PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device* device) const
{
    PluginData ret;

    KService::Ptr service = plugins[name];
    if (!service) {
        kDebug(kdeconnect_kded()) << "Plugin unknown" << name;
        return ret;
    }

    KPluginFactory *factory = KPluginLoader(service->library()).factory();
    if (!factory) {
        kDebug(kdeconnect_kded()) << "KPluginFactory could not load the plugin:" << service->library();
        return ret;
    }

    ret.interfaces = service->property("X-KdeConnect-SupportedPackageType", QVariant::StringList).toStringList();

    QVariant deviceVariant = QVariant::fromValue<Device*>(device);

    //FIXME any reason to use QObject in template param instead KdeConnectPlugin?
    ret.plugin = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant);
    if (!ret.plugin) {
        kDebug(kdeconnect_kded()) << "Error loading plugin";
        return ret;
    }

    kDebug(kdeconnect_kded()) << "Loaded plugin:" << service->name();
    return ret;
}
void PluginManager::loadPlugins()
{
    KService::List offers = KServiceTypeTrader::self()->query(QLatin1String("KTpAccountsKCM/AccountUiPlugin"));

    KService::List::const_iterator iter;
    for (iter = offers.constBegin(); iter < offers.constEnd(); ++iter) {
       QString error;
       KService::Ptr service = *iter;

        KPluginFactory *factory = KPluginLoader(service->library()).factory();

        if (!factory) {
            qWarning() << "KPluginFactory could not load the plugin:" << service->library();
            continue;
        }

       AbstractAccountUiPlugin *plugin = factory->create<AbstractAccountUiPlugin>(this);

       if (plugin) {
           qDebug() << "Loaded plugin:" << service->name();
           m_plugins.append(plugin);
       } else {
           qDebug() << error;
       }
    }
}
Beispiel #3
0
void FrameBufferManager::loadPlugins()
{
    //qDebug();

    const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("krfb"), [](const KPluginMetaData & md) {
            return md.serviceTypes().contains(QStringLiteral("krfb/framebuffer"));
        });

    QVectorIterator<KPluginMetaData> i(plugins);
    i.toBack();
    QSet<QString> unique;
    while (i.hasPrevious()) {
	KPluginMetaData data = i.previous();
        // only load plugins once, even if found multiple times!
        if (unique.contains(data.name()))
            continue;
	KPluginFactory *factory = KPluginLoader(data.fileName()).factory();
	
	if (!factory) {
		qDebug() << "KPluginFactory could not load the plugin:" << data.fileName();
	} else {
		qDebug() << "found plugin at " << data.fileName();
	}
	
	FrameBufferPlugin *plugin = factory->create<FrameBufferPlugin>(this);
	if (plugin) {
		m_plugins.insert(data.pluginId(), plugin);
		qDebug() << "Loaded plugin with name " << data.pluginId();
	} else {
		qDebug() << "unable to load pluign for " << data.fileName();
	}
        unique.insert (data.name());
    }
}
Beispiel #4
0
CViewer::CViewer()
{
    KPluginFactory *factory=KPluginLoader("kfontviewpart").factory();

    if(factory)
    {
        itsPreview=factory->create<KParts::ReadOnlyPart>(this);

        actionCollection()->addAction(KStandardAction::Open, this, SLOT(fileOpen()));
        actionCollection()->addAction(KStandardAction::Quit, this, SLOT(close()));
        actionCollection()->addAction(KStandardAction::KeyBindings, this, SLOT(configureKeys()));
        itsPrintAct=actionCollection()->addAction(KStandardAction::Print, itsPreview, SLOT(print()));

        itsPrintAct->setEnabled(false);

        if(itsPreview->browserExtension())
            connect(itsPreview->browserExtension(), SIGNAL(enableAction(const char*,bool)),
                    this, SLOT(enableAction(const char*,bool)));

        setCentralWidget(itsPreview->widget());
        createGUI(itsPreview);

        setAutoSaveSettings();
        applyMainWindowSettings(KSharedConfig::openConfig()->group("MainWindow"));
    }
    else
Beispiel #5
0
KEmoticonsProvider *KEmoticonsPrivate::loadProvider(const KService::Ptr &service)
{
    KPluginFactory *factory = KPluginLoader(service->library()).factory();
    if (!factory) {
        kWarning() << "Invalid plugin factory for" << service->library();
        return 0;
    }
    KEmoticonsProvider *provider = factory->create<KEmoticonsProvider>(0);
    return provider;
}
Beispiel #6
0
TermWidget::TermWidget(QWidget * par,bool bIsStandalone)
    : QFrame(par)
{
    setObjectName("term_widget");
    if(bIsStandalone)g_pTermWidgetList->append(this);
    m_bIsStandalone = bIsStandalone;

    m_pKonsolePart = 0;
    m_pKonsoleWidget = 0;

    if(bIsStandalone)
    {
        m_pHBox = new KviTalHBox(this);
        m_pTitleLabel = new QLabel(__tr2qs("Terminal Emulator"),m_pHBox);
        m_pTitleLabel->setFrameStyle(QFrame::Raised | QFrame::StyledPanel);
        m_pCloseButton = new QPushButton("",m_pHBox);
        m_pCloseButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Close)));
        m_pCloseButton->setToolTip(__tr2qs("Close this window"));
        m_pHBox->setStretchFactor(m_pTitleLabel,2);
        connect(m_pCloseButton,SIGNAL(clicked()),this,SLOT(closeClicked()));
    } else {
        m_pHBox = 0;
        m_pTitleLabel = 0;
        m_pCloseButton = 0;
    }

    setFrameStyle(QFrame::Sunken | QFrame::Panel);

    KPluginFactory *pKonsoleFactory = KPluginLoader("libkonsolepart").factory();

    if(pKonsoleFactory)
    {
        m_pKonsolePart = static_cast<KParts::ReadOnlyPart *>(pKonsoleFactory->create<QObject>(this, this));

        if(m_pKonsolePart)
        {
            // start the terminal
            qobject_cast<TerminalInterface*>(m_pKonsolePart)->showShellInDir( QString() );

            m_pKonsoleWidget = m_pKonsolePart->widget();

            setFocusProxy(m_pKonsoleWidget);
            m_pKonsoleWidget->show();

            connect ( m_pKonsolePart, SIGNAL(destroyed()), this, SLOT(konsoleDestroyed()) );
        } else {
            m_pKonsoleWidget = new QLabel(__tr2qs("Can't create the terminal emulation part"), this);
        }
    } else {
        m_pKonsoleWidget = new QLabel(__tr2qs("Can't retrieve the terminal emulation factory"), this);
    }
}
Beispiel #7
0
Container::Container( QWidget* parent ) : QWidget(parent)
{
    setAttribute( Qt::WA_X11NetWmWindowTypeDock );

    KWindowSystem::setType( winId(), NET::Dock );
    KWindowSystem::setState( winId(), NET::Sticky );
    KWindowSystem::setState( winId(), NET::StaysOnTop );
    KWindowSystem::setOnAllDesktops( winId(), true );

    setMinimumSize( 20, 20 );
    m_side = 0;
    m_occ = 48;

//     setSide( 2 );

//     slotScreenResized();

    NLayout* layout = new NLayout;
    layout->setMargin( 0 );
//     layout->setSpacing( 0 );
    setLayout( layout );

    m_isLocked = true;

    /// at least set a sensible order by default
    QStringList m_appletsOrder;
    m_appletsOrder << "knpanel_applet_kbutton";
    m_appletsOrder << "knpanel_applet_mnpager";
    m_appletsOrder << "knpanel_applet_sctasks";
    m_appletsOrder << "knpanel_applet_sstray";
    m_appletsOrder << "knpanel_applet_dclock";
    m_appletsOrder << "knpanel_applet_trash";
    m_appletsOrder << "knpanel_applet_sdhbutton";

    QHash<QString,Plate*> plates;
    QString constraint( "([X-KDE-Priority] > 0) and (exist Library)" );
    KService::List offers = KServiceTypeTrader::self()->query( "KNPanelApplet", constraint );
    foreach ( const KService::Ptr& service, offers ) {
        KPluginFactory* factory = KPluginLoader( service->library() ).factory();
        if ( factory ) {
            const KAboutData* aboutData = factory->componentData().aboutData();
            qWarning() << "loading" << aboutData->appName();
            /// FIXME: port to KPluginInfo
            if ( !m_appletsOrder.contains( aboutData->appName() ) )
                continue;

            KNPanelApplet* applet = factory->create<KNPanelApplet>();
            plates.insert( aboutData->appName(), new Plate( applet, factory->componentData() ) );
        }
    }
void KateProjectInfoViewTerminal::loadTerminal()
{
    /**
     * null in any case, if loadTerminal fails below and we are in the destroyed event
     */
    m_konsolePart = 0;

    /**
     * get konsole part factory
     */
    KPluginFactory *factory = KPluginLoader(QStringLiteral("konsolepart")).factory();
    if (!factory) {
        return;
    }

    /**
     * create part
     */
    m_konsolePart = factory->create<KParts::ReadOnlyPart>(this, this);
    if (!m_konsolePart) {
        return;
    }

    /**
     * init locale translation stuff
     */
    // FIXME KF5 KGlobal::locale()->insertCatalog("konsole");

    /**
     * switch to right directory
     */
    qobject_cast<TerminalInterface *>(m_konsolePart)->showShellInDir(QFileInfo(m_project->fileName()).absolutePath());

    /**
     * add to widget
     */
    m_layout->addWidget(m_konsolePart->widget());
    setFocusProxy(m_konsolePart->widget());

    /**
     * guard destruction, create new terminal!
     */
    connect(m_konsolePart, SIGNAL(destroyed()), this, SLOT(loadTerminal()));
    connect(m_konsolePart, SIGNAL(overrideShortcut(QKeyEvent *, bool &)),
            this, SLOT(overrideShortcut(QKeyEvent *, bool &)));
}
Beispiel #9
0
QWidget* createTerminalWidget(QWidget* parent = 0)
{
    KPluginFactory* factory = KPluginLoader("libkonsolepart").factory();
    KParts::ReadOnlyPart* part = factory ? (factory->create<KParts::ReadOnlyPart>(parent)) : 0;

    if (!part) {
        printf("Failed to initialize part\n");
        return 0;
    }

    TerminalInterface* terminal = qobject_cast<TerminalInterface*>(part);
    if (!terminal) {
        printf("Failed to initialize terminal\n");
        return 0;
    }

    terminal->showShellInDir(KUrl().path());
    terminal->sendInput("cd " + KShell::quoteArg(KUrl().path()) + '\n');
    terminal->sendInput("clear\n");
    return part->widget();
}
Beispiel #10
0
bool MainWindow::loadPart()
{
    KPluginFactory *factory = Q_NULLPTR;

    const auto plugins = KPluginLoader::findPlugins(QString(), [](const KPluginMetaData& metaData) {
        return metaData.pluginId() == QStringLiteral("arkpart") &&
               metaData.serviceTypes().contains(QStringLiteral("KParts/ReadOnlyPart")) &&
               metaData.serviceTypes().contains(QStringLiteral("Browser/View"));
    });

    if (!plugins.isEmpty()) {
        factory = KPluginLoader(plugins.first().fileName()).factory();
    }

    m_part = factory ? static_cast<KParts::ReadWritePart*>(factory->create<KParts::ReadWritePart>(this)) : Q_NULLPTR;

    if (!m_part) {
        KMessageBox::error(this, i18n("Unable to find Ark's KPart component, please check your installation."));
        qCWarning(ARK) << "Error loading Ark KPart.";
        return false;
    }

    m_part->setObjectName(QStringLiteral("ArkPart"));
    setCentralWidget(m_part->widget());

    setupGUI(ToolBar | Keys | Save, QStringLiteral("arkui.rc"));
    createGUI(m_part);

    statusBar()->hide();

    connect(m_part, SIGNAL(ready()), this, SLOT(updateActions()));
    connect(m_part, SIGNAL(quit()), this, SLOT(quit()));
    // #365200: this will disable m_recentFilesAction, while openUrl() will enable it.
    // So updateActions() needs to be called after openUrl() returns.
    connect(m_part, SIGNAL(busy()), this, SLOT(updateActions()), Qt::QueuedConnection);

    return true;
}
        foreach (const QString &dir, dirsToCheck) {
            QVector<KPluginMetaData> metadataList = KPluginLoader::findPlugins(dir,
                [=](const KPluginMetaData &data)
            {
                return data.serviceTypes().contains("artikulate/libsound/backend");
            });

            foreach (const auto &metadata, metadataList) {
                loader.setFileName(metadata.fileName());
                qCDebug(LIBSOUND_LOG) << "Load Plugin: " << metadata.name();
                if (!loader.load()) {
                    qCCritical(LIBSOUND_LOG) << "Error while loading plugin: " << metadata.name();
                }
                KPluginFactory *factory = KPluginLoader(loader.fileName()).factory();
                if (!factory) {
                    qCCritical(LIBSOUND_LOG) << "Could not load plugin:" << metadata.name();
                    continue;
                }
                BackendInterface *plugin = factory->create<BackendInterface>(parent, QList< QVariant >());
                if (plugin->outputBackend()) {
                    m_backendList.append(plugin->outputBackend());
                }
            }
Beispiel #12
0
	void Konsole::spawn()
	{
		KILE_DEBUG_MAIN << "void Konsole::spawn()";

		KPluginFactory *factory = Q_NULLPTR;
		KService::Ptr service = KService::serviceByDesktopName("konsolepart");
		if(!service) {
			KILE_DEBUG_MAIN << "No service for konsolepart";
			return;
		}

		factory = KPluginLoader(service->library()).factory();
		if(!factory) {
			KILE_DEBUG_MAIN << "No factory for konsolepart";
			return;
		}

		// the catalog for translations is added by the Konsole part constructor already
		m_part = static_cast<KParts::ReadOnlyPart*>(factory->create<QObject>(this, this));
		if(!m_part) {
			return;
		}

		if(!qobject_cast<TerminalInterface*>(m_part)){
			KILE_DEBUG_MAIN << "Did not find the TerminalInterface";
			delete m_part;
			m_part = Q_NULLPTR;
			return;
		}

		layout()->addWidget(m_part->widget());
		setFocusProxy(m_part->widget());
		connect(m_part, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));

		// necessary as older versions of Konsole (4.5) might not show a proper prompt otherwise
		qobject_cast<TerminalInterface*>(m_part)->showShellInDir(QDir::currentPath());
	}