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

Sharan Rao sharanrao at gmail.com
Mon Jun 25 06:17:29 UTC 2007


SVN commit 679878 by sharan:

Now one can set the default language that  has to be used during startup



 M  +20 -0     dialogs/settingsdlg.cpp  
 M  +2 -0      dialogs/settingsdlg.h  
 M  +1 -0      optionstate.h  
 M  +8 -8      uml.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/settingsdlg.cpp #679877:679878
@@ -29,6 +29,7 @@
 #include "codegenerationoptionspage.h"
 #include "codevieweroptionspage.h"
 #include "../dialog_utils.h"
+#include  "../model_utils.h"
 
 SettingsDlg::SettingsDlg( QWidget * parent, Settings::OptionState *state )
         : KPageDialog( parent) {
@@ -212,6 +213,22 @@
 
     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::pl_Reserved) {
+        QString language = Model_Utils::progLangToString((Uml::Programming_Language) indexCounter);
+        m_GeneralWidgets.languageKB->insertItem(language, indexCounter);
+        indexCounter++;
+    }
+    m_GeneralWidgets.languageKB->setCurrentIndex(Model_Utils::stringToProgLang(m_pOptionState->generalState.defaultLanguage));
+
 }
 
 /**
@@ -375,6 +392,7 @@
         m_GeneralWidgets.timeISB->setEnabled( true );
         m_GeneralWidgets.loadlastCB -> setChecked( true );
         m_GeneralWidgets.diagramKB -> setCurrentIndex( 0 );
+        m_GeneralWidgets.languageKB->setCurrentIndex( ( int )Model_Utils::stringToProgLang( "C++" ) );
     }
     else if ( current == pageFont )
     {
@@ -419,6 +437,8 @@
         m_pOptionState->generalState.autosavesuffix = m_GeneralWidgets.autosaveSuffixT -> text();
 	m_pOptionState->generalState.loadlast = m_GeneralWidgets.loadlastCB -> isChecked();
         m_pOptionState->generalState.diagram  = (Uml::Diagram_Type)(m_GeneralWidgets.diagramKB->currentItem() + 1);
+        m_pOptionState->generalState.defaultLanguage = Model_Utils::progLangToString( ( Uml::Programming_Language )( m_GeneralWidgets.languageKB->currentItem() ) );
+
     }
     else if ( item == pageFont )
     {
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/settingsdlg.h #679877:679878
@@ -97,6 +97,7 @@
 
         KIntSpinBox * timeISB;
         KComboBox * diagramKB;
+        KComboBox * languageKB;
 
         QCheckBox * undoCB;
         QCheckBox * tabdiagramsCB;
@@ -114,6 +115,7 @@
 
         QLabel * startL;
         QLabel *  autosaveL;
+        QLabel * defaultLanguageL;
     }
     ;//end struct GeneralWidgets
 
--- trunk/KDE/kdesdk/umbrello/umbrello/optionstate.h #679877:679878
@@ -41,6 +41,7 @@
     QString autosavesuffix;  ///< Text input field for suffix of autosave
     bool loadlast;
     Uml::Diagram_Type diagram;
+    QString defaultLanguage;
     QString lastFile;
 };
 
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #679877:679878
@@ -637,6 +637,8 @@
     cg.writeEntry( "loadlast", optionState.generalState.loadlast );
 
     cg.writeEntry( "diagram", (int)optionState.generalState.diagram );
+    cg.writeEntry( "defaultLanguage", optionState.generalState.defaultLanguage );
+
     if( m_doc->url().fileName() == i18n( "Untitled" ) ) {
         cg.writeEntry( "lastFile", "" );
     } else {
@@ -685,11 +687,7 @@
     // now write the basic defaults to the m_config file
     m_commoncodegenpolicy->writeConfig(m_config.data());
 
-    // next, we record the activeLanguage in the Code Generation Group
-    if (m_codegen) {
-        cg.changeGroup("Code Generation");
-        cg.writeEntry("activeLanguage", Model_Utils::progLangToString(m_codegen->getLanguage()));
-    }
+    cg.sync();
 }
 
 void UMLApp::readOptions() {
@@ -1118,6 +1116,7 @@
     m_dlg = new SettingsDlg(this, &optionState);
     connect(m_dlg, SIGNAL( applyClicked() ), this, SLOT( slotApplyPrefs() ) );
 
+
     if ( m_dlg->exec() == QDialog::Accepted && m_dlg->getChangesApplied() ) {
         slotApplyPrefs();
     }
@@ -1239,6 +1238,7 @@
 
     optionState.generalState.diagram  = (Uml::Diagram_Type) generalGroup.readEntry("diagram", 1);
 
+    optionState.generalState.defaultLanguage = generalGroup.readEntry( "defaultLanguage", "C++" );
 
     const KConfigGroup uiGroup( m_config, "UI Options" );
     optionState.uiState.useFillColor = uiGroup.readEntry( "useFillColor", true );
@@ -1663,9 +1663,9 @@
 }
 
 Uml::Programming_Language UMLApp::getDefaultLanguage() {
-    const KConfigGroup codeGenGroup( m_config, "Code Generation");
-    QString activeLanguage = codeGenGroup.readEntry("activeLanguage", "C++");
-    return Model_Utils::stringToProgLang(activeLanguage);
+    Settings::OptionState& optionState = Settings::getOptionState();
+    QString defaultLanguage = optionState.generalState.defaultLanguage;
+    return Model_Utils::stringToProgLang(defaultLanguage);
 }
 
 void UMLApp::initGenerator() {




More information about the umbrello-devel mailing list