示例#1
0
文件: menus.cpp 项目: Kafay/vlc
/**
 * Tools, like Media Information, Preferences or Messages
 **/
QMenu *QVLCMenu::ToolsMenu( QMenu *menu )
{
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
            SLOT( extendedDialog() ), "Ctrl+E" );

    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
            SLOT( synchroDialog() ), "" );

    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );

    addDPStaticEntry( menu, qtr( I_MENU_BOOKMARK ),"",
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
#ifdef ENABLE_VLM
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
        "Ctrl+W" );
#endif

    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
        ":/menu/messages", SLOT( messagesDialog() ),
        "Ctrl+M" );

    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
    menu->addSeparator();

    addDPStaticEntry( menu, qtr( "&Preferences" ),
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P" );

    return menu;
}
示例#2
0
/**
 * Tools, like Media Information, Preferences or Messages
 **/
QMenu *VLCMenuBar::ToolsMenu( QMenu *menu )
{
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
            SLOT( extendedDialog() ), "Ctrl+E" );

    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
            SLOT( synchroDialog() ), "" );

    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );

#ifdef ENABLE_VLM
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
        "Ctrl+Shift+W" );
#endif

    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
        ":/menu/messages", SLOT( messagesDialog() ), "Ctrl+M" );

    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
    menu->addSeparator();

    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
        ":/menu/preferences", SLOT( toolbarDialog() ) );

    addDPStaticEntry( menu, qtr( "&Preferences" ),
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P", QAction::PreferencesRole );

    return menu;
}
//FIXME: keep loaded plugins in own plugin manager and
//unload plugins to let load new version without
//the need to restart the application
void RackWindow::loadPlugin(QWidget *pluginHost)
{
    QDir pluginsDir(qApp->applicationDirPath());
#if defined(Q_OS_WIN)
    if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
        pluginsDir.cdUp();
#elif defined(Q_OS_MAC)
    if (pluginsDir.dirName() == "MacOS") {
        pluginsDir.cdUp();
        pluginsDir.cdUp();
        pluginsDir.cdUp();
    }
#endif

    if (!pluginsDir.cd("plugins"))
    {
        QMessageBox::information(this, "Error", "No plugin folder found");
        return;
    }


    QStringList pluginList = pluginsDir.entryList(QDir::Files);


    RSelectPluginDialog pluginDialog(this);
    pluginDialog.pluginListWidget->addItems(pluginList);
    pluginDialog.pluginListWidget->setCurrentRow(0);
    if (pluginDialog.exec())
    {



//    bool ok;
//    int newPluginIndex = RSelectPluginDialog::getIndex(this, pluginList, &ok);
//    if (ok) {

        //QString fileName = pluginsDir.entryList(QDir::Files).at(newPluginIndex);

        QString fileName = pluginsDir.entryList(QDir::Files).at(pluginDialog.pluginListWidget->currentRow());

        QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
        QObject *plugin = pluginLoader.instance();


        ///test

//        QList<QPluginLoader *> loadedPlugins = findChildren<QPluginLoader *>();

//        QObject *plugin = 0;

//        for (int i = 0; i < loadedPlugins.size(); ++i) {
//            if (loadedPlugins.at(i)->fileName() == pluginsDir.absoluteFilePath(fileName)) {
//                plugin = loadedPlugins.at(i)->instance();
//                break;
//            }
//        }

//        if (!plugin) {
//            QPluginLoader *pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName), this);
//            plugin = pluginLoader->instance();
//        }


        //debug code
        qDebug() << "we have the following plugins loaded:";
        QList<QPluginLoader *> debugPlugins = findChildren<QPluginLoader *>();
        for (int i = 0; i < debugPlugins.size(); ++i) {
            qDebug() << debugPlugins.at(i)->fileName();
        }


        //////////


//        m_pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName), this);
//        QObject *plugin = m_pluginLoader->instance();

        /////////////////


        if (plugin)
        {
            IWidgetPlugin *widgetPlugin = qobject_cast<IWidgetPlugin *>(plugin);
            if (widgetPlugin)
            {
                QWidget *newWidget = widgetPlugin->createRWidget(m_coreImpl, this);

                //get pointers from pluginhost:
                QStackedWidget *pluginStack = pluginHost->findChild<QStackedWidget *>("rackPluginStack");
                QToolBar *pluginHostToolBar = pluginHost->findChild<QToolBar *>("rackPluginHostToolBar");
                QToolBar *pluginToolBar = pluginHost->property("pluginToolBar").value<QToolBar *>();
                QSignalMapper *sm = pluginHost->findChild<QSignalMapper *>("rackPluginSwitchMapper");
                QActionGroup *ag = pluginHostToolBar->findChild<QActionGroup *>();

                //add plugin widget to the widget stack:
                pluginStack->setCurrentIndex(pluginStack->addWidget(newWidget));

                //create action for the toolbars:
                QAction *act = new QAction(widgetPlugin->name(), ag);
                act->setCheckable(true);
                act->setChecked(true);
                //qt bugfix: set transparent dummy icon to move button text down or right
                act->setIcon(QIcon(":/images/transparent-icon.png"));

                //create button for pluginhost toolbar:
                QToolButton *tb = new QToolButton;
                tb->setObjectName(QLatin1String(newWidget->metaObject()->className()) + "ToolButton");
                tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
                tb->setFocusPolicy(Qt::NoFocus);
                tb->setDefaultAction(act);
                RPushButton *settingsButton = new RPushButton;
                settingsButton->setObjectName("rackPluginHostToolBarSettingsButton");
                RPushButton *deleteButton = new RPushButton;
                deleteButton->setObjectName("rackPluginHostToolBarDeleteButton");
                QHBoxLayout *hl = new QHBoxLayout(tb);
                hl->setSpacing(0);
                hl->setContentsMargins(0,0,1,0);
                hl->addStretch();
                hl->addWidget(settingsButton);
                hl->addWidget(deleteButton);
                pluginHostToolBar->addWidget(tb);

                //create button for plugin toolbar:
                QToolButton *tb1 = new QToolButton;
                tb1->setObjectName(QLatin1String(newWidget->metaObject()->className()) + "ToolButton");
                tb1->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
                tb1->setFocusPolicy(Qt::NoFocus);
                tb1->setDefaultAction(act);
                pluginToolBar->addWidget(tb1);

                //connect action trigger to PluginSwitchMapper;
                QObject::connect(act, SIGNAL(triggered()), sm, SLOT(map()));
                sm->setMapping(act, newWidget);

                //connect delete signal
                //remove act from actiongroup and delete it:
                QObject::connect(deleteButton, SIGNAL(clicked()), m_mapperClosePlugin, SLOT(map()));
                m_mapperClosePlugin->setMapping(deleteButton, act);
                QObject::connect(deleteButton, SIGNAL(clicked()), newWidget, SLOT(deleteLater()));
                QObject::connect(deleteButton, SIGNAL(clicked()), tb1, SLOT(deleteLater()));
                QObject::connect(deleteButton, SIGNAL(clicked()), tb, SLOT(deleteLater()));

                //connect settings signal
                //if (plugin has settings) ...
                //QObject::connect(settingsButton, SIGNAL(clicked()),

            }
        }
        else
        {
            QMessageBox::information(this, "Error", "Could not load the plugin");
            qDebug() << pluginLoader.errorString();

        }
    }
}