[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/systemsettings
From: Ben Cooksley <sourtooth () gmail ! com>
Date: 2009-07-19 10:34:02
Message-ID: 1247999642.280095.32450.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 999143 by bcooksley:
Add initial support for integrating external applications in system settings
M +4 -3 app/SettingsBase.cpp
M +0 -3 app/SettingsBase.h
M +3 -1 core/CMakeLists.txt
M +41 -26 core/ModuleView.cpp
M +1 -0 core/ModuleView.h
A core/externalModule.ui
A core/systemsettingsexternalapp.desktop
--- trunk/KDE/kdebase/workspace/systemsettings/app/SettingsBase.cpp #999142:999143
@@ -39,9 +39,7 @@
#include "ModuleView.h"
SettingsBase::SettingsBase( QWidget * parent ) :
- KXmlGuiWindow(parent),
- categories( KServiceTypeTrader::self()->query("SystemSettingsCategory") ),
- modules( KServiceTypeTrader::self()->query("KCModule") )
+ KXmlGuiWindow(parent)
{
// Ensure delayed loading doesn't cause a crash
activeView = 0;
@@ -79,6 +77,9 @@
void SettingsBase::initApplication()
{
// Prepare the menu of all modules
+ categories = KServiceTypeTrader::self()->query("SystemSettingsCategory");
+ modules = KServiceTypeTrader::self()->query("KCModule");
+ modules += KServiceTypeTrader::self()->query("SystemSettingsExternalApp");
rootModule = new MenuItem( true, 0 );
initMenuList(rootModule);
// Prepare the Base Data
--- trunk/KDE/kdebase/workspace/systemsettings/app/SettingsBase.h #999142:999143
@@ -47,9 +47,6 @@
protected:
virtual QSize sizeHint() const;
-private:
- MenuItem * initModuleLists(MenuItem * parent);
-
private slots:
void initApplication();
void initToolBar();
--- trunk/KDE/kdebase/workspace/systemsettings/core/CMakeLists.txt #999142:999143
@@ -19,6 +19,8 @@
ToolTipManager.cpp
)
+KDE4_ADD_UI_FILES( systemsettingsview_LIB_SRCS externalModule.ui )
+
set(systemsettingsview_LIB_HDRS
systemsettingsview_export.h
MenuItem.h
@@ -36,4 +38,4 @@
install( TARGETS systemsettingsview ${INSTALL_TARGETS_DEFAULT_ARGS} )
install( FILES ${systemsettingsview_LIB_HDRS} DESTINATION \
${INCLUDE_INSTALL_DIR}/systemsettingsview COMPONENT Devel )
-INSTALL( FILES systemsettingsview.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
+INSTALL( FILES systemsettingsview.desktop systemsettingsexternalapp.desktop \
DESTINATION ${SERVICETYPES_INSTALL_DIR} )
--- trunk/KDE/kdebase/workspace/systemsettings/core/ModuleView.cpp #999142:999143
@@ -19,6 +19,7 @@
*****************************************************************************/
#include "ModuleView.h"
+#include "ui_externalModule.h"
#include <QMap>
#include <QList>
@@ -46,7 +47,8 @@
public:
Private() { }
QMap<KPageWidgetItem*, KCModuleProxy*> mPages;
- QMap<KCModuleProxy*, KCModuleInfo*> mModules;
+ QMap<KPageWidgetItem*, KCModuleInfo*> mModules;
+ Ui::ExternalModule externalModule;
KPageWidget* mPageWidget;
QVBoxLayout* mLayout;
KDialogButtonBox* mButtons;
@@ -96,12 +98,7 @@
KCModuleInfo * ModuleView::activeModule() const
{
- KCModuleProxy * activeModule = d->mPages.value( d->mPageWidget->currentPage() );
- if( activeModule ) {
- return d->mModules.value(activeModule);
- } else {
- return 0;
- }
+ return d->mModules.value( d->mPageWidget->currentPage() );
}
const KAboutData * ModuleView::aboutData() const
@@ -156,27 +153,37 @@
return;
}
- // Create the items
+ // Create the scroller
QScrollArea * moduleScroll = new QScrollArea( this );
- KCModuleProxy * moduleProxy = new KCModuleProxy( *module, moduleScroll );
- // Prepare the module
- moduleProxy->setAutoFillBackground( false );
// Prepare the scroll area
moduleScroll->setWidgetResizable( true );
moduleScroll->setFrameStyle( QFrame::NoFrame );
moduleScroll->viewport()->setAutoFillBackground( false );
- moduleScroll->setWidget( moduleProxy );
// Create the page
KPageWidgetItem *page = new KPageWidgetItem( moduleScroll, module->moduleName() \
); +
+ if( module->service()->hasServiceType("SystemSettingsExternalApp") ) { // Is it \
an external app? + QProcess::startDetached( module->service()->exec() ); // \
Launch it! + QWidget * externalWidget = new QWidget( this );
+ d->externalModule.setupUi( externalWidget );
+ d->externalModule.LblText->setText( i18n("%1 is an external application and \
has been automatically launched", module->moduleName() ) ); + \
d->externalModule.PbRelaunch->setText( i18n("Relaunch %1", module->moduleName()) ); + \
connect( d->externalModule.PbRelaunch, SIGNAL(clicked()), this, SLOT(runExternal()) \
); + moduleScroll->setWidget( externalWidget );
+ } else { // It must be a normal module then
+ KCModuleProxy * moduleProxy = new KCModuleProxy( *module, moduleScroll );
+ moduleScroll->setWidget( moduleProxy );
+ moduleProxy->setAutoFillBackground( false );
+ connect( moduleProxy, SIGNAL(changed(bool)), this, SLOT(stateChanged()));
+ d->mPages.insert( page, moduleProxy );
+ }
+
// Provide information to the users
page->setIcon( KIcon( module->service()->icon() ) );
page->setHeader( module->service()->comment() );
- // Allow it to signal properly
- connect( moduleProxy, SIGNAL(changed(bool)), this, SLOT(stateChanged()));
- // Set it to be shown and signal that
+ d->mModules.insert( page, module );
+ // Add the new page
d->mPageWidget->addPage( page );
- d->mPages.insert( page, moduleProxy );
- d->mModules.insert( moduleProxy, module );
}
bool ModuleView::resolveChanges()
@@ -222,16 +229,19 @@
void ModuleView::closeModules()
{
blockSignals(true);
- QMap<KPageWidgetItem*, KCModuleProxy*>::iterator pageIterator;
- QMap<KPageWidgetItem*, KCModuleProxy*>::iterator endIterator = d->mPages.end();
+ QMap<KPageWidgetItem*, KCModuleProxy*>::iterator module;
+ QMap<KPageWidgetItem*, KCModuleProxy*>::iterator moduleEnd = d->mPages.end();
// These two MUST be kept separate in order to ensure modules aren't loaded \
during the closing procedure
- for ( pageIterator = d->mPages.begin(); pageIterator != endIterator; \
++pageIterator ) {
- delete pageIterator.value();
- pageIterator.value() = 0;
+ for ( module = d->mPages.begin(); module != moduleEnd; ++module ) {
+ delete module.value();
+ module.value() = 0;
}
- for ( pageIterator = d->mPages.begin(); pageIterator != endIterator; \
++pageIterator ) {
- d->mPageWidget->removePage( pageIterator.key() );
+ QMap<KPageWidgetItem*, KCModuleInfo*>::iterator page = d->mModules.begin();
+ QMap<KPageWidgetItem*, KCModuleInfo*>::iterator pageEnd = d->mModules.end();
+ for ( page = d->mModules.begin(); page != pageEnd; ++page ) {
+ d->mPageWidget->removePage( page.key() );
}
+
d->mPages.clear();
d->mModules.clear();
blockSignals(false);
@@ -263,12 +273,12 @@
void ModuleView::moduleHelp()
{
- KCModuleProxy * activeModule = d->mPages.value( d->mPageWidget->currentPage() );
+ KCModuleInfo * activeModule = d->mModules.value( d->mPageWidget->currentPage() \
); if( !activeModule ) {
return;
}
- QString docPath = activeModule->moduleInfo().docPath();
+ QString docPath = activeModule->docPath();
if( docPath.isEmpty() ) {
return;
}
@@ -336,4 +346,9 @@
d->mDefault->setEnabled(buttons & KCModule::Default );
}
+void ModuleView::runExternal()
+{
+ QProcess::startDetached( activeModule()->service()->exec() ); // Launch it!
+}
+
#include "ModuleView.moc"
--- trunk/KDE/kdebase/workspace/systemsettings/core/ModuleView.h #999142:999143
@@ -132,6 +132,7 @@
void activeModuleChanged( KPageWidgetItem* current, KPageWidgetItem* previous);
void updateButtons();
void stateChanged();
+ void runExternal();
Q_SIGNALS:
/**
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic