[Uml-devel] KDE/kdesdk/umbrello/umbrello

Ralf Habacker ralf.habacker at gmail.com
Fri Jun 15 20:23:20 UTC 2012


SVN commit 1300949 by habacker:

Moved general settings page into separate class.

 M  +1 -0      CMakeLists.txt  
 A             dialogs/generaloptionpage.cpp   [License: GPL (v2+)]
 A             dialogs/generaloptionpage.h   [License: GPL (v2+)]
 M  +4 -134    dialogs/settingsdlg.cpp  
 M  +4 -33     dialogs/settingsdlg.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/CMakeLists.txt #1300948:1300949
@@ -223,6 +223,7 @@
     dialogs/dialog_utils.cpp
     dialogs/dialogbase.cpp
     dialogs/exportallviewsdialog.cpp
+    dialogs/generaloptionpage.cpp
     dialogs/notedialog.cpp
     dialogs/objectnodedialog.cpp
     dialogs/overwritedialogue.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/settingsdlg.cpp #1300948:1300949
@@ -17,6 +17,7 @@
 #include "codegenoptionspage.h"
 #include "umlwidgetstylepage.h"
 #include "codevieweroptionspage.h"
+#include "generaloptionpage.h"
 #include "dialog_utils.h"
 #include "debug_utils.h"
 #include "icon_utils.h"
@@ -167,119 +168,9 @@
     pageGeneral->setHeader( i18n("General Settings") );
     pageGeneral->setIcon( Icon_Utils::DesktopIcon(Icon_Utils::it_Properties_General) );
     addPage( pageGeneral );
-
-    // Set up undo setting
-    m_GeneralWidgets.miscGB = new QGroupBox( i18nc("miscellaneous group box", "Miscellaneous"), page );
-
-    QGridLayout * miscLayout = new QGridLayout( m_GeneralWidgets.miscGB );
-    miscLayout->setSpacing( spacingHint() );
-    miscLayout->setMargin( fontMetrics().height() );
-
-    m_GeneralWidgets.undoCB = new QCheckBox( i18n("Enable undo"), m_GeneralWidgets.miscGB );
-    m_GeneralWidgets.undoCB->setChecked( m_pOptionState->generalState.undo );
-    miscLayout->addWidget( m_GeneralWidgets.undoCB, 0, 0 );
-
-    m_GeneralWidgets.tabdiagramsCB = new QCheckBox( i18n("Use tabbed diagrams"), m_GeneralWidgets.miscGB );
-    m_GeneralWidgets.tabdiagramsCB->setChecked( m_pOptionState->generalState.tabdiagrams );
-    miscLayout->addWidget( m_GeneralWidgets.tabdiagramsCB, 0, 1 );
-
-    m_GeneralWidgets.newcodegenCB = new QCheckBox( i18n("Use new C++/Java/Ruby generators"), m_GeneralWidgets.miscGB );
-    m_GeneralWidgets.newcodegenCB->setChecked( m_pOptionState->generalState.newcodegen );
-    miscLayout->addWidget( m_GeneralWidgets.newcodegenCB, 1, 0 );
-
-    m_GeneralWidgets.angularLinesCB = new QCheckBox( i18n("Use angular association lines"), m_GeneralWidgets.miscGB );
-    m_GeneralWidgets.angularLinesCB->setChecked( m_pOptionState->generalState.angularlines );
-    miscLayout->addWidget( m_GeneralWidgets.angularLinesCB, 1, 1 );
-
-    m_GeneralWidgets.footerPrintingCB = new QCheckBox( i18n("Turn on footer and page numbers when printing"), m_GeneralWidgets.miscGB );
-    m_GeneralWidgets.footerPrintingCB->setChecked( m_pOptionState->generalState.footerPrinting );
-    miscLayout->addWidget( m_GeneralWidgets.footerPrintingCB, 2, 0 );
-
-    //setup autosave settings
-    m_GeneralWidgets.autosaveGB = new QGroupBox( i18n("Autosave"), page );
-
-    QGridLayout * autosaveLayout = new QGridLayout( m_GeneralWidgets.autosaveGB );
-    autosaveLayout->setSpacing( spacingHint() );
-    autosaveLayout->setMargin( fontMetrics().height() );
-
-    m_GeneralWidgets.autosaveCB = new QCheckBox( i18n("E&nable autosave"), m_GeneralWidgets.autosaveGB );
-    m_GeneralWidgets.autosaveCB->setChecked( m_pOptionState->generalState.autosave );
-    autosaveLayout->addWidget( m_GeneralWidgets.autosaveCB, 0, 0 );
-
-    m_GeneralWidgets.autosaveL = new QLabel( i18n("Select auto-save time interval (mins):"), m_GeneralWidgets.autosaveGB );
-    autosaveLayout->addWidget( m_GeneralWidgets.autosaveL, 1, 0 );
-
-    m_GeneralWidgets.timeISB = new KIntSpinBox( 1, 600, 1, m_pOptionState->generalState.autosavetime, m_GeneralWidgets.autosaveGB );
-    m_GeneralWidgets.timeISB->setEnabled( m_pOptionState->generalState.autosave );
-    autosaveLayout->addWidget( m_GeneralWidgets.timeISB, 1, 1 );
-
-    // Allow definition of Suffix for autosave ( default: ".xmi" )
-    Dialog_Utils::makeLabeledEditField( m_GeneralWidgets.autosaveGB, autosaveLayout, 2,
-                                    m_GeneralWidgets.autosaveSuffixL, i18n("Set autosave suffix:"),
-                                    m_GeneralWidgets.autosaveSuffixT, m_pOptionState->generalState.autosavesuffix );
-    QString autoSaveSuffixToolTip = i18n( "<qt><p>The autosave file will be saved to ~/autosave.xmi if the autosaving occurs "
-                                          "before you have manually saved the file.</p>"
-                                          "<p>If you have already saved it, the autosave file will be saved in the same folder as the file "
-                                          "and will be named like the file's name, followed by the suffix specified.</p>"
-                                          "<p>If the suffix is equal to the suffix of the file you have saved, "
-                                          "the autosave will overwrite your file automatically.</p></qt>" );
-    m_GeneralWidgets.autosaveSuffixL->setToolTip( autoSaveSuffixToolTip );
-    m_GeneralWidgets.autosaveSuffixT->setToolTip( autoSaveSuffixToolTip );
-
-    //setup startup settings
-    m_GeneralWidgets.startupGB = new QGroupBox( i18n("Startup"), page );
-
-    QGridLayout * startupLayout = new QGridLayout( m_GeneralWidgets.startupGB );
-    startupLayout->setSpacing( spacingHint() );
-    startupLayout->setMargin( fontMetrics().height() );
-
-    m_GeneralWidgets.loadlastCB = new QCheckBox( i18n("&Load last project"), m_GeneralWidgets.startupGB );
-    m_GeneralWidgets.loadlastCB->setChecked( m_pOptionState->generalState.loadlast );
-    startupLayout->addWidget( m_GeneralWidgets.loadlastCB, 0, 0 );
-
-    m_GeneralWidgets.startL = new QLabel( i18n("Start new project with:"), m_GeneralWidgets.startupGB );
-    startupLayout->addWidget( m_GeneralWidgets.startL, 1, 0 );
-
-    m_GeneralWidgets.diagramKB = new KComboBox( m_GeneralWidgets.startupGB );
-    m_GeneralWidgets.diagramKB->setCompletionMode( KGlobalSettings::CompletionPopup );
-    startupLayout->addWidget( m_GeneralWidgets.diagramKB, 1, 1 );
-
-    // start at 1 because we don't allow No Diagram any more
-    // diagramNo 1 is Uml::DiagramType::Class
-    // digaramNo 9 is Uml::DiagramType::EntityRelationship
-    for (int diagramNo = 1; diagramNo < 10; ++diagramNo) {
-        Uml::DiagramType dt = Uml::DiagramType(Uml::DiagramType::Value(diagramNo));
-        insertDiagram( dt.toString(), diagramNo - 1  );
+    m_pGeneralPage = new GeneralOptionPage(page);
     }
 
-    m_GeneralWidgets.diagramKB->setCurrentIndex( (int)m_pOptionState->generalState.diagram-1 );
-    connect( m_GeneralWidgets.autosaveCB, SIGNAL(clicked()), this, SLOT(slotAutosaveCBClicked()) );
-
-    m_GeneralWidgets.defaultLanguageL = new QLabel( i18n( "Default Language :" ), m_GeneralWidgets.startupGB );
-    startupLayout->addWidget( m_GeneralWidgets.defaultLanguageL, 2, 0 );
-
-    m_GeneralWidgets.languageKB = new KComboBox( m_GeneralWidgets.startupGB );
-    m_GeneralWidgets.languageKB->setCompletionMode( KGlobalSettings::CompletionPopup );
-    startupLayout->addWidget( m_GeneralWidgets.languageKB, 2, 1 );
-
-    int indexCounter = 0;
-    while (indexCounter < Uml::ProgrammingLanguage::Reserved) {
-        QString language = Uml::ProgrammingLanguage::toString(Uml::ProgrammingLanguage::Value(indexCounter));
-        m_GeneralWidgets.languageKB->insertItem(indexCounter, language);
-        indexCounter++;
-    }
-    m_GeneralWidgets.languageKB->setCurrentIndex(m_pOptionState->generalState.defaultLanguage);
-}
-
-/**
- * Inserts @p type into the type-combobox as well as its completion object.
- */
-void SettingsDlg::insertDiagram( const QString& type, int index )
-{
-    m_GeneralWidgets.diagramKB->insertItem( index, type );
-    m_GeneralWidgets.diagramKB->completionObject()->addItem( type );
-}
-
 void SettingsDlg::setupClassPage()
 {
     //setup class settings page
@@ -456,12 +347,7 @@
     KPageWidgetItem *current = currentPage();
     if ( current ==  pageGeneral )
     {
-        m_GeneralWidgets.autosaveCB->setChecked( false );
-        m_GeneralWidgets.timeISB->setValue( 5 );
-        m_GeneralWidgets.timeISB->setEnabled( true );
-        m_GeneralWidgets.loadlastCB->setChecked( true );
-        m_GeneralWidgets.diagramKB->setCurrentIndex( 0 );
-        m_GeneralWidgets.languageKB->setCurrentIndex( Uml::ProgrammingLanguage::Cpp );
+        m_pGeneralPage->setDefaults();
     }
     else if ( current == pageFont )
     {
@@ -508,18 +394,7 @@
     m_bChangesApplied = true;
     if ( item == pageGeneral )
     {
-        m_pOptionState->generalState.undo = m_GeneralWidgets.undoCB->isChecked();
-        m_pOptionState->generalState.tabdiagrams = m_GeneralWidgets.tabdiagramsCB->isChecked();
-        m_pOptionState->generalState.newcodegen = m_GeneralWidgets.newcodegenCB->isChecked();
-        m_pOptionState->generalState.angularlines = m_GeneralWidgets.angularLinesCB->isChecked();
-        m_pOptionState->generalState.footerPrinting = m_GeneralWidgets.footerPrintingCB->isChecked();
-        m_pOptionState->generalState.autosave = m_GeneralWidgets.autosaveCB->isChecked();
-        m_pOptionState->generalState.autosavetime = m_GeneralWidgets.timeISB->value();
-        // retrieve Suffix setting from dialog entry
-        m_pOptionState->generalState.autosavesuffix = m_GeneralWidgets.autosaveSuffixT->text();
-        m_pOptionState->generalState.loadlast = m_GeneralWidgets.loadlastCB->isChecked();
-        m_pOptionState->generalState.diagram  = Uml::DiagramType::Value(m_GeneralWidgets.diagramKB->currentIndex() + 1);
-        m_pOptionState->generalState.defaultLanguage = Uml::ProgrammingLanguage::Value( m_GeneralWidgets.languageKB->currentIndex());
+        m_pGeneralPage->apply();
     }
     else if ( item == pageFont )
     {
@@ -624,11 +499,6 @@
     }
 }
 
-void SettingsDlg::slotAutosaveCBClicked()
-{
-    m_GeneralWidgets.timeISB->setEnabled( m_GeneralWidgets.autosaveCB->isChecked() );
-}
-
 QString SettingsDlg::getCodeGenerationLanguage()
 {
     return m_pCodeGenPage->getLanguage();
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/settingsdlg.h #1300948:1300949
@@ -33,6 +33,7 @@
 class CodeImportOptionsPage;
 class CodeGenOptionsPage;
 class CodeViewerOptionsPage;
+class GeneralOptionPage;
 
 /**
  * @author Paul Hensgen
@@ -55,7 +56,6 @@
     QString getCodeGenerationLanguage();
 
 protected:
-    void insertDiagram( const QString& type, int index = -1 );
     void insertAttribScope( const QString& type, int index = -1 );
     void insertOperationScope( const QString& type, int index = -1 );
 
@@ -82,35 +82,6 @@
     }
     ;//end struct UIWidgets
 
-    struct GeneralWidgets {
-        QGroupBox * miscGB;
-        QGroupBox * autosaveGB;
-        QGroupBox * startupGB;
-
-        KIntSpinBox * timeISB;
-        KComboBox * diagramKB;
-        KComboBox * languageKB;
-
-        QCheckBox * undoCB;
-        QCheckBox * tabdiagramsCB;
-        QCheckBox * newcodegenCB;
-        QCheckBox * angularLinesCB;
-        QCheckBox * footerPrintingCB;
-        QCheckBox * autosaveCB;
-        QCheckBox * loadlastCB;
-
-        // Allow definition of Suffix for autosave
-        // ( Default: ".xmi" )
-        KLineEdit * autosaveSuffixT;
-        QLabel    * autosaveSuffixL;
-        // End AutoSave Suffix
-
-        QLabel * startL;
-        QLabel * autosaveL;
-        QLabel * defaultLanguageL;
-    }
-    ;//end struct GeneralWidgets
-
     struct ClassWidgets {
         QGroupBox * visibilityGB;
         QGroupBox * scopeGB;
@@ -151,7 +122,6 @@
 
     //private attributes
     FontWidgets m_FontWidgets;
-    GeneralWidgets m_GeneralWidgets;
     UIWidgets m_UiWidgets;
     ClassWidgets m_ClassWidgets;
     Settings::OptionState *m_pOptionState;
@@ -160,9 +130,11 @@
     CodeImportOptionsPage * m_pCodeImportPage;
     CodeGenOptionsPage * m_pCodeGenPage;
     CodeViewerOptionsPage * m_pCodeViewerPage;
+    GeneralOptionPage * m_pGeneralPage;
 
     bool m_bChangesApplied;
-    KPageWidgetItem *pageCodeViewer, *pageFont, *pageCodeImport, *pageCodeGen, *pageUserInterface, *pageGeneral, *pageClass, *pageAutoLayout;
+    KPageWidgetItem *pageCodeViewer, *pageFont, *pageCodeImport, *pageCodeGen,
+                    *pageUserInterface, *pageClass, *pageAutoLayout, *pageGeneral;
 
 private slots:
     void slotApply();
@@ -173,7 +145,6 @@
     void slotFillCBChecked(bool value);
     void slotGridCBChecked(bool value);
     void slotBgCBChecked(bool value);
-    void slotAutosaveCBClicked();
 };
 
 #endif




More information about the umbrello-devel mailing list