diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /kicker/proxy/extensiondebugger.cpp | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kicker/proxy/extensiondebugger.cpp')
-rw-r--r-- | kicker/proxy/extensiondebugger.cpp | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/kicker/proxy/extensiondebugger.cpp b/kicker/proxy/extensiondebugger.cpp new file mode 100644 index 000000000..f7c3309c4 --- /dev/null +++ b/kicker/proxy/extensiondebugger.cpp @@ -0,0 +1,160 @@ +/***************************************************************** + +Copyright (c) 2000 Matthias Elter <[email protected]> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTDHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#include <qfile.h> +#include <qlayout.h> +#include <qpushbutton.h> + +#include <kapplication.h> +#include <kglobal.h> +#include <klibloader.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kcmdlineargs.h> +#include <kdebug.h> +#include <kpanelextension.h> +#include <kaboutdata.h> +#include <qfileinfo.h> + +#include "appletinfo.h" +#include "extensiondebugger.h" +#include "extensiondebugger.moc" + + + +static KCmdLineOptions options[] = +{ + { "+desktopfile", I18N_NOOP("The extensions desktop file"), 0 }, + KCmdLineLastOption +}; + +KPanelExtension* loadExtension(const AppletInfo& info) +{ + KLibLoader* loader = KLibLoader::self(); + KLibrary* lib = loader->library(QFile::encodeName(info.library())); + + if (!lib) + { + kdWarning() << "cannot open extension: " << info.library() + << " because of " << loader->lastErrorMessage() << endl; + return 0; + } + + KPanelExtension* (*init_ptr)(QWidget *, const QString&); + init_ptr = (KPanelExtension* (*)(QWidget *, const QString&))lib->symbol( "init" ); + + if (!init_ptr) + { + kdWarning() << info.library() << " is not a kicker extension!" << endl; + return 0; + } + + return init_ptr(0, info.configFile()); +} + +int main( int argc, char ** argv ) +{ + KAboutData aboutData( "extensionproxy", I18N_NOOP("Panel extension proxy.") + , "v0.1.0" + ,I18N_NOOP("Panel extension proxy.") + , KAboutData::License_BSD + , "(c) 2000, The KDE Developers"); + KCmdLineArgs::init(argc, argv, &aboutData ); + aboutData.addAuthor("Matthias Elter",0, "[email protected]"); + aboutData.addAuthor("Matthias Ettrich",0, "[email protected]"); + KApplication::addCmdLineOptions(); + KCmdLineArgs::addCmdLineOptions(options); // Add our own options. + + KApplication a; + a.disableSessionManagement(); + + KGlobal::dirs()->addResourceType("extensions", KStandardDirs::kde_default("data") + + "kicker/extensions"); + + QString df; + + // parse cmdline args + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + // sanity check + if ( args->count() == 0 ) + KCmdLineArgs::usage(i18n("No desktop file specified") ); + + + QCString desktopFile = QCString( args->arg(0) ); + + // try simple path first + QFileInfo finfo( desktopFile ); + if ( finfo.exists() ) { + df = finfo.absFilePath(); + } else { + // locate desktop file + df = KGlobal::dirs()->findResource("extensions", QString(desktopFile)); + } + + // does the config file exist? + if (!QFile::exists(df)) { + kdError() << "Failed to locate extension desktop file: " << desktopFile << endl; + return 1; + } + + AppletInfo info( df ); + + KPanelExtension *extension = loadExtension(info); + if ( !extension ) { + kdError() << "Failed to load extension: " << info.library() << endl; + return 1; + } + + ExtensionContainer *container = new ExtensionContainer( extension ); + container->show(); + + QObject::connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); + + int result = a.exec(); + + delete extension; + return result; +} + +ExtensionContainer::ExtensionContainer( KPanelExtension *extension, QWidget *parent, const char *name ) + : QWidget( parent, name ), m_extension( extension ) +{ + ( new QVBoxLayout( this ) )->setAutoAdd( true ); + + QPushButton *configButton = new QPushButton( i18n( "Configure..." ), this ); + connect( configButton, SIGNAL( clicked() ), + this, SLOT( showPreferences() ) ); + + m_extension->reparent( this, QPoint( 0, 0 ) ); +} + +void ExtensionContainer::resizeEvent( QResizeEvent * ) +{ + m_extension->setGeometry( 0, 0, width(), height() ); +} + +void ExtensionContainer::showPreferences() +{ + m_extension->action( KPanelExtension::Preferences ); +} |