void PanelPluginsModel::removePlugin()
{
    Plugin * p = qobject_cast<Plugin*>(sender());
    auto plugin = std::find_if(mPlugins.begin(), mPlugins.end(),
                               [p] (pluginslist_t::const_reference obj) { return p == obj.second; });
    removePlugin(std::move(plugin));
}
Beispiel #2
0
PluginManager::~PluginManager()
{
    QListIterator<Plugin *> i(m_list);
    while (i.hasNext()) {
        Plugin *item = static_cast<Plugin *>(i.next());
        if (item)
            removePlugin(item);
    }
}
void PanelPluginsModel::onRemovePlugin()
{
    if (!isActiveIndexValid())
        return;

    auto plugin = mPlugins.begin() + mActive.row();
    if (plugin->second.isNull())
        removePlugin(std::move(plugin));
    else
        plugin->second->requestRemove();
}
void CTKPluginListener::processPlugins(const QList<QSharedPointer<ctkPlugin> >& plugins)
{
  // sort the plugins according to their dependencies
  const QList<QSharedPointer<ctkPlugin> > sortedPlugins = sortPlugins(plugins);

  foreach (QSharedPointer<ctkPlugin> plugin, sortedPlugins)
  {
    if (isPluginResolved(plugin))
      addPlugin(plugin);
    else
      removePlugin(plugin);
  }
}
Beispiel #5
0
void PluginManager::loadPlugin(string plugin_name) {
  removePlugin(plugin_name);

  string path = "./plugins/" + plugin_name;
  void* handle = dlopen(path.c_str(), RTLD_LAZY);

  if(!handle)
    throw PluginException("failed to load plugin from " + path + ": " + dlerror());

  Plugin* (*make_plugin)();
  *(void **) (&make_plugin) = dlsym(handle, "make_plugin");

  plugins[plugin_name] = make_plugin();
  handles[plugin_name] = handle;
}
Beispiel #6
0
PluginData* PluginHandler_reloadPlugin(PluginData* pluginData) {
    const char* filename = pluginData->filename;
    const char* fullName = string_clone(pluginData->fullFilename);

    printf("removing plugin...\n");

    removePlugin(pluginData);

    printf("adding plugin...%s\n", filename);

    PluginHandler_addPlugin(OBJECT_DIR, filename);

    printf("finding plugin\n");

    printf("trying to find %s\n", fullName);

    PluginData* newPluginData = PluginHandler_findPluginByFilename(fullName);

    printf("found plugin %p\n", newPluginData);

    return newPluginData;
}
void ctkQtMobilityServiceRuntime::pluginChanged(const ctkPluginEvent& pe)
{
  QSharedPointer<ctkPlugin> plugin = pe.getPlugin();

  ctkPluginEvent::Type eventType = pe.getType();
  if (eventType == ctkPluginEvent::LAZY_ACTIVATION)
  {
    lazy.insert(plugin);
    processPlugin(plugin);
  }
  else if (eventType == ctkPluginEvent::STARTED)
  {
    if (!lazy.remove(plugin))
    {
      processPlugin(plugin);
    }
  }
  else if (eventType == ctkPluginEvent::STOPPING)
  {
    lazy.remove(plugin);
    removePlugin(plugin);
  }
}
Beispiel #8
0
VSTSettingsPage::VSTSettingsPage(VSTProcessor *processor_, QWidget *parent)
  : QWidget(parent), processor(processor_), addPluginDialog(this)
{
  int i;
  QString defaultSearchPath;

#if defined(Q_WS_MAC)
  defaultSearchPath = "~/Library/Audio/Plug-Ins/VST;/Library/Audio/Plug-Ins/VST";
#elif defined(Q_WS_WIN)
  if (sizeof(void*) == 4) {
    defaultSearchPath = QSettings("HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\VST",
                                  QSettings::NativeFormat).value("VSTPluginsPath").toString();
  }
  if (defaultSearchPath.isEmpty()) {
    defaultSearchPath = QSettings("HKEY_LOCAL_MACHINE\\Software\\VST",
                                  QSettings::NativeFormat).value("VSTPluginsPath").toString();
  }
#endif

  addPluginDialog.setSearchPath(settings->value("vst/searchPath", defaultSearchPath).toString());
  addPluginDialog.setPlugins(settings->value("vst/plugins").toStringList());

  QVBoxLayout *vBoxLayout = new QVBoxLayout;
  QHBoxLayout *hBoxLayout = new QHBoxLayout;

  pluginList = new QListWidget;
  connect(pluginList, SIGNAL(itemSelectionChanged()),
          this, SLOT(itemSelectionChanged()));
  for (i = 0; i < processor->numPlugins(); i++) {
    pluginList->addItem(processor->getPlugin(i)->getName());
  }
  hBoxLayout->addWidget(pluginList);

  QVBoxLayout *buttonLayout = new QVBoxLayout;
  QPushButton *addButton = new QPushButton(QIcon::fromTheme("list-add"), tr("Add"));
  connect(addButton, SIGNAL(clicked()),
          this, SLOT(addPlugin()));
  buttonLayout->addWidget(addButton);
  removeButton = new QPushButton(QIcon::fromTheme("list-remove"), tr("Remove"));
  connect(removeButton, SIGNAL(clicked()),
          this, SLOT(removePlugin()));
  buttonLayout->addWidget(removeButton);
  upButton = new QPushButton(QIcon::fromTheme("go-up"), tr("Up"));
  connect(upButton, SIGNAL(clicked()),
          this, SLOT(movePluginUp()));
  buttonLayout->addWidget(upButton);
  downButton = new QPushButton(QIcon::fromTheme("go-down"), tr("Down"));
  connect(downButton, SIGNAL(clicked()),
          this, SLOT(movePluginDown()));
  buttonLayout->addWidget(downButton);
  editButton = new QPushButton(tr("Edit..."));
  connect(editButton, SIGNAL(clicked()),
          this, SLOT(openEditor()));
  buttonLayout->addWidget(editButton);
  hBoxLayout->addLayout(buttonLayout);

  vBoxLayout->addLayout(hBoxLayout);

  setLayout(vBoxLayout);
  itemSelectionChanged();
}
Beispiel #9
0
DesktopScene::DesktopScene(QObject * parent)
    : QGraphicsScene(parent),
      m_wheelDesktopSwitch(false),
      m_menu(0),
      m_activePlugin(0)
{
    m_power = new PowerManager(this);
    m_screenSaver = new ScreenSaver(this);

    DesktopConfig::instance()->config->beginGroup("razor");
    QStringList plugins =  DesktopConfig::instance()->config->value("plugins").toStringList();
    m_menuFile = DesktopConfig::instance()->config->value("menu_file", "").toString();
    m_wheelDesktopSwitch = DesktopConfig::instance()->config->value("mouse_wheel_desktop_switch", false).toBool();
    DesktopConfig::instance()->config->endGroup();
    if (m_menuFile.isEmpty())
        m_menuFile = XdgMenu::getMenuFileName();

    m_xdgMenu.setEnvironments(QStringList() << "X-RAZOR" << "Razor");
    bool res = m_xdgMenu.read(m_menuFile);
    connect(&m_xdgMenu, SIGNAL(changed()), this, SLOT(buildMenu()));

    if (res)
    {
        QTimer::singleShot(1000, this, SLOT(buildMenu()));
    }
    else
    {
        QMessageBox::warning(0, "Menu Parse error", m_xdgMenu.errorString());
        return;
    }

    m_actArrangeWidgets = new QAction(tr("Unlock Desktop..."), this);
    m_actArrangeWidgets->setIcon(XdgIcon::fromTheme("object-locked"));
    m_actArrangeWidgets->setCheckable(true);
    connect(m_actArrangeWidgets, SIGNAL(toggled(bool)),
            this, SLOT(arrangeWidgets(bool)));

    m_actAddNewPlugin = new QAction(tr("Add New Desktop Widget..."), this);
    connect(m_actAddNewPlugin, SIGNAL(triggered()),
            this, SLOT(showAddPluginDialog()));

    m_actRemovePlugin = new QAction(tr("Remove Plugin..."), this);
    connect(m_actRemovePlugin, SIGNAL(triggered()),
            this, SLOT(removePlugin()));

    m_actConfigurePlugin = new QAction(tr("Configure Plugin..."), this);
    connect(m_actConfigurePlugin, SIGNAL(triggered()),
            this, SLOT(configurePlugin()));

    m_actSetbackground = new QAction(tr("Set Desktop Background..."), this);
    m_actSetbackground->setIcon(XdgIcon::fromTheme("preferences-desktop-wallpaper"));
    connect(m_actSetbackground, SIGNAL(triggered()),
            this, SLOT(setDesktopBackground()));

    m_actAbout = new QAction(tr("About Razor..."), this);
    m_actAbout->setIcon(XdgIcon::fromTheme("help-browser"));
    connect(m_actAbout, SIGNAL(triggered()), this, SLOT(about()));

    // load plugins
    QStringList desktopDirs = pluginDesktopDirs();
    foreach (QString configId, plugins)
    {
        DesktopConfig::instance()->config->beginGroup(configId);
        QString libName(DesktopConfig::instance()->config->value("plugin", "").toString());

        qreal x = DesktopConfig::instance()->config->value("x", 10.0).toReal();
        qreal y = DesktopConfig::instance()->config->value("y", 10.0).toReal();
        qreal w = DesktopConfig::instance()->config->value("w", 10.0).toReal();
        qreal h = DesktopConfig::instance()->config->value("h", 10.0).toReal();
        QPointF position(x, y);
        QSizeF size(w, h);
        DesktopConfig::instance()->config->endGroup();

        RazorPluginInfoList list = RazorPluginInfo::search(desktopDirs, "RazorDesktop/Plugin", QString("%1.desktop").arg(libName));
        if( !list.count())
        {
            qWarning() << QString("Plugin \"%1\" not found.").arg(libName);
            continue;
        }
        QLibrary* lib = loadPluginLib(list.first());
        if (!lib)
        {
            qWarning() << "RazorWorkSpace::setConfig() Library" << libName << "is not loaded";
            continue;
        }

        DesktopWidgetPlugin * item = m_plugins[configId];
        if (!item)
        {
            item = loadPlugin(lib, configId);
            m_plugins.insert(configId, item);
        }

        item->setSizeAndPosition(position, size);
    }