Пример #1
0
void TagEditor::createActions(){

    connect(LoadScriptButton,SIGNAL(clicked()),this,SLOT(loadScript()));
    connect(SaveScriptButton,SIGNAL(clicked()),this,SLOT(saveScript()));
    connect(RunScriptButton,SIGNAL(clicked()),this, SLOT(runScript()));

    QAction* searchOnlineAction = new QAction(tr("Search for selected file/album in online musicdatabases..."), this);
    searchOnlineAction->setShortcut(tr("Ctrl+S"));
    connect(searchOnlineAction, SIGNAL(triggered()), this, SLOT(searchOnline()));
    QAction* searchForFilesAction = new QAction(tr("Search for files to add to workspace..."), this);
    //searchForFilesAction->setShortcut(tr("Ctrl+S"));
    connect(searchForFilesAction, SIGNAL(triggered()), this, SLOT(searchAndAddFiles()));

    TreeView->setContextMenuPolicy(Qt::ActionsContextMenu);
    TreeView->addAction(searchOnlineAction);
    TreeView->addAction(searchForFilesAction);


    connect( TreeView, SIGNAL( expanded( const QModelIndex & )  ), this, SLOT( resizeColumn() ) );
    connect( TreeView, SIGNAL( collapsed( const QModelIndex & )  ), this, SLOT( resizeColumn() ) );
    //connect( TreeWidget_, SIGNAL( currentRowChanged( int )  ), this, SLOT( showTagInfo(int) ) );
    connect( TreeWidget_, SIGNAL( itemSelectionChanged() ), this, SLOT( showTagInfo() ) );
    connect( AddButton, SIGNAL( clicked()  ), this, SLOT(addFiles() ) );
    connect( RemoveButton, SIGNAL( clicked()  ), this, SLOT(removeFiles() ) );
    connect( ClearButton, SIGNAL( clicked()  ), this, SLOT(removeAllFiles() ) );
    connect( SaveButton, SIGNAL( clicked()  ), this, SLOT(saveTag() ) );
    connect( ChooseDirButton, SIGNAL( clicked()  ), this, SLOT(chooseDir() ) );

    connect( actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) );
    connect( actionRewriteTag, SIGNAL( triggered() ), this, SLOT( rewriteTag() ) );
    connect( actionRenameFiles, SIGNAL( triggered() ), this, SLOT( renameFiles() ) );
    connect( actionReplaceTags, SIGNAL( triggered() ), this, SLOT( replaceTags() ) );
    connect( actionSerialize, SIGNAL( triggered() ), this, SLOT( serialize() ) );
    connect( actionClearTags, SIGNAL( triggered() ), this, SLOT( clearTags() ) );
    //connect( actionRemoveFrames, SIGNAL( triggered() ), this, SLOT( removeFrames() ) );
    //styles

    QSignalMapper *styleMapper = new QSignalMapper(this);
    QStringList styles = QStyleFactory::keys();
    for(int i=0;i<styles.size();i++){
        QAction *a = new QAction(styles[i],menuStyle);
        a->setCheckable(true);
        connect(a, SIGNAL(triggered()), styleMapper, SLOT(map()));
        styleMapper->setMapping(a, styles[i]);
        menuStyle->addAction(a);
    }
    menuStyle->addSeparator();
    QAction *actionCustomStyleSheet = new QAction("Custom...",menuStyle);
    actionCustomStyleSheet->setCheckable(true);
    connect(actionCustomStyleSheet, SIGNAL(triggered()), this, SLOT(openStyleSheet()));
    menuStyle->addAction( actionCustomStyleSheet );
    connect(styleMapper, SIGNAL(mapped(const QString &)), this, SLOT(setGUIStyle(const QString &)));

}
void RackWindow::createToolBars()
{
    //main toolbar actions:
    QAction *fullscreenAct = new QAction(tr("Fullscreen"), this);
    fullscreenAct->setCheckable(true);
    QAction *enterSettingsAct = new QAction(tr("Change Widget Layout"), this);
    QAction *quitAct = new QAction(tr("Quit"), this);

    //main toolbar menus:
    QMenu *mainMenu = new QMenu(this);
    mainMenu->setObjectName("rackMainMenu");
    QAction *titleAct = new QAction(tr("R.A.C.K."),this);
    titleAct->setDisabled(true);
    mainMenu->addAction(titleAct);
    mainMenu->setDefaultAction(titleAct);
    mainMenu->addAction(fullscreenAct);
    mainMenu->addAction(enterSettingsAct);
    mainMenu->addAction(quitAct);

    //main toolbar buttons:
    RPushButton *settingsButton = new RPushButton(tr("Menu"));
    settingsButton->setObjectName("rackSettingsButton");
    settingsButton->setMenu(mainMenu);
    RBlinkButton *deleteButton = new RBlinkButton(tr("Delete"));
    deleteButton->setObjectName("rackDeleteButton");
    RBlinkButton *previewButton = new RBlinkButton(tr("Preview"));
    previewButton->setObjectName("rackPreviewButton");

    //main toolbar:
    QToolBar *mainToolBar = new QToolBar;
    mainToolBar->setObjectName("rackMainToolBar");
    mainToolBar->setMovable(false);
    mainToolBar->addWidget(settingsButton);
    mainToolBar->addWidget(deleteButton);
    mainToolBar->addWidget(previewButton);

    //delete state:
    QObject::connect(deleteButton, SIGNAL(clicked()), m_coreImpl, SLOT(toggleDeleteState()));
    QObject::connect(m_coreImpl, SIGNAL(deleteStateChanged(bool)), deleteButton, SLOT(setBlinking(bool)));

    //preview state:
    QObject::connect(previewButton, SIGNAL(clicked()), m_coreImpl, SLOT(togglePreviewState()));
    QObject::connect(m_coreImpl, SIGNAL(previewStateChanged(bool)), previewButton, SLOT(setBlinking(bool)));

    //normal state:
    QObject::connect(this, SIGNAL(enterSettingsMode()), m_coreImpl, SLOT(setNormalState()));

    //main toolbar signals & slots:
    QObject::connect(fullscreenAct, SIGNAL(triggered(bool)), this, SLOT(toggleFullscreen()));
    QObject::connect(enterSettingsAct, SIGNAL(triggered()), SIGNAL(enterSettingsMode()));
    QObject::connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
    QObject::connect(this, SIGNAL(enterSettingsMode()), mainToolBar, SLOT(hide()));
    QObject::connect(this, SIGNAL(leaveSettingsMode()), mainToolBar, SLOT(show()));





    /////////////////////////save tests
    QAction *saveAct = new QAction(tr("Save"), this);
    mainMenu->addAction(saveAct);
    QObject::connect(saveAct, SIGNAL(triggered()), this, SLOT(savePluginHosts()));
    ////////////////////////////


    /////////////////////////style sheet load
    QAction *styleAct = new QAction(tr("Load Style Sheet"), this);
    mainMenu->addAction(styleAct);
    QObject::connect(styleAct, SIGNAL(triggered()), this, SLOT(openStyleSheet()));
    ////////////////////////////

    /////////////////////////style sheet reload
    QAction *restyleAct = new QAction(tr("Reload Style Sheet"), this);
    mainMenu->addAction(restyleAct);
    QObject::connect(restyleAct, SIGNAL(triggered()), this, SLOT(loadStyleSheet()));
    ////////////////////////////


    //settings toolbar buttons:
    RPushButton *settingsOKButton = new RPushButton(tr("OK"));
    settingsOKButton->setObjectName("rackSettingsOKButton");

    RPushButton *settingsCancelButton = new RPushButton(tr("Cancel"));
    settingsCancelButton->setObjectName("rackSettingsCancelButton");

    //settings toolbar:
    QToolBar *settingsToolBar = new QToolBar;
    settingsToolBar->setObjectName("rackSettingsToolBar");
    settingsToolBar->setMovable(false);
    settingsToolBar->addWidget(settingsOKButton);
    settingsToolBar->addWidget(settingsCancelButton);

    //settings toolbar signals & slots:
    QObject::connect(settingsOKButton, SIGNAL(clicked()), SIGNAL(leaveSettingsMode()));
    QObject::connect(this, SIGNAL(enterSettingsMode()), settingsToolBar, SLOT(show()));
    QObject::connect(this, SIGNAL(leaveSettingsMode()), settingsToolBar, SLOT(hide()));

    //add toolbars to mainwindow:
    addToolBar(Qt::BottomToolBarArea, mainToolBar);
    addToolBar(Qt::BottomToolBarArea, settingsToolBar);
}