[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/kcontrol4/src
From:       Ben Cooksley <sourtooth () gmail ! com>
Date:       2009-02-28 22:52:51
Message-ID: 1235861571.474919.32670.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 933445 by bcooksley:

Change the application to not destroy the plugins main widget upon changing plugin. \
Move connect call into Plugin loading area to avoid multiple connects in changed \
environment

 M  +7 -5      app/SettingsBase.cpp  
 M  +2 -0      app/SettingsBase.h  
 M  +17 -15    classic/ClassicMode.cpp  
 M  +18 -17    icons/IconMode.cpp  


--- trunk/playground/base/kcontrol4/src/app/SettingsBase.cpp #933444:933445
@@ -48,6 +48,9 @@
     initMenuList(rootModule);
     initAbout();
     initSearch();
+    // Prepare the view area
+    stackedWidget = new QStackedWidget( this );
+    setCentralWidget(stackedWidget);
     // Load all possible views
     pluginObjects = KServiceTypeTrader::self()->query( "BaseMode" );
     for( int pluginsDone = 0; pluginsDone < pluginObjects.count(); pluginsDone = \
pluginsDone + 1 ) { @@ -57,8 +60,10 @@
         if( error.isEmpty() ) {
             possibleViews.insert( activeService->library(), controller );
             controller->init( rootModule, activeService, KGlobal::config()->group( \
activeService->name() ) ); +            \
                stackedWidget->addWidget(controller->mainWidget());
             connect(controller, SIGNAL(dirtyStateChanged(bool)), this, \
                SLOT(toggleDirtyState(bool))); 
             connect(controller, SIGNAL(actionsChanged()), this, \
SLOT(updateViewActions())); +            connect(controller->moduleView(), \
                SIGNAL(moduleChanged()), this, SLOT(moduleChanged()));
             connect(searchText, SIGNAL(textChanged(const QString&)), controller, \
SLOT(searchChanged(const QString&)));  } else { 
             kWarning() << "View load error: " + error;
@@ -195,6 +200,7 @@
     if( activeView ) {
         activeView->saveState();
     }
+
     QString viewToUse = mainConfigGroup.readEntry( "ActiveView", "icon_mode" );
     if( possibleViews.keys().contains(viewToUse) ) { // First the configuration \
entry  activeView = possibleViews.value(viewToUse);
@@ -203,11 +209,7 @@
         activeView = possibleViews.values().first();
     }
 
-    setCentralWidget(activeView->mainWidget()); // Now we set it as the main widget
-
-    if ( activeView->moduleView() ) {     
-        connect(activeView->moduleView(), SIGNAL(moduleChanged()), this, \
                SLOT(moduleChanged()));
-    }
+    stackedWidget->setCurrentWidget(activeView->mainWidget());
 }
 
 void SettingsBase::toggleDirtyState(bool state)
--- trunk/playground/base/kcontrol4/src/app/SettingsBase.h #933444:933445
@@ -24,6 +24,7 @@
 #include "ui_configDialog.h"
 
 #include <QMap>
+#include <QStackedWidget>
 
 #include <KXmlGuiWindow>
 #include <KService>
@@ -82,6 +83,7 @@
     KConfigGroup mainConfigGroup;
     // The control module
     KToolBar * viewToolbar;
+    QStackedWidget * stackedWidget;
     // The module list
     MenuItem * rootModule;
     KService::List categories;
--- trunk/playground/base/kcontrol4/src/classic/ClassicMode.cpp #933444:933445
@@ -60,27 +60,14 @@
         createMenu( child, treeItem );
     }
 
-    // Create the widget
+    // Create the model
     proxyModel = new MenuProxyModel( this );
     proxyModel->setSourceModel( new MenuModel( treeItem, this ) );
     proxyModel->setFilterRole( MenuModel::UserFilterRole );
     proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
     proxyModel->sort( 0 );
-}
 
-void ClassicMode::createMenu( MenuItem * copyFrom, MenuItem * copyTo )
-{
-    copyTo->name = copyFrom->name;
-    copyTo->service = copyFrom->service;
-    copyTo->item = copyFrom->item;
-    foreach( MenuItem * copyChild, copyFrom->children ) {
-        MenuItem * newChild = new MenuItem( copyChild->menu, copyTo );
-        createMenu( copyChild, newChild );
-    }
-}
-
-QWidget * ClassicMode::mainWidget()
-{
+    // Create the widget
     classicWidget = new QSplitter( Qt::Horizontal, 0 );
     classicTree = new QTreeView( classicWidget );
     classicCategory = new CategoryList( classicWidget, proxyModel );
@@ -113,6 +100,21 @@
     QList<int> defaultSizes;
     defaultSizes << 250 << 500;
     classicWidget->setSizes( config.readEntry( "viewLayout", defaultSizes ) );
+}
+
+void ClassicMode::createMenu( MenuItem * copyFrom, MenuItem * copyTo )
+{
+    copyTo->name = copyFrom->name;
+    copyTo->service = copyFrom->service;
+    copyTo->item = copyFrom->item;
+    foreach( MenuItem * copyChild, copyFrom->children ) {
+        MenuItem * newChild = new MenuItem( copyChild->menu, copyTo );
+        createMenu( copyChild, newChild );
+    }
+}
+
+QWidget * ClassicMode::mainWidget()
+{
     return classicWidget;
 }
 
--- trunk/playground/base/kcontrol4/src/icons/IconMode.cpp #933444:933445
@@ -49,6 +49,24 @@
 
 QWidget * IconMode::mainWidget()
 { 
+    return iconWidget;
+}
+
+void IconMode::initEvent()
+{
+    foreach( MenuItem * childItem, rootItem->children ) {
+        IconModel * model = new IconModel( childItem, this );
+        MenuProxyModel * proxyModel = new MenuProxyModel( this );
+        proxyModel->setCategorizedModel( true );
+        proxyModel->setSourceModel( model );
+        proxyModel->setFilterRole( MenuModel::UserFilterRole );
+        proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
+        proxyModel->sort( 0 );
+        proxyList.append(proxyModel);
+        proxyMap.insert(proxyModel, childItem->service->name());
+    }
+
+    // Create the widget
     iconWidget = new KTabWidget();
 #if QT_VERSION >= 0x040500
     iconWidget->setDocumentMode(true);
@@ -67,25 +85,8 @@
         tv->setModel( proxyModel );
         iconWidget->addTab(tv, proxyMap.value(proxyModel) );
     }
-
-    return iconWidget;
 }
 
-void IconMode::initEvent()
-{
-    foreach( MenuItem * childItem, rootItem->children ) {
-        IconModel * model = new IconModel( childItem, this );
-        MenuProxyModel * proxyModel = new MenuProxyModel( this );
-        proxyModel->setCategorizedModel( true );
-        proxyModel->setSourceModel( model );
-        proxyModel->setFilterRole( MenuModel::UserFilterRole );
-        proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
-        proxyModel->sort( 0 );
-        proxyList.append(proxyModel);
-        proxyMap.insert(proxyModel, childItem->service->name());
-    }
-}
-
 void IconMode::searchChanged(const QString text)
 {
     foreach( MenuProxyModel * proxyModel, proxyList ) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic