diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /karbon/dialogs | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'karbon/dialogs')
-rw-r--r-- | karbon/dialogs/Makefile.am | 22 | ||||
-rw-r--r-- | karbon/dialogs/vcolordlg.cc | 45 | ||||
-rw-r--r-- | karbon/dialogs/vcolordlg.h | 43 | ||||
-rw-r--r-- | karbon/dialogs/vcolortab.cc | 199 | ||||
-rw-r--r-- | karbon/dialogs/vcolortab.h | 65 | ||||
-rw-r--r-- | karbon/dialogs/vconfiguredlg.cc | 461 | ||||
-rw-r--r-- | karbon/dialogs/vconfiguredlg.h | 163 | ||||
-rw-r--r-- | karbon/dialogs/vstrokedlg.cc | 216 | ||||
-rw-r--r-- | karbon/dialogs/vstrokedlg.h | 66 |
9 files changed, 1280 insertions, 0 deletions
diff --git a/karbon/dialogs/Makefile.am b/karbon/dialogs/Makefile.am new file mode 100644 index 00000000..7856355a --- /dev/null +++ b/karbon/dialogs/Makefile.am @@ -0,0 +1,22 @@ +INCLUDES = $(KOFFICE_INCLUDES) $(KOPAINTER_INCLUDES) \ + -I$(srcdir)/.. \ + -I$(srcdir)/../core \ + -I$(srcdir)/../commands \ + $(all_includes) + +noinst_LTLIBRARIES = \ + libkarbondialogs.la + +noinst_HEADERS = \ + vcolordlg.h \ + vconfiguredlg.h \ + vcolortab.h + +libkarbondialogs_la_SOURCES = \ + vcolordlg.cc \ + vconfiguredlg.cc \ + vcolortab.cc + +libkarbondialogs_la_METASOURCES = \ + AUTO + diff --git a/karbon/dialogs/vcolordlg.cc b/karbon/dialogs/vcolordlg.cc new file mode 100644 index 00000000..6acefa24 --- /dev/null +++ b/karbon/dialogs/vcolordlg.cc @@ -0,0 +1,45 @@ +/* This file is part of the KDE project + Copyright (C) 2001, The Karbon Developers + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include <klocale.h> + +#include "vcolor.h" +#include "vcolordlg.h" +#include "vcolortab.h" + +VColorDlg::VColorDlg( const VColor &c, QWidget* parent, const char* name ) + : KDialogBase ( parent, name, true, i18n( "Uniform Color" ), + KDialogBase::Ok | KDialogBase::Cancel ) +{ + m_colortab = new VColorTab( VColor( c ), this, name ); + + setMainWidget( m_colortab ); + setFixedSize( baseSize() ); +} + +VColor +VColorDlg::Color() +{ + return m_colortab->Color(); +} + + +#include "vcolordlg.moc" + diff --git a/karbon/dialogs/vcolordlg.h b/karbon/dialogs/vcolordlg.h new file mode 100644 index 00000000..820bb1bf --- /dev/null +++ b/karbon/dialogs/vcolordlg.h @@ -0,0 +1,43 @@ +/* This file is part of the KDE project + Copyright (C) 2001, The Karbon Developers + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef __VCOLORDLG_H__ +#define __VCOLORDLG_H__ + +#include <kdialogbase.h> + +class VColor; +class VColorTab; +class VFill; + +class VColorDlg : public KDialogBase +{ + Q_OBJECT + +public: + VColorDlg( const VColor &c, QWidget* parent = 0L, const char* name = 0L ); + + VColor Color(); + +private: + VColorTab* m_colortab; +}; +#endif + diff --git a/karbon/dialogs/vcolortab.cc b/karbon/dialogs/vcolortab.cc new file mode 100644 index 00000000..037fdc6e --- /dev/null +++ b/karbon/dialogs/vcolortab.cc @@ -0,0 +1,199 @@ +/* This file is part of the KDE project + Copyright (C) 2001, The Karbon Developers + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include <qgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> + +#include <kcolordialog.h> +#include <klocale.h> +#include <knuminput.h> + +#include "vcolor.h" +#include "vfillcmd.h" +#include "vcolortab.h" +#include "vselection.h" + +#include <kdebug.h> + + +VColorTab::VColorTab( const VColor &c, QWidget* parent, const char* name ) + : QTabWidget( parent, name ) +{ + QGridLayout *mainLayout; + + mRGBWidget = new QWidget( this ); + mainLayout = new QGridLayout( mRGBWidget, 3, 3 ); + mColorSelector = new KHSSelector( mRGBWidget ); + mColorSelector->setMinimumHeight( 165 ); + mColorSelector->setMinimumWidth( 165 ); + connect( mColorSelector, SIGNAL( valueChanged( int, int ) ), this, SLOT( slotHSChanged( int, int ) ) ); + mainLayout->addMultiCellWidget(mColorSelector, 0, 2, 0, 0 ); + + //Selector + mSelector = new KGradientSelector( KSelector::Vertical, mRGBWidget ); + mSelector->setColors( QColor( "white" ), QColor( "black" ) ); + mSelector->setMinimumWidth( 20 ); + //TODO: Make it autochange color if the solid-filled object is selected (also for QSpinBoxes) + connect( mSelector, SIGNAL( valueChanged( int ) ), this, SLOT( slotVChanged( int ) ) ); + mainLayout->addMultiCellWidget( mSelector, 0, 2, 1, 1 ); + + //Reference + QGroupBox* groupbox = new QGroupBox( 2, Vertical, i18n( "Reference" ), mRGBWidget ); + new QLabel( i18n( "Old:" ), groupbox ); + new QLabel( i18n( "New:" ), groupbox ); + mOldColor = new KColorPatch( groupbox ); + mColorPreview = new KColorPatch( groupbox ); + + QColor color( c ); + mOldColor->setColor( color ); + mColorPreview->setColor( color ); + mainLayout->addWidget( groupbox, 0, 2 ); + + //Components + QGroupBox* cgroupbox = new QGroupBox( 3, Vertical, i18n( "Components" ), mRGBWidget ); + + //--->RGB + new QLabel( i18n( "R:" ), cgroupbox ); + new QLabel( i18n( "G:" ), cgroupbox ); + new QLabel( i18n( "B:" ), cgroupbox ); + mRed = new KIntSpinBox( 0, 255, 1, 0, 10, cgroupbox ); + mGreen = new KIntSpinBox( 0, 255, 1, 0, 10, cgroupbox ); + mBlue = new KIntSpinBox( 0, 255, 1, 0, 10, cgroupbox ); + connect( mRed, SIGNAL( valueChanged(int) ), this, SLOT( slotUpdateFromRGBSpinBoxes() ) ); + connect( mGreen, SIGNAL( valueChanged(int) ), this, SLOT( slotUpdateFromRGBSpinBoxes() ) ); + connect( mBlue, SIGNAL( valueChanged(int) ), this, SLOT( slotUpdateFromRGBSpinBoxes() ) ); + + //--->HSV + new QLabel( i18n( "Hue:", "H:" ), cgroupbox ); + new QLabel( i18n( "Saturation:", "S:" ), cgroupbox ); + new QLabel( i18n( "Value:", "V:" ), cgroupbox ); + mHue = new KIntSpinBox( 0, 359, 1, 0, 10, cgroupbox ); + mSaturation = new KIntSpinBox( 0, 255, 1, 0, 10, cgroupbox ); + mValue = new KIntSpinBox( 0, 255, 1, 0, 10, cgroupbox ); + connect( mHue, SIGNAL( valueChanged(int) ), this, SLOT( slotUpdateFromHSVSpinBoxes() ) ); + connect( mSaturation, SIGNAL( valueChanged(int) ), this, SLOT( slotUpdateFromHSVSpinBoxes() ) ); + connect( mValue, SIGNAL( valueChanged(int) ), this, SLOT( slotUpdateFromHSVSpinBoxes() ) ); + mainLayout->addWidget( cgroupbox, 1, 2 ); + + //--->Opacity + QGroupBox* ogroupBox = new QGroupBox( 1, Vertical, i18n( "Opacity" ), mRGBWidget ); + mOpacity = new KIntNumInput( 100, ogroupBox ); + mOpacity->setRange( 0, 100, 1, true ); + mOpacity->setValue( int( c.opacity() * 100.0 ) ); + mainLayout->addWidget( ogroupBox, 2, 2 ); + + mainLayout->setSpacing( 2 ); + mainLayout->setMargin( 5 ); + + mainLayout->activate(); + + addTab( mRGBWidget, i18n( "RGB" ) ); + + mRed->setValue( color.red() ); + mGreen->setValue( color.green() ); + mBlue->setValue( color.blue() ); +} + +void VColorTab::slotUpdateFromRGBSpinBoxes() +{ + QColor color( mRed->value(), mGreen->value(), mBlue->value(), QColor::Rgb ); + mColorPreview->setColor( color ); + mColorPreview->update(); + + // set HSV + mHue->blockSignals( true ); + mSaturation->blockSignals( true ); + mValue->blockSignals( true ); + + int h, s, v; + color.hsv( &h, &s, &v ); + mHue->setValue( h ); + mSaturation->setValue( s ); + mValue->setValue( v ); + + // update gradient selector + mSelector->blockSignals( true ); + mColorSelector->setValues( h, s ); + slotHSChanged( h, s ); + mSelector->setValue( static_cast<int>( ( float( mValue->value() ) / 255.0 ) * 99.0 ) ); + mSelector->blockSignals( false ); + + mHue->blockSignals( false ); + mSaturation->blockSignals( false ); + mValue->blockSignals( false ); +} + +void VColorTab::slotUpdateFromHSVSpinBoxes() +{ + QColor color( mHue->value(), mSaturation->value(), mValue->value(), QColor::Hsv ); + mColorPreview->setColor( color ); + mColorPreview->update(); + + // update gradient selector + mSelector->blockSignals( true ); + mSelector->setValue( static_cast<int>( ( float( mValue->value() ) / 255.0 ) * 99.0 ) ); + mSelector->blockSignals( false ); + + // set RGB + mRed->blockSignals( true ); + mGreen->blockSignals( true ); + mBlue->blockSignals( true ); + + mRed->setValue( color.red() ); + mGreen->setValue( color.green() ); + mBlue->setValue( color.blue() ); + + mRed->blockSignals( false ); + mGreen->blockSignals( false ); + mBlue->blockSignals( false ); +} + +VColor VColorTab::Color() +{ + kdDebug() << "VColorTab::slotApplyButtonPressed" << endl; + float r = mRed->value() / 255.0, g = mGreen->value() / 255.0, b = mBlue->value() / 255.0; + float op = mOpacity->value() / 100.0; + + VColor c; + c.set( r, g, b ); + c.setOpacity( op ); + + return c; +} + +void VColorTab::slotHSChanged( int h, int s ) +{ + //QColor color( mHue->value(), mSaturation->value(), newVal, QColor::Hsv ); + mHue->setValue( h ); + mSaturation->setValue( s ); + QColor color1( h, s, 255, QColor::Hsv ); + QColor color2( h, s, 0, QColor::Hsv ); + mSelector->setColors( color1, color2 ); +} + +void VColorTab::slotVChanged( int newVal ) +{ + //QColor color( mHue->value(), mSaturation->value(), newVal, QColor::Hsv ); + mValue->setValue( static_cast<int>( float( newVal ) / 99.0 * 255.0 ) ); +} + +#include "vcolortab.moc" + diff --git a/karbon/dialogs/vcolortab.h b/karbon/dialogs/vcolortab.h new file mode 100644 index 00000000..18a00f7c --- /dev/null +++ b/karbon/dialogs/vcolortab.h @@ -0,0 +1,65 @@ +/* This file is part of the KDE project + Copyright (C) 2001, The Karbon Developers + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef __VCOLORTAB_H +#define __VCOLORTAB_H + +#include <qtabwidget.h> + +class QColor; +class KHSSelector; +class KIntSpinBox; +class KGradientSelector; +class KColorPatch; +class KIntNumInput; +class VColor; + +class VColorTab : public QTabWidget +{ + Q_OBJECT + +public: + VColorTab( const VColor &c, QWidget* parent = 0L, const char* name = 0L ); + + VColor Color(); + +private: + QWidget* mRGBWidget; + KHSSelector* mColorSelector; + KIntSpinBox* mRed; + KIntSpinBox* mGreen; + KIntSpinBox* mBlue; + KIntSpinBox* mHue; + KIntSpinBox* mSaturation; + KIntSpinBox* mValue; + KIntNumInput* mOpacity; + KGradientSelector* mSelector; + KColorPatch* mOldColor; + KColorPatch* mColorPreview; + +private slots: + void slotUpdateFromRGBSpinBoxes(); + void slotUpdateFromHSVSpinBoxes(); + void slotVChanged( int ); + void slotHSChanged( int, int ); +}; + +#endif + diff --git a/karbon/dialogs/vconfiguredlg.cc b/karbon/dialogs/vconfiguredlg.cc new file mode 100644 index 00000000..c8439753 --- /dev/null +++ b/karbon/dialogs/vconfiguredlg.cc @@ -0,0 +1,461 @@ +/* This file is part of the KDE project + Copyright (C) 2002, 2003 Laurent Montel <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include <float.h> + +#include <qcheckbox.h> +#include <qgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qvbox.h> +#include <qvgroupbox.h> +#include <qcombobox.h> +#include <qgrid.h> + +#include <kiconloader.h> +#include <kconfig.h> +#include <kdialogbase.h> +#include <klocale.h> +#include <knuminput.h> +#include <kcolorbutton.h> +#include <KoUnitWidgets.h> + +#include "karbon_view.h" +#include "karbon_part.h" +#include "karbon_factory.h" + +#include "vconfiguredlg.h" + + +VConfigureDlg::VConfigureDlg( KarbonView* parent ) + : KDialogBase( KDialogBase::IconList, i18n( "Configure" ), + KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel | KDialogBase::Default, + KDialogBase::Ok, parent ) + +{ + QVBox * page = addVBoxPage( + i18n( "Interface" ), i18n( "Interface" ), + BarIcon( "misc", KIcon::SizeMedium ) ); + + m_interfacePage = new VConfigInterfacePage( parent, page ); + + page = addVBoxPage( + i18n( "Misc" ), i18n( "Misc" ), + BarIcon( "misc", KIcon::SizeMedium ) ); + + m_miscPage = new VConfigMiscPage( parent, page ); + + page = addVBoxPage( + i18n( "Grid" ), i18n( "Grid" ), + BarIcon( "grid", KIcon::SizeMedium ) ); + + m_gridPage = new VConfigGridPage( parent, page ); + + connect( m_miscPage, SIGNAL( unitChanged( int ) ), m_gridPage, SLOT( slotUnitChanged( int ) ) ); + + page = addVBoxPage( + i18n( "Document" ), i18n( "Document Settings" ), + BarIcon( "document", KIcon::SizeMedium ) ); + + m_defaultDocPage = new VConfigDefaultPage( parent, page ); + connect( this, SIGNAL( okClicked() ), this, SLOT( slotApply() ) ); +} + +void VConfigureDlg::slotApply() +{ + m_interfacePage->apply(); + m_miscPage->apply(); + m_defaultDocPage->apply(); + m_gridPage->apply(); +} + +void VConfigureDlg::slotDefault() +{ + switch( activePageIndex() ) + { + case 0: m_interfacePage->slotDefault(); + break; + case 1: m_miscPage->slotDefault(); + break; + case 2: m_gridPage->slotDefault(); + break; + case 3: m_defaultDocPage->slotDefault(); + break; + default: + break; + } +} + + +VConfigInterfacePage::VConfigInterfacePage( KarbonView* view, + QVBox* box, char* name ) + : QObject( box->parent(), name ) +{ + m_view = view; + m_config = KarbonFactory::instance()->config(); + + m_oldRecentFiles = 10; + m_oldCopyOffset = 10; + m_oldDockerFontSize = 8; + bool oldShowStatusBar = true; + + QVGroupBox* tmpQGroupBox = new QVGroupBox( i18n( "Interface" ), box ); + + m_config->setGroup( "" ); + + m_oldDockerFontSize = m_config->readNumEntry( "palettefontsize", m_oldDockerFontSize ); + + if( m_config->hasGroup( "Interface" ) ) + { + m_config->setGroup( "Interface" ); + + m_oldRecentFiles = m_config->readNumEntry( + "NbRecentFile", m_oldRecentFiles ); + + oldShowStatusBar = m_config->readBoolEntry( + "ShowStatusBar" , true ); + + m_oldCopyOffset = m_config->readNumEntry( + "CopyOffset", m_oldCopyOffset ); + } + + m_showStatusBar = new QCheckBox( i18n( "Show status bar" ), tmpQGroupBox ); + m_showStatusBar->setChecked( oldShowStatusBar ); + + m_recentFiles = new KIntNumInput( m_oldRecentFiles, tmpQGroupBox ); + m_recentFiles->setRange( 1, 20, 1 ); + m_recentFiles->setLabel( i18n( "Number of recent files:" ) ); + + m_copyOffset = new KIntNumInput( m_oldCopyOffset, tmpQGroupBox ); + m_copyOffset->setRange( 1, 50, 1 ); + m_copyOffset->setLabel( i18n( "Copy offset:" ) ); + + m_dockerFontSize = new KIntNumInput( m_oldDockerFontSize, tmpQGroupBox ); + m_dockerFontSize->setRange( 5, 20, 1 ); + m_dockerFontSize->setLabel( i18n( "Palette font size:" ) ); +} + +void VConfigInterfacePage::apply() +{ + bool showStatusBar = m_showStatusBar->isChecked(); + + KarbonPart* part = m_view->part(); + + m_config->setGroup( "Interface" ); + + int recent = m_recentFiles->value(); + + if( recent != m_oldRecentFiles ) + { + m_config->writeEntry( "NbRecentFile", recent ); + m_view->setNumberOfRecentFiles( recent ); + m_oldRecentFiles = recent; + } + + int copyOffset = m_copyOffset->value(); + + if( copyOffset != m_oldCopyOffset ) + { + m_config->writeEntry( "CopyOffset", copyOffset ); + m_oldCopyOffset = copyOffset; + } + + bool refreshGUI = false; + + if( showStatusBar != part->showStatusBar() ) + { + m_config->writeEntry( "ShowStatusBar", showStatusBar ); + part->setShowStatusBar( showStatusBar ); + refreshGUI = true; + } + + m_config->setGroup( "" ); + + int dockerFontSize = m_dockerFontSize->value(); + + if( dockerFontSize != m_oldDockerFontSize ) + { + m_config->writeEntry( "palettefontsize", dockerFontSize ); + m_oldDockerFontSize = dockerFontSize; + refreshGUI = true; + } + + if( refreshGUI ) + part->reorganizeGUI(); + +} + +void VConfigInterfacePage::slotDefault() +{ + m_recentFiles->setValue( 10 ); + m_dockerFontSize->setValue( 8 ); + m_showStatusBar->setChecked( true ); +} + + +VConfigMiscPage::VConfigMiscPage( KarbonView* view, QVBox* box, char* name ) + : QObject( box->parent(), name ) +{ + m_view = view; + m_config = KarbonFactory::instance()->config(); + + KoUnit::Unit unit = view->part()->unit(); + + QGroupBox* tmpQGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Misc" ), box, "GroupBox" ); + tmpQGroupBox->layout()->setSpacing(KDialog::spacingHint()); + tmpQGroupBox->layout()->setMargin(KDialog::marginHint()); + + QGridLayout* grid = new QGridLayout(tmpQGroupBox->layout(), 4, 2 ); + + m_oldUndoRedo = 30; + + QString unitType = KoUnit::unitName( unit ); + //#################"laurent + //don't load unitType from config file because unit is + //depend from kword file => unit can be different from config file + + if( m_config->hasGroup( "Misc" ) ) + { + m_config->setGroup( "Misc" ); + m_oldUndoRedo = m_config->readNumEntry( "UndoRedo", m_oldUndoRedo ); + } + + m_undoRedo = new KIntNumInput( m_oldUndoRedo, tmpQGroupBox ); + m_undoRedo->setLabel( i18n( "Undo/redo limit:" ) ); + m_undoRedo->setRange( 10, 60, 1 ); + + grid->addMultiCellWidget( m_undoRedo, 0, 0, 0, 1 ); + + grid->addWidget( new QLabel( i18n( "Units:" ), tmpQGroupBox ), 1, 0 ); + + m_unit = new QComboBox( tmpQGroupBox ); + m_unit->insertStringList( KoUnit::listOfUnitName() ); + grid->addWidget( m_unit, 1, 1 ); + m_oldUnit = KoUnit::unit( unitType ); + m_unit->setCurrentItem( m_oldUnit ); + connect( m_unit, SIGNAL( activated( int ) ), SIGNAL( unitChanged( int ) ) ); +} + +void VConfigMiscPage::apply() +{ + KarbonPart * part = m_view->part(); + + m_config->setGroup( "Misc" ); + + if( m_oldUnit != m_unit->currentItem() ) + { + m_oldUnit = m_unit->currentItem(); + part->setUnit( static_cast<KoUnit::Unit>( m_oldUnit ) ); + part->document().setUnit(part->unit()); + m_config->writeEntry( "Units", KoUnit::unitName( part->unit() ) ); + } + + int newUndo = m_undoRedo->value(); + + if( newUndo != m_oldUndoRedo ) + { + m_config->writeEntry( "UndoRedo", newUndo ); + part->setUndoRedoLimit( newUndo ); + m_oldUndoRedo = newUndo; + } +} + +void VConfigMiscPage::slotDefault() +{ + m_undoRedo->setValue( 30 ); + m_unit->setCurrentItem( 0 ); +} + +VConfigGridPage::VConfigGridPage( KarbonView* view, QVBox* page, char* name ) + : QObject( page->parent(), name ) +{ + m_view = view; + KoUnit::Unit unit = view->part()->document().unit(); + KarbonGridData &gd = view->part()->document().grid(); + double pgw = view->part()->document().width(); + double pgh = view->part()->document().height(); + double fw = gd.freq.width(); + double fh = gd.freq.height(); + double sw = gd.snap.width(); + double sh = gd.snap.height(); + + m_gridChBox = new QCheckBox( i18n( "Show &grid" ), page ); + m_gridChBox->setChecked( gd.isShow ); + m_snapChBox = new QCheckBox( i18n( "Snap to g&rid" ), page ); + m_snapChBox->setChecked( gd.isSnap ); + QLabel* gridColorLbl = new QLabel( i18n( "Grid &color:" ), page); + m_gridColorBtn = new KColorButton( gd.color, page ); + gridColorLbl->setBuddy( m_gridColorBtn ); + QGroupBox* spacingGrp = new QGroupBox( 2, Qt::Horizontal, i18n( "Spacing" ), page ); + QLabel* spaceHorizLbl = new QLabel( i18n( "&Horizontal:" ), spacingGrp ); + m_spaceHorizUSpin = new KoUnitDoubleSpinBox( spacingGrp, 0.0, pgw, 0.1, fw, unit ); + spaceHorizLbl->setBuddy( m_spaceHorizUSpin ); + QLabel* spaceVertLbl = new QLabel( i18n( "&Vertical:" ), spacingGrp ); + m_spaceVertUSpin = new KoUnitDoubleSpinBox( spacingGrp, 0.0, pgh, 0.1, fh, unit ); + spaceVertLbl->setBuddy( m_spaceVertUSpin ); + QGroupBox* snapGrp = new QGroupBox( 2, Qt::Horizontal, i18n( "Snap Distance" ), page ); + QLabel* snapHorizLbl = new QLabel( i18n( "H&orizontal:" ), snapGrp ); + m_snapHorizUSpin = new KoUnitDoubleSpinBox( snapGrp, 0.0, fw, 0.1, sw, unit ); + snapHorizLbl->setBuddy( m_snapHorizUSpin ); + QLabel* snapVertLbl = new QLabel( i18n( "V&ertical:" ), snapGrp ); + m_snapVertUSpin = new KoUnitDoubleSpinBox( snapGrp, 0.0, fh, 0.1, sh, unit ); + snapVertLbl->setBuddy( m_snapVertUSpin ); + + QGridLayout* gl = new QGridLayout(); + gl->setSpacing( KDialog::spacingHint() ); + gl->addMultiCellWidget( m_gridChBox, 0, 0, 0, 2 ); + gl->addMultiCellWidget( m_snapChBox, 1, 1, 0, 2 ); + gl->addWidget( gridColorLbl, 2, 0) ; + gl->addWidget( m_gridColorBtn, 2, 1 ); + gl->addItem( new QSpacerItem( 0, 0 ), 2, 2 ); + gl->addMultiCellWidget( spacingGrp, 3, 3, 0, 2 ); + gl->addMultiCellWidget( snapGrp, 4, 4, 0, 2 ); + gl->addMultiCell( new QSpacerItem( 0, 0 ), 5, 5, 0, 2 ); + + connect( m_spaceHorizUSpin, SIGNAL( valueChanged( double ) ), SLOT( setMaxHorizSnap( double ) ) ); + connect( m_spaceVertUSpin, SIGNAL( valueChanged( double ) ), SLOT( setMaxVertSnap( double ) ) ) ; +} + +void VConfigGridPage::setMaxHorizSnap( double v ) +{ + m_snapHorizUSpin->setMaxValue( v ); +} + +void VConfigGridPage::setMaxVertSnap( double v ) +{ + m_snapVertUSpin->setMaxValue( v ); +} + +void VConfigGridPage::slotUnitChanged( int u ) +{ + KoUnit::Unit unit = static_cast<KoUnit::Unit>( u ); + m_snapHorizUSpin->setUnit( unit ); + m_snapVertUSpin->setUnit( unit ); + m_spaceHorizUSpin->setUnit( unit ); + m_spaceVertUSpin->setUnit( unit ); +} + +void VConfigGridPage::apply() +{ + KarbonGridData &gd = m_view->part()->document().grid(); + gd.freq.setWidth( m_spaceHorizUSpin->value() ); + gd.freq.setHeight( m_spaceVertUSpin->value() ); + gd.snap.setWidth( m_snapHorizUSpin->value() ); + gd.snap.setHeight( m_snapVertUSpin->value() ); + gd.isShow = m_gridChBox->isChecked(); + gd.isSnap = m_snapChBox->isChecked(); + gd.color = m_gridColorBtn->color(); + m_view->repaintAll(); +} + +void VConfigGridPage::slotDefault() +{ + KoUnit::Unit unit = m_view->part()->document().unit(); + m_spaceHorizUSpin->setValue( KoUnit::toUserValue( 20.0, unit ) ); + m_spaceVertUSpin->setValue( KoUnit::toUserValue( 20.0, unit ) ); + m_snapHorizUSpin->setValue( KoUnit::toUserValue( 20.0, unit ) ); + m_snapVertUSpin->setValue( KoUnit::toUserValue( 20.0, unit ) ); + m_gridChBox->setChecked( true ); + m_snapChBox->setChecked( true ); + m_gridColorBtn->setColor( QColor( 228, 228, 228 ) ); +} + +VConfigDefaultPage::VConfigDefaultPage( KarbonView* view, + QVBox* box, char* name ) + : QObject( box->parent(), name ) +{ + m_view = view; + + m_config = KarbonFactory::instance()->config(); + + QVGroupBox* gbDocumentSettings = new QVGroupBox( + i18n( "Document Settings" ), box ); + gbDocumentSettings->setMargin( KDialog::marginHint() ); + gbDocumentSettings->setInsideSpacing( KDialog::spacingHint() ); + + m_oldAutoSave = m_view->part()->defaultAutoSave() / 60; + + m_oldBackupFile = true; + + m_oldSaveAsPath = true; + + if( m_config->hasGroup( "Interface" ) ) + { + m_config->setGroup( "Interface" ); + m_oldAutoSave = m_config->readNumEntry( "AutoSave", m_oldAutoSave ); + m_oldBackupFile = m_config->readBoolEntry( "BackupFile", m_oldBackupFile ); + m_oldSaveAsPath = m_config->readBoolEntry( "SaveAsPath", m_oldSaveAsPath ); + } + + m_autoSave = new KIntNumInput( m_oldAutoSave, gbDocumentSettings ); + m_autoSave->setRange( 0, 60, 1 ); + m_autoSave->setLabel( i18n( "Auto save (min):" ) ); + m_autoSave->setSpecialValueText( i18n( "No auto save" ) ); + m_autoSave->setSuffix( i18n( "min" ) ); + + m_createBackupFile = new QCheckBox( i18n( "Create backup file" ), gbDocumentSettings ); + m_createBackupFile->setChecked( m_oldBackupFile ); + + m_saveAsPath = new QCheckBox( i18n( "Save as path" ), gbDocumentSettings ); + m_saveAsPath->setChecked( m_oldSaveAsPath ); +} + +void VConfigDefaultPage::apply() +{ + m_config->setGroup( "Document defaults" ); + + m_config->setGroup( "Interface" ); + + int autoSave = m_autoSave->value(); + + if( autoSave != m_oldAutoSave ) + { + m_config->writeEntry( "AutoSave", autoSave ); + m_view->part()->setAutoSave( autoSave * 60 ); + m_oldAutoSave = autoSave; + } + + bool state = m_createBackupFile->isChecked(); + + if( state != m_oldBackupFile ) + { + m_config->writeEntry( "BackupFile", state ); + m_view->part()->setBackupFile( state ); + m_oldBackupFile = state; + } + + state = m_saveAsPath->isChecked(); + + //if( state != m_oldSaveAsPath ) + //{ + m_config->writeEntry( "SaveAsPath", state ); + m_view->part()->document().saveAsPath( state ); + m_oldSaveAsPath = state; + //} +} + +void VConfigDefaultPage::slotDefault() +{ + m_autoSave->setValue( m_view->part()->defaultAutoSave() / 60 ); + m_createBackupFile->setChecked( true ); + m_saveAsPath->setChecked( true ); +} + +#include "vconfiguredlg.moc" + diff --git a/karbon/dialogs/vconfiguredlg.h b/karbon/dialogs/vconfiguredlg.h new file mode 100644 index 00000000..f1470bea --- /dev/null +++ b/karbon/dialogs/vconfiguredlg.h @@ -0,0 +1,163 @@ +/* This file is part of the KDE project + Copyright (C) 2002, Laurent Montel <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef __VCONFIGUREDLG_H__ +#define __VCONFIGUREDLG_H__ + + +#include <kdialogbase.h> + +class KarbonView; +class KConfig; +class KIntNumInput; +class KColorButton; +class KoUnitDoubleSpinBox; +class QCheckBox; +class QComboBox; + +class VConfigInterfacePage : public QObject +{ + Q_OBJECT + +public: + VConfigInterfacePage( + KarbonView* view, QVBox *box = 0L, char* name = 0L ); + + void apply(); + +public slots: + void slotDefault(); + +private: + KarbonView* m_view; + KConfig* m_config; + + KIntNumInput* m_recentFiles; + int m_oldRecentFiles; + + QCheckBox* m_showStatusBar; + + KIntNumInput* m_copyOffset; + int m_oldCopyOffset; + + KIntNumInput* m_dockerFontSize; + int m_oldDockerFontSize; +}; + + +class VConfigMiscPage : public QObject +{ + Q_OBJECT + +public: + VConfigMiscPage( + KarbonView* view, QVBox* box, char* name = 0L ); + + void apply(); + +signals: + void unitChanged( int ); + +public slots: + void slotDefault(); + +private: + KarbonView* m_view; + KConfig* m_config; + + KIntNumInput* m_undoRedo; + int m_oldUndoRedo; + int m_oldUnit; + QComboBox *m_unit; +}; + +class VConfigDefaultPage : public QObject +{ + Q_OBJECT + +public: + VConfigDefaultPage( + KarbonView* view, QVBox* box, char* name = 0L ); + + void apply(); + +public slots: + void slotDefault(); + +private: + KarbonView* m_view; + KConfig* m_config; + + KIntNumInput* m_autoSave; + int m_oldAutoSave; + QCheckBox *m_createBackupFile; + bool m_oldBackupFile; + QCheckBox *m_saveAsPath; + bool m_oldSaveAsPath; +}; + +class VConfigGridPage : public QObject +{ + Q_OBJECT + +public: + VConfigGridPage( + KarbonView* view, QVBox* box, char* name = 0L ); + + void apply(); + +public slots: + void slotDefault(); + void slotUnitChanged( int ); + +protected slots: + void setMaxHorizSnap( double v ); + void setMaxVertSnap( double v ); + +private: + KarbonView* m_view; + KoUnitDoubleSpinBox* m_spaceHorizUSpin; + KoUnitDoubleSpinBox* m_spaceVertUSpin; + KoUnitDoubleSpinBox* m_snapHorizUSpin; + KoUnitDoubleSpinBox* m_snapVertUSpin; + QCheckBox* m_gridChBox; + QCheckBox* m_snapChBox; + KColorButton* m_gridColorBtn; +}; + +class VConfigureDlg : public KDialogBase +{ + Q_OBJECT + +public: + VConfigureDlg( KarbonView* parent ); + +public slots: + void slotApply(); + void slotDefault(); + +private: + VConfigInterfacePage* m_interfacePage; + VConfigMiscPage* m_miscPage; + VConfigGridPage* m_gridPage; + VConfigDefaultPage* m_defaultDocPage; +}; + +#endif + diff --git a/karbon/dialogs/vstrokedlg.cc b/karbon/dialogs/vstrokedlg.cc new file mode 100644 index 00000000..ed530178 --- /dev/null +++ b/karbon/dialogs/vstrokedlg.cc @@ -0,0 +1,216 @@ +/* This file is part of the KDE project + Copyright (C) 2001, The Karbon Developers + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include <qcombobox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtabwidget.h> +#include <qradiobutton.h> +#include <qvbuttongroup.h> + +#include <kiconloader.h> +#include <klocale.h> +#include <kstandarddirs.h> + +#include "KoUnitWidgets.h" + +#include "karbon_part.h" +#include "vcolor.h" +#include "vselection.h" +#include "vstrokecmd.h" +#include "vstroke.h" +#include "vstrokedlg.h" +#include "vcolortab.h" + +VStrokeDlg::VStrokeDlg( KarbonPart* part, QWidget* parent, const char* name ) + : KDialogBase ( parent, name, true, i18n( "Stroke" ), Ok | Cancel ), m_part( part ) +{ + enableButtonSeparator( true ); + QTabWidget *mainWidget = new QTabWidget( this, "strokemain" ); + QHBoxLayout *mainLayout = new QHBoxLayout (mainWidget, 3); + + QVBoxLayout *leftLayout = new QVBoxLayout( mainLayout, 4 ); + + QLabel* widthLabel = new QLabel( i18n ( "stroke width", "Width:" ), mainWidget ); + leftLayout->addWidget ( widthLabel ); + m_setLineWidth = new KoUnitDoubleSpinBox( mainWidget, 0.0, 1000.0, 0.5, 1.0, KoUnit::U_PT, 1 ); + leftLayout->addWidget ( m_setLineWidth ); + + //Dashing -> + QLabel* styleLabel = new QLabel( i18n ( "Style:" ), mainWidget ); + leftLayout->addWidget ( styleLabel ); + m_styleCombo = new QComboBox( mainWidget ); + m_styleCombo->setEnabled ( false ); + leftLayout->addWidget ( m_styleCombo ); + // <- Dashing - reserved for later + + QRadioButton* button; + m_typeOption = new QVButtonGroup ( mainWidget ); + button = new QRadioButton ( i18n( "None" ), m_typeOption ); + m_typeOption->insert( button ); + button = new QRadioButton ( i18n( "Stroke" ), m_typeOption ); + m_typeOption->insert( button ); + button = new QRadioButton ( i18n( "Gradient" ), m_typeOption ); + m_typeOption->insert( button ); + m_typeOption->setTitle( i18n( "Type" ) ); + mainLayout->addWidget( m_typeOption ); + connect( m_typeOption, SIGNAL( clicked( int ) ), this, SLOT( slotTypeChanged( int ) ) ); + + m_capOption = new QVButtonGroup ( mainWidget ); + //button = new QRadioButton ( i18n( "Butt" ), m_capOption ); + button = new QRadioButton ( m_capOption ); + button->setPixmap( DesktopIcon( "cap_butt" ) ); + m_capOption->insert( button ); + button = new QRadioButton ( m_capOption ); + button->setPixmap( DesktopIcon( "cap_round" ) ); + m_capOption->insert( button ); + button = new QRadioButton ( m_capOption ); + button->setPixmap( DesktopIcon( "cap_square" ) ); + m_capOption->insert( button ); + m_capOption->setTitle( i18n( "Cap" ) ); + mainLayout->addWidget( m_capOption ); + connect( m_capOption, SIGNAL( clicked( int ) ), this, SLOT( slotCapChanged( int ) ) ); + + m_joinOption = new QVButtonGroup ( mainWidget ); + button = new QRadioButton ( m_joinOption ); + button->setPixmap( DesktopIcon( "join_miter" ) ); + m_joinOption->insert( button ); + button = new QRadioButton ( m_joinOption ); + button->setPixmap( DesktopIcon( "join_round" ) ); + m_joinOption->insert( button ); + button = new QRadioButton ( m_joinOption ); + button->setPixmap( DesktopIcon( "join_bevel" ) ); + m_joinOption->insert( button ); + m_joinOption->setTitle( i18n( "Join" ) ); + mainLayout->addWidget( m_joinOption ); + connect( m_joinOption, SIGNAL( clicked( int ) ), this, SLOT( slotJoinChanged( int ) ) ); + + VSelection *sel = part->document().selection(); + if( sel && sel->objects().count() > 0 ) // there is a selection, so take the stroke of first selected object + { + m_stroke.setType ( sel->objects().getFirst()->stroke()->type() ); + m_stroke.setColor ( sel->objects().getFirst()->stroke()->color() ); + m_stroke.setLineWidth ( sel->objects().getFirst()->stroke()->lineWidth() ); + m_stroke.setLineCap ( sel->objects().getFirst()->stroke()->lineCap() ); + m_stroke.setLineJoin ( sel->objects().getFirst()->stroke()->lineJoin() ); + m_stroke.setMiterLimit ( sel->objects().getFirst()->stroke()->miterLimit() ); + } + + slotUpdateDialog(); //Put the values of selected objects (or default) + mainLayout->activate(); + + //setMainWidget( mainWidget ); + + m_colortab = new VColorTab( sel->objects().count() == 0 ? sel->stroke()->color() : + sel->objects().getFirst()->stroke()->color(), this); + m_colortab->insertTab( mainWidget, i18n("Stroke"), 0 ); + m_colortab->setCurrentPage( 0 ); + + setMainWidget( m_colortab ); + + disableResize(); + connect (this, SIGNAL( okClicked( void ) ), this, SLOT( slotOKClicked ( void ) ) ); +} + +void VStrokeDlg::slotTypeChanged( int ID ) +{ + switch ( ID ) { + case 1: + m_stroke.setType ( VStroke::solid ); break; + case 2: + m_stroke.setType ( VStroke::grad ); break; + default: + m_stroke.setType ( VStroke::none ); + } +} + +void VStrokeDlg::slotCapChanged( int ID ) +{ + switch ( ID ) { + case 1: + m_stroke.setLineCap ( VStroke::capRound ); break; + case 2: + m_stroke.setLineCap ( VStroke::capSquare ); break; + default: + m_stroke.setLineCap ( VStroke::capButt ); + } +} + +void VStrokeDlg::slotJoinChanged( int ID ) +{ + switch ( ID ) { + case 1: + m_stroke.setLineJoin ( VStroke::joinRound ); break; + case 2: + m_stroke.setLineJoin ( VStroke::joinBevel ); break; + default: + m_stroke.setLineJoin ( VStroke::joinMiter ); + } +} + +void VStrokeDlg::slotOKClicked() +{ + m_stroke.setLineWidth ( m_setLineWidth->value() ); + + m_stroke.setColor( m_colortab->Color() ); + + if( m_part && m_part->document().selection()->objects().count() > 0 ) + m_part->addCommand( new VStrokeCmd( &m_part->document(), &m_stroke ), true ); + + emit strokeChanged( VStroke( m_stroke ) ); +} + +void VStrokeDlg::slotUpdateDialog() +{ + switch( m_stroke.type() ) + { + case VStroke::solid: + m_typeOption->setButton( 1 ); break; + case VStroke::grad: + m_typeOption->setButton( 2 ); break; + default: + m_typeOption->setButton( 0 ); + } + + switch( m_stroke.lineCap() ) + { + case VStroke::capRound: + m_capOption->setButton( 1 ); break; + case VStroke::capSquare: + m_capOption->setButton( 2 ); break; + default: + m_capOption->setButton( 0 ); + } + + switch( m_stroke.lineJoin() ) + { + case VStroke::joinRound: + m_joinOption->setButton( 1 ); break; + case VStroke::joinBevel: + m_joinOption->setButton( 2 ); break; + default: + m_joinOption->setButton( 0 ); + } + + m_setLineWidth->setValue( m_stroke.lineWidth() ); +} + +#include "vstrokedlg.moc" + diff --git a/karbon/dialogs/vstrokedlg.h b/karbon/dialogs/vstrokedlg.h new file mode 100644 index 00000000..ddfa1b9f --- /dev/null +++ b/karbon/dialogs/vstrokedlg.h @@ -0,0 +1,66 @@ +/* This file is part of the KDE project + Copyright (C) 2001, The Karbon Developers + Copyright (C) 2002, The Karbon Developers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef __VSTROKEDLG_H__ +#define __VSTROKEDLG_H__ + +#include <kdialogbase.h> + +class QComboBox; +class QVButtonGroup; + +class KarbonPart; +class KoUnitDoubleSpinBox; +class VStroke; +class VColorTab; + +class VStrokeDlg : public KDialogBase +{ + Q_OBJECT + +public: + VStrokeDlg( KarbonPart* part, QWidget* parent = 0L, const char* name = 0L ); + +private: + VColorTab* m_colortab; + KarbonPart *m_part; + KoUnitDoubleSpinBox *m_setLineWidth; + QComboBox *m_styleCombo; + QVButtonGroup *m_typeOption; + QVButtonGroup *m_capOption; + QVButtonGroup *m_joinOption; + +protected: + VStroke m_stroke; + +signals: + void strokeChanged( const VStroke & ); + +private slots: + void slotTypeChanged( int ID ); + void slotCapChanged( int ID ); + void slotJoinChanged( int ID ); + void slotOKClicked(); + void slotUpdateDialog(); + +}; + +#endif + |