Ejemplo n.º 1
0
void cPluginManager::findPlugins ()
{
  pluginInfo.clear ();
  KPluginInfo::List pi = KPluginInfo::fromServices (KServiceTypeTrader::self()->query (
      QString::fromLatin1("KMuddy/Plugin"),
      QString::fromLatin1("(Type == 'Service') and ([X-KMuddy-Version] == 2)")));
  
  // fill in the associative array with plugin info
  KPluginInfo::List::Iterator it;
  for (it = pi.begin(); it != pi.end(); ++it) {
    KPluginInfo info = *it;
    kDebug() << "Found plugin: " << info.name();
    pluginInfo[info.name()] = info;
  }
}
Ejemplo n.º 2
0
void BehaviorConfig_Shorten::slotAboutClicked()
{
    const QString shorten = shortenPlugins->itemData(shortenPlugins->currentIndex()).toString();
    if (shorten == QLatin1String("none")) {
        return;
    }
    KPluginInfo info = availablePlugins.value(shorten);

    KAboutData aboutData(info.name(), info.name(), info.version(), info.comment(),
                         KAboutLicense::byKeyword(info.license()).key(), QString(),
                         QString(), info.website());
    aboutData.addAuthor(info.author(), QString(), info.email());

    KAboutApplicationDialog aboutPlugin(aboutData, this);
    aboutPlugin.setWindowIcon(QIcon::fromTheme(info.icon()));
    aboutPlugin.exec();
}
Ejemplo n.º 3
0
bool KPluginInfo::operator>(const KPluginInfo &rhs) const
{
    if (category() > rhs.category()) {
        return true;
    }
    if (category() == rhs.category()) {
        return name() > rhs.name();
    }
    return false;
}
Ejemplo n.º 4
0
TestManager::TestManager(QObject *parent)
    : QObject(parent)
{
    m_manager = new PluginManager(this);
    connect(m_manager, SIGNAL(pluginLoaded(Plugin *)),
            SLOT(slotPluginLoaded(Plugin *)));
    connect(m_manager, SIGNAL(allPluginsLoaded()),
            SLOT(slotAllPluginsLoaded()));
    m_manager->loadAllPlugins();

    QValueList<KPluginInfo *> plugins = m_manager->availablePlugins();
    kdDebug() << "Number of available plugins is " << plugins.count() << endl;
    for(QValueList<KPluginInfo *>::iterator it = plugins.begin(); it != plugins.end(); ++it)
    {
        KPluginInfo *i = (*it);
        kdDebug() << "\tAvailable plugin " << i->name()
                  << ", comment = " << i->comment() << endl;
    }
}
Ejemplo n.º 5
0
 bool canUnload( const KPluginInfo& plugin )
 {
     kDebug() << "checking can unload for:" << plugin.name() << plugin.property("X-KDevelop-LoadMode");
     if( plugin.property( "X-KDevelop-LoadMode" ).toString() == "AlwaysOn" )
     {
         return false;
     }
     QStringList interfaces = plugin.property( "X-KDevelop-Interfaces" ).toStringList();
     kDebug() << "checking dependencies:" << interfaces;
     foreach( const KPluginInfo& info, loadedPlugins.keys() )
     {
         if( info.pluginName() != plugin.pluginName() )
         {
             QStringList dependencies = info.property( "X-KDevelop-IRequired" ).toStringList();
             dependencies += info.property( "X-KDevelop-IOptional" ).toStringList();
             foreach( const QString& dep, dependencies )
             {
                 if( interfaces.contains( dep ) && !canUnload( info ) )
                 {
                     return false;
                 }
             }
         }
     }
Ejemplo n.º 6
0
void BehaviorConfig_Shorten::slotConfigureClicked()
{
    qCDebug(CHOQOK);
    KPluginInfo pluginInfo = availablePlugins.value(shortenPlugins->itemData(shortenPlugins->currentIndex()).toString());
    qCDebug(CHOQOK) << pluginInfo.name() << pluginInfo.kcmServices().count();

    QPointer<QDialog> configDialog = new QDialog(this);
    configDialog->setWindowTitle(pluginInfo.name());
    // The number of KCModuleProxies in use determines whether to use a tabwidget
    QTabWidget *newTabWidget = 0;
    // Widget to use for the setting dialog's main widget,
    // either a QTabWidget or a KCModuleProxy
    QWidget *mainWidget = 0;
    // Widget to use as the KCModuleProxy's parent.
    // The first proxy is owned by the dialog itself
    QWidget *moduleProxyParentWidget = configDialog;

    for (const KService::Ptr &servicePtr: pluginInfo.kcmServices()) {
        if (!servicePtr->noDisplay()) {
            KCModuleInfo moduleInfo(servicePtr);
            KCModuleProxy *currentModuleProxy = new KCModuleProxy(moduleInfo, moduleProxyParentWidget);
            if (currentModuleProxy->realModule()) {
                moduleProxyList << currentModuleProxy;
                if (mainWidget && !newTabWidget) {
                    // we already created one KCModuleProxy, so we need a tab widget.
                    // Move the first proxy into the tab widget and ensure this and subsequent
                    // proxies are in the tab widget
                    newTabWidget = new QTabWidget(configDialog);
                    moduleProxyParentWidget = newTabWidget;
                    mainWidget->setParent(newTabWidget);
                    KCModuleProxy *moduleProxy = qobject_cast<KCModuleProxy *>(mainWidget);
                    if (moduleProxy) {
                        newTabWidget->addTab(mainWidget, moduleProxy->moduleInfo().moduleName());
                        mainWidget = newTabWidget;
                    } else {
                        delete newTabWidget;
                        newTabWidget = 0;
                        moduleProxyParentWidget = configDialog;
                        mainWidget->setParent(0);
                    }
                }

                if (newTabWidget) {
                    newTabWidget->addTab(currentModuleProxy, servicePtr->name());
                } else {
                    mainWidget = currentModuleProxy;
                }
            } else {
                delete currentModuleProxy;
            }
        }
    }

    // it could happen that we had services to show, but none of them were real modules.
    if (moduleProxyList.count()) {
        QWidget *showWidget = new QWidget(configDialog);
        QVBoxLayout *layout = new QVBoxLayout;
        showWidget->setLayout(layout);
        layout->addWidget(mainWidget);
        layout->insertSpacing(-1, QApplication::style()->pixelMetric(QStyle::PM_DialogButtonsSeparator));

        QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
        QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
        okButton->setDefault(true);
        okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
        connect(buttonBox, &QDialogButtonBox::accepted, configDialog.data(), &QDialog::accept);
        connect(buttonBox, &QDialogButtonBox::rejected, configDialog.data(), &QDialog::reject);
        layout->addWidget(buttonBox);
        showWidget->adjustSize();

//         connect(&configDialog, SIGNAL(defaultClicked()), this, SLOT(slotDefaultClicked()));

        if (configDialog->exec() == QDialog::Accepted) {
            for (KCModuleProxy *moduleProxy: moduleProxyList) {
                QStringList parentComponents = moduleProxy->moduleInfo().service()->property(QLatin1String("X-KDE-ParentComponents")).toStringList();
                moduleProxy->save();
            }
        } else {
            for (KCModuleProxy *moduleProxy: moduleProxyList) {
                moduleProxy->load();
            }
        }

        qDeleteAll(moduleProxyList);
        moduleProxyList.clear();
    }
}
Ejemplo n.º 7
0
void PlasmaMuleApplet::contextMenuEvent(QGraphicsSceneContextMenuEvent * event)
{
	QStringList::const_iterator constIterator;
	QMenu menu;

	if (m_catDirs.count() == 1)
	{
		menu.addAction (KIcon("folder"), QString("Default"));
	} else {
		QMenu *open_sub_menu = menu.addMenu("Open Incoming");
		for (constIterator = m_catNames.constBegin(); constIterator != m_catNames.constEnd(); constIterator++)
		{
			open_sub_menu->addAction(KIcon("folder"), "Folder for " + *constIterator);
			if (constIterator != m_catNames.constEnd())
			{
				open_sub_menu->addSeparator();
			}
		}
		menu.addSeparator();
	}

	QClipboard* clipboard = QApplication::clipboard();

	if (!clipboard->text(QClipboard::Clipboard).isEmpty() || !clipboard->text(QClipboard::Selection).isEmpty())
	{
		if (m_catDirs.count() == 1)
		{
			if (!clipboard->text(QClipboard::Clipboard).isEmpty())
			{
				menu.addAction(KIcon("arrow-down-double"), "Download Link from Clipboard");

				if (!clipboard->text(QClipboard::Selection).isEmpty())
				{
					menu.addSeparator();
				}
			}

			if (!clipboard->text(QClipboard::Selection).isEmpty())
			{
				menu.addAction(KIcon("arrow-down-double"), "Download Link from Selection");
			}
		} else	{
			QMenu *download_sub_menu = menu.addMenu("Download Link");

			for (constIterator = m_catNames.constBegin(); constIterator != m_catNames.constEnd(); constIterator++)
			{
				if (!clipboard->text(QClipboard::Clipboard).isEmpty())
				{
					download_sub_menu->addAction(KIcon("arrow-down-double"), "Clipboard->" + *constIterator);

					if (!clipboard->text(QClipboard::Selection).isEmpty())
					{
						download_sub_menu->addSeparator();
					}
				}

				if (!clipboard->text(QClipboard::Selection).isEmpty())
				{
					download_sub_menu->addAction(KIcon("arrow-down-double"), "Selection->" + *constIterator);
				}

				if (constIterator != m_catNames.constEnd())
				{
				download_sub_menu->addSeparator();
				}
			}
		}
	}

	menu.addSeparator();
	menu.addAction(KIcon("documentinfo"), "About");

	QAction* selectedItem = menu.exec(QCursor::pos());
	if (selectedItem)
	{
		if (selectedItem->text() == "About")
		{
			KPluginInfo* service = new KPluginInfo (KService::serviceByDesktopName ("plasma-applet-plasmamule"));
			KAboutData* aboutData = new KAboutData (service->name().toUtf8(),
				service->name().toUtf8(),
				ki18n(service->pluginName().toUtf8()),
				service->version().toUtf8(),
				ki18n(service->comment().toUtf8()),
				KAboutData::License_GPL_V3,
				ki18n(QByteArray()),
				ki18n(QByteArray()),
				service->website().toLatin1(),
				service->email().toLatin1());
			aboutData->addAuthor (ki18n(service->author().toUtf8()),
				ki18n(QByteArray()),
				service->email().toLatin1(),
				service->website().toLatin1());
			aboutData->setTranslator(ki18nc ("NAME OF TRANSLATORS", "Your names"),
				ki18nc("EMAIL OF TRANSLATORS", "Your emails"));
			aboutData->setProgramIconName (service->icon());

			KAboutApplicationDialog* about = new KAboutApplicationDialog(aboutData, KAboutApplicationDialog::HideTranslators);
			about->exec();
		} else if (selectedItem->text().startsWith("Folder for"))
		{
			kDebug(m_debugChannel) << "Opening Folder " << m_catDirs.at(m_catNames.indexOf(selectedItem->text().remove("Folder for ")));
			KUrl url(m_catDirs.at(m_catNames.indexOf(selectedItem->text().remove("Folder for "))) + "/");
			(void) new KRun( url, 0, true );
		} else if (selectedItem->text().startsWith("Download"))
		{
			if (selectedItem->text().remove("Download Link from ") == "Clipboard")
			{
				sendLinkToEngine (clipboard->text(QClipboard::Clipboard), 0, this, m_debugChannel);
			} else {
				sendLinkToEngine (clipboard->text(QClipboard::Selection), 0, this, m_debugChannel);
			}
		} else if (selectedItem->text().startsWith("Clipboard->"))
		{
			sendLinkToEngine (clipboard->text(QClipboard::Clipboard), m_catNames.indexOf(selectedItem->text().remove("Clipboard->")), this, m_debugChannel);
		} else if (selectedItem->text().startsWith("Selection->"))
		{
			sendLinkToEngine (clipboard->text(QClipboard::Selection), m_catNames.indexOf(selectedItem->text().remove("Selection->")), this, m_debugChannel);
		}
	}
}