Example #1
0
void
ActionCollection::togglePrivateListeningMode()
{
    tDebug() << Q_FUNC_INFO;
    if ( TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening )
        TomahawkSettings::instance()->setPrivateListeningMode( TomahawkSettings::FullyPrivate );
    else
        TomahawkSettings::instance()->setPrivateListeningMode( TomahawkSettings::PublicListening );

    QAction *privacyToggle = m_actionCollection[ "togglePrivacy" ];
    bool isPublic = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening;
    privacyToggle->setText( ( isPublic ? tr( "&Listen Privately" ) : tr( "&Listen Publicly" ) ) );
    privacyToggle->setIconVisibleInMenu( isPublic );

    emit privacyModeChanged();
}
Example #2
0
Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
{
    OverrideableAction *a = 0;
    const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);

    if (CommandPrivate * c = m_idCmdMap.value(uid, 0)) {
        a = qobject_cast<OverrideableAction *>(c);
        if (!a) {
            qWarning() << "registerAction: id" << id << "is registered with a different command type.";
            return c;
        }
    } else {
        a = new OverrideableAction(uid);
        m_idCmdMap.insert(uid, a);
    }

    if (!a->action()) {
        QAction *baseAction = new QAction(m_mainWnd);
        baseAction->setObjectName(id);
        baseAction->setCheckable(action->isCheckable());
        baseAction->setIcon(action->icon());
        baseAction->setIconText(action->iconText());
        baseAction->setText(action->text());
        baseAction->setToolTip(action->toolTip());
        baseAction->setStatusTip(action->statusTip());
        baseAction->setWhatsThis(action->whatsThis());
        baseAction->setChecked(action->isChecked());
        baseAction->setSeparator(action->isSeparator());
        baseAction->setShortcutContext(Qt::ApplicationShortcut);
        baseAction->setEnabled(false);
        baseAction->setParent(m_mainWnd);
#ifdef Q_WS_MAC
        baseAction->setIconVisibleInMenu(false);
#endif
        a->setAction(baseAction);
        m_mainWnd->addAction(baseAction);
        a->setKeySequence(a->keySequence());
        a->setDefaultKeySequence(QKeySequence());
    } else if (checkUnique) {
        qWarning() << "registerOverridableAction: id" << id << "is already registered.";
    }

    return a;
}
Example #3
0
void
ActionCollection::initActions()
{
    QAction *latchOn = new QAction( tr( "&Listen Along" ), this );
    latchOn->setIcon( QIcon( RESPATH "images/headphones-sidebar.png" ) );
    m_actionCollection[ "latchOn" ] = latchOn;
    QAction *latchOff = new QAction( tr( "Stop &Listening Along" ), this );
    latchOff->setIcon( QIcon( RESPATH "images/headphones-off.png" ) );
    m_actionCollection[ "latchOff" ] = latchOff;

    QAction *realtimeFollowingAlong = new QAction( tr( "&Follow in real-time" ), this );
    realtimeFollowingAlong->setCheckable( true );
    m_actionCollection[ "realtimeFollowingAlong" ] = realtimeFollowingAlong;

    bool isPublic = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening;
    QAction *privacyToggle = new QAction( ( isPublic ? tr( "&Listen Privately" ) : tr( "&Listen Publicly" ) ), this );
    privacyToggle->setIcon( QIcon( RESPATH "images/private-listening.png" ) );
    privacyToggle->setIconVisibleInMenu( isPublic );
    m_actionCollection[ "togglePrivacy" ] = privacyToggle;
    connect( m_actionCollection[ "togglePrivacy" ], SIGNAL( triggered() ), SLOT( togglePrivateListeningMode() ), Qt::UniqueConnection );

    m_actionCollection[ "loadPlaylist" ] = new QAction( tr( "&Load Playlist" ), this );
    m_actionCollection[ "renamePlaylist" ] = new QAction( tr( "&Rename Playlist" ), this );
    m_actionCollection[ "copyPlaylist" ] = new QAction( tr( "&Copy Playlist Link" ), this );
    m_actionCollection[ "playPause" ] = new QAction( tr( "&Play" ), this );
    m_actionCollection[ "stop" ] = new QAction( tr( "&Stop" ), this );
    m_actionCollection[ "previousTrack" ] = new QAction( tr( "&Previous Track" ), this );
    m_actionCollection[ "nextTrack" ] = new QAction( tr( "&Next Track" ), this );
    m_actionCollection[ "quit" ] = new QAction( tr( "&Quit" ), this );

    // connect actions to AudioEngine
    AudioEngine *ae = AudioEngine::instance();
    connect( m_actionCollection[ "playPause" ],     SIGNAL( triggered() ), ae,   SLOT( playPause() ), Qt::UniqueConnection );
    connect( m_actionCollection[ "stop" ],          SIGNAL( triggered() ), ae,   SLOT( stop() ),      Qt::UniqueConnection );
    connect( m_actionCollection[ "previousTrack" ], SIGNAL( triggered() ), ae,   SLOT( previous() ),  Qt::UniqueConnection );
    connect( m_actionCollection[ "nextTrack" ],     SIGNAL( triggered() ), ae,   SLOT( next() ),      Qt::UniqueConnection );
}
Example #4
0
void
ActionCollection::initActions()
{
    QAction *latchOn = new QAction( tr( "&Listen Along" ), this );
    latchOn->setIcon( ImageRegistry::instance()->icon( RESPATH "images/headphones.svg" ) );
    m_actionCollection[ "latchOn" ] = latchOn;
    QAction *latchOff = new QAction( tr( "Stop &Listening Along" ), this );
    latchOff->setIcon( ImageRegistry::instance()->icon( RESPATH "images/headphones-off.svg" ) );
    m_actionCollection[ "latchOff" ] = latchOff;

    QAction *realtimeFollowingAlong = new QAction( tr( "&Follow in real-time" ), this );
    realtimeFollowingAlong->setCheckable( true );
    m_actionCollection[ "realtimeFollowingAlong" ] = realtimeFollowingAlong;

    bool isPublic = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening;
    QAction *privacyToggle = new QAction( ( isPublic ? tr( "&Listen Privately" ) : tr( "&Listen Publicly" ) ), this );
    privacyToggle->setIcon( ImageRegistry::instance()->icon( RESPATH "images/private-listening.svg" ) );
    privacyToggle->setIconVisibleInMenu( isPublic );
    m_actionCollection[ "togglePrivacy" ] = privacyToggle;
    connect( m_actionCollection[ "togglePrivacy" ], SIGNAL( triggered() ), SLOT( togglePrivateListeningMode() ), Qt::UniqueConnection );

    m_actionCollection[ "loadPlaylist" ] =   new QAction( tr( "&Load Playlist" ), this );
    m_actionCollection[ "loadStation" ] =    new QAction( tr( "&Load Station" ), this );
    m_actionCollection[ "renamePlaylist" ] = new QAction( tr( "&Rename Playlist" ), this );
    m_actionCollection[ "renameStation" ] = new QAction( tr( "&Rename Station" ), this );
    m_actionCollection[ "copyPlaylist" ] =   new QAction( tr( "&Copy Playlist Link" ), this );
    m_actionCollection[ "playPause" ] =      new QAction( tr( "&Play" ), this );
    m_actionCollection[ "playPause" ]->setIcon( ImageRegistry::instance()->icon( RESPATH "images/play-rest.svg" ) );
    m_actionCollection[ "playPause" ]->setShortcut( Qt::Key_Space );
    m_actionCollection[ "playPause" ]->setShortcutContext( Qt::ApplicationShortcut );
    m_actionCollection[ "stop" ] =           new QAction( tr( "&Stop" ), this );
    m_actionCollection[ "previousTrack" ] =  new QAction( tr( "&Previous Track" ), this );
    m_actionCollection[ "previousTrack" ]->setIcon( ImageRegistry::instance()->icon( RESPATH "images/back-rest.svg" ) );
    m_actionCollection[ "nextTrack" ] =      new QAction( tr( "&Next Track" ), this );
    m_actionCollection[ "nextTrack" ]->setIcon( ImageRegistry::instance()->icon( RESPATH "images/skip-rest.svg" ) );
    m_actionCollection[ "quit" ] =           new QAction( tr( "&Quit" ), this );
    m_actionCollection[ "quit" ]->setShortcut( QKeySequence::Quit );
    m_actionCollection[ "quit" ]->setShortcutContext( Qt::ApplicationShortcut );
    m_actionCollection[ "quit" ]->setMenuRole( QAction::QuitRole );

    // connect actions to AudioEngine
    AudioEngine *ae = AudioEngine::instance();
    connect( m_actionCollection[ "playPause" ],     SIGNAL( triggered() ), ae,   SLOT( playPause() ), Qt::UniqueConnection );
    connect( m_actionCollection[ "stop" ],          SIGNAL( triggered() ), ae,   SLOT( stop() ),      Qt::UniqueConnection );
    connect( m_actionCollection[ "previousTrack" ], SIGNAL( triggered() ), ae,   SLOT( previous() ),  Qt::UniqueConnection );
    connect( m_actionCollection[ "nextTrack" ],     SIGNAL( triggered() ), ae,   SLOT( next() ),      Qt::UniqueConnection );

    // main menu actions
    m_actionCollection[ "loadXSPF" ] = new QAction( tr( "Load &XSPF..." ), this );
    m_actionCollection[ "updateCollection" ] = new QAction( tr( "U&pdate Collection" ), this );
    m_actionCollection[ "rescanCollection" ] = new QAction( tr( "Fully &Rescan Collection" ), this );
    m_actionCollection[ "showOfflineSources" ] = new QAction( tr( "Show Offline Sources" ), this );
    m_actionCollection[ "showOfflineSources" ]->setCheckable( true );
    m_actionCollection[ "preferences" ] = new QAction( tr( "&Configure Tomahawk..." ), this );
    m_actionCollection[ "preferences" ]->setIcon( ImageRegistry::instance()->icon( RESPATH "images/configure.svg" ) );
    m_actionCollection[ "preferences" ]->setMenuRole( QAction::PreferencesRole );
#ifdef Q_OS_MAC
    m_actionCollection[ "minimize" ] = new QAction( tr( "Minimize" ), this );
    m_actionCollection[ "minimize" ]->setShortcut( QKeySequence( "Ctrl+M" ) );
    m_actionCollection[ "zoom" ] = new QAction( tr( "Zoom" ), this );
    m_actionCollection[ "zoom" ]->setShortcut( QKeySequence( "Meta+Ctrl+Z" ) );
    m_actionCollection[ "fullscreen" ] = new QAction( tr( "Enter Full Screen" ), this );
    m_actionCollection[ "fullscreen" ]->setShortcut( QKeySequence( "Meta+Ctrl+F" ) );
#else
    m_actionCollection[ "toggleMenuBar" ] = new QAction( tr( "Hide Menu Bar" ), this );
    m_actionCollection[ "toggleMenuBar" ]->setShortcut( QKeySequence( "Ctrl+M" ) );
    m_actionCollection[ "toggleMenuBar" ]->setShortcutContext( Qt::ApplicationShortcut );
#endif
    m_actionCollection[ "diagnostics" ] = new QAction( tr( "Diagnostics..." ), this );
    m_actionCollection[ "diagnostics" ]->setMenuRole( QAction::ApplicationSpecificRole );
    m_actionCollection[ "aboutTomahawk" ] = new QAction( tr( "About &Tomahawk..." ), this );
    m_actionCollection[ "aboutTomahawk" ]->setIcon( ImageRegistry::instance()->icon( RESPATH "images/info.svg" ) );
    m_actionCollection[ "aboutTomahawk" ]->setMenuRole( QAction::AboutRole );
    m_actionCollection[ "legalInfo" ] = new QAction( tr( "&Legal Information..." ), this );
    m_actionCollection[ "legalInfo" ]->setMenuRole( QAction::ApplicationSpecificRole );
    m_actionCollection[ "openLogfile" ] = new QAction( tr( "&View Logfile" ), this );
    m_actionCollection[ "openLogfile" ]->setMenuRole( QAction::ApplicationSpecificRole );
    #if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE ) || defined( Q_WS_WIN )
    m_actionCollection[ "checkForUpdates" ] = new QAction( tr( "Check For Updates..." ), this );
    m_actionCollection[ "checkForUpdates" ]->setMenuRole( QAction::ApplicationSpecificRole );
#endif
    m_actionCollection[ "crashNow" ] = new QAction( "Crash now...", this );
}
Example #5
0
TilesetEditor::TilesetEditor(QObject *parent)
    : Editor(parent)
    , mMainWindow(new TilesetEditorWindow(this))
    , mMainToolBar(new MainToolBar(mMainWindow))
    , mWidgetStack(new QStackedWidget(mMainWindow))
    , mAddTiles(new QAction(this))
    , mRemoveTiles(new QAction(this))
    , mShowAnimationEditor(new QAction(this))
    , mPropertiesDock(new PropertiesDock(mMainWindow))
    , mUndoDock(new UndoDock(mMainWindow))
    , mTerrainDock(new TerrainDock(mMainWindow))
    , mTileCollisionDock(new TileCollisionDock(mMainWindow))
    , mWangDock(new WangDock(mMainWindow))
    , mZoomComboBox(new QComboBox)
    , mStatusInfoLabel(new QLabel)
    , mTileAnimationEditor(new TileAnimationEditor(mMainWindow))
    , mCurrentTilesetDocument(nullptr)
    , mCurrentTile(nullptr)
{
#if QT_VERSION >= 0x050600
    mMainWindow->setDockOptions(mMainWindow->dockOptions() | QMainWindow::GroupedDragging);
#endif
    mMainWindow->setDockNestingEnabled(true);
    mMainWindow->setCentralWidget(mWidgetStack);

    QAction *editTerrain = mTerrainDock->toggleViewAction();
    QAction *editCollision = mTileCollisionDock->toggleViewAction();
    QAction *editWang = mWangDock->toggleViewAction();

    mAddTiles->setIcon(QIcon(QLatin1String(":images/16x16/add.png")));
    mRemoveTiles->setIcon(QIcon(QLatin1String(":images/16x16/remove.png")));
    mShowAnimationEditor->setIcon(QIcon(QLatin1String(":images/24x24/animation-edit.png")));
    mShowAnimationEditor->setCheckable(true);
    mShowAnimationEditor->setIconVisibleInMenu(false);
    editTerrain->setIcon(QIcon(QLatin1String(":images/24x24/terrain.png")));
    editTerrain->setIconVisibleInMenu(false);
    editCollision->setIcon(QIcon(QLatin1String(":images/48x48/tile-collision-editor.png")));
    editCollision->setIconVisibleInMenu(false);
    editWang->setIcon(QIcon(QLatin1String(":images/24x24/wangtile.png")));
    editWang->setIconVisibleInMenu(false);

    Utils::setThemeIcon(mAddTiles, "add");
    Utils::setThemeIcon(mRemoveTiles, "remove");

    mTilesetToolBar = mMainWindow->addToolBar(tr("Tileset"));
    mTilesetToolBar->setObjectName(QLatin1String("TilesetToolBar"));
    mTilesetToolBar->addAction(mAddTiles);
    mTilesetToolBar->addAction(mRemoveTiles);
    mTilesetToolBar->addSeparator();
    mTilesetToolBar->addAction(editTerrain);
    mTilesetToolBar->addAction(editCollision);
    mTilesetToolBar->addAction(editWang);
    mTilesetToolBar->addAction(mShowAnimationEditor);

    mMainWindow->statusBar()->addPermanentWidget(mZoomComboBox);
    mMainWindow->statusBar()->addWidget(mStatusInfoLabel);

    resetLayout();

    connect(mMainWindow, &TilesetEditorWindow::urlsDropped, this, &TilesetEditor::addTiles);

    connect(mWidgetStack, &QStackedWidget::currentChanged, this, &TilesetEditor::currentWidgetChanged);

    connect(mAddTiles, &QAction::triggered, this, &TilesetEditor::openAddTilesDialog);
    connect(mRemoveTiles, &QAction::triggered, this, &TilesetEditor::removeTiles);

    connect(editTerrain, &QAction::toggled, this, &TilesetEditor::setEditTerrain);
    connect(editCollision, &QAction::toggled, this, &TilesetEditor::setEditCollision);
    connect(editWang, &QAction::toggled, this, &TilesetEditor::setEditWang);
    connect(mShowAnimationEditor, &QAction::toggled, mTileAnimationEditor, &TileAnimationEditor::setVisible);

    connect(mTileAnimationEditor, &TileAnimationEditor::closed, this, &TilesetEditor::onAnimationEditorClosed);

    connect(mTerrainDock, &TerrainDock::currentTerrainChanged, this, &TilesetEditor::currentTerrainChanged);
    connect(mTerrainDock, &TerrainDock::addTerrainTypeRequested, this, &TilesetEditor::addTerrainType);
    connect(mTerrainDock, &TerrainDock::removeTerrainTypeRequested, this, &TilesetEditor::removeTerrainType);

    connect(mWangDock, &WangDock::currentWangSetChanged, this, &TilesetEditor::currentWangSetChanged);
    connect(mWangDock, &WangDock::currentWangIdChanged, this, &TilesetEditor::currentWangIdChanged);
    connect(mWangDock, &WangDock::wangColorChanged, this, &TilesetEditor::wangColorChanged);
    connect(mWangDock, &WangDock::addWangSetRequested, this, &TilesetEditor::addWangSet);
    connect(mWangDock, &WangDock::removeWangSetRequested, this, &TilesetEditor::removeWangSet);
    connect(mWangDock->wangColorView(), &WangColorView::wangColorColorPicked,
            this, &TilesetEditor::setWangColorColor);

    connect(this, &TilesetEditor::currentTileChanged,
            mTileAnimationEditor, &TileAnimationEditor::setTile);
    connect(this, &TilesetEditor::currentTileChanged,
            mTileCollisionDock, &TileCollisionDock::setTile);

    connect(mTileCollisionDock, &TileCollisionDock::dummyMapDocumentChanged,
            this, [this]() {
        mPropertiesDock->setDocument(mCurrentTilesetDocument);
    });
    connect(mTileCollisionDock, &TileCollisionDock::hasSelectedObjectsChanged,
            this, &TilesetEditor::hasSelectedCollisionObjectsChanged);
    connect(mTileCollisionDock, &TileCollisionDock::statusInfoChanged,
            mStatusInfoLabel, &QLabel::setText);
    connect(mTileCollisionDock, &TileCollisionDock::visibilityChanged,
            this, &Editor::enabledStandardActionsChanged);

    connect(TilesetManager::instance(), &TilesetManager::tilesetImagesChanged,
            this, &TilesetEditor::updateTilesetView);

    retranslateUi();
    connect(Preferences::instance(), &Preferences::languageChanged, this, &TilesetEditor::retranslateUi);
}
Example #6
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QAction *qaAction;
    QMenu *menMain = new QMenu();

    QMenu *menPref = new QMenu();
    QMenu *menAcc = new QMenu();
    QMenu *menDevel = new QMenu();
    QMenu *menEdu = new QMenu();
    QMenu *menGraph = new QMenu();
    QMenu *menHam = new QMenu();
    QMenu *menInter = new QMenu();
    QMenu *menMulti = new QMenu();
    QMenu *menOffic = new QMenu();
    QMenu *menOth = new QMenu();
    QMenu *menSci = new QMenu();
    QMenu *menSys = new QMenu();

    QDesktopWidget *qDesktop = new QDesktopWidget();
    QRect qrDesktop = qDesktop->availableGeometry();
    QFile file(QDir::homePath() + "/.qtmenu");
    QString strProcess;
    QString strForeColor;
    QString strBackColor;
    int nLeft = -1;
    int nTop = -1;

    QDir qdDir = QDir(strSysApps);
    QFileInfoList qflList = qdDir.entryInfoList();

    QString strRunCommand = "fbrun -nearmouse";
    QString strExitCommand = "fluxbox-remote quit";
    QString strRebootCommand = "sudo reboot";
    QString strPoweroffCommand = "sudo poweroff";
    QStringList strlistCustoms;
    QString strTheme;

    bool blShowGNOME = true;
    bool blShowLXDE = true;
    bool blShowKDE = true;
    bool blShowMATE = true;
    bool blShowXFCE = true;


    QList<MenuListItem> mliList;
    MenuListItem mliListTemp;
    QMenu *menTemp;
    int nCount = qflList.count() - 1;
    bool blFirstLoop = true;
    bool blHasCustoms = false;

    bool blIconHasPath = false;
    bool blIconHasExt = false;

    // process config file
    if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        while (!file.atEnd())
        {
            strProcess = file.readLine().trimmed();

            // left positioning
            if (strProcess.toLower().startsWith("left=")) {
                strProcess.remove(0, 5);
                nLeft = strProcess.toInt();
            } else
            // top positioning
            if (strProcess.toLower().startsWith("top=")) {
                strProcess.remove(0, 4);
                nTop = strProcess.toInt();
            } else
            // custom menu items
            if (strProcess.toLower().startsWith("custom=")) {
                strProcess.remove(0, 7);
                strlistCustoms.append(strProcess);
            } else
            // theme
            if (strProcess.toLower().startsWith("icontheme=")) {
                strProcess.remove(0, 10);
                strTheme = strProcess;
            } else
            // foreground
            if (strProcess.toLower().startsWith("fg=")) {
                strProcess.remove(0, 3);
                if (strProcess != "") {
                    strForeColor = strProcess;
                }
            } else
            // background
            if (strProcess.toLower().startsWith("bg=")) {
                strProcess.remove(0, 3);
                if (strProcess != "") {
                    strBackColor = strProcess;
                }
            } else
            // show gnome items?
            if (strProcess.toLower().startsWith("showgnomeitems=")) {
                strProcess.remove(0, 15);
                if (strProcess.contains("true") ) {
                    blShowGNOME = true;
                } else {
                    blShowGNOME = false;
                }
            } else
            // show lxde items?
            if (strProcess.toLower().startsWith("showlxdeitems=")) {
                strProcess.remove(0, 14);
                if (strProcess.contains("true") ) {
                    blShowLXDE = true;
                } else {
                    blShowLXDE = false;
                }
            } else
            // show kde items?
            if (strProcess.toLower().startsWith("showkdeitems=")) {
                strProcess.remove(0, 14);
                if (strProcess.contains("true") ) {
                    blShowKDE = true;
                } else {
                    blShowKDE = false;
                }
            } else
            // show mate items?
            if (strProcess.toLower().startsWith("showmateitems=")) {
                strProcess.remove(0, 14);
                if (strProcess.contains("true") ) {
                    blShowMATE = true;
                } else {
                    blShowMATE = false;
                }
            } else
            // show xfce items?
            if (strProcess.toLower().startsWith("showxfceitems=")) {
                strProcess.remove(0, 14);
                if (strProcess.contains("true") ) {
                    blShowXFCE = true;
                } else {
                    blShowXFCE = false;
                }
            } else
            // run command
            if (strProcess.toLower().startsWith("runcommand=")) {
                strProcess.remove(0, 11);
                if (strProcess != "") {
                    strRunCommand = strProcess;
                }
            } else
            // exit command
            if (strProcess.toLower().startsWith("exitcommand=")) {
                strProcess.remove(0, 12);
                if (strProcess != "") {
                    strExitCommand = strProcess;
                }
            } else
            // reboot command
            if (strProcess.toLower().startsWith("restartcommand=")) {
                strProcess.remove(0, 15);
                if (strProcess != "") {
                    strRebootCommand = strProcess;
                }
            } else
            // poweroff command
            if (strProcess.toLower().startsWith("poweroffcommand=")) {
                strProcess.remove(0, 16);
                if (strProcess != "") {
                    strPoweroffCommand = strProcess;
                }
            }
        }
    }

    // set icon theme
    if (strTheme != "") {
        QIcon::setThemeName(strTheme);
    } else {
        QIcon::setThemeName("hicolor");
    }

    // custom menu items from config file
    for (int n = 0; n < strlistCustoms.count(); n++)
    {
        MenuListItem mi;

        strProcess = strlistCustoms.at(n);
        mi.strName = strProcess.section("|", 0, 0);
        mi.strExec = strProcess.section("|", 1, 1);
        mi.strIcon = strProcess.section("|", 2, 2);
        mi.strCategory = "CustomItems";

        mliList.append(mi);

        blHasCustoms = true;
    }

    // read desktop files and insert menu items
    for (int n = 0; n < nCount;)
    {
        QFileInfo fileInfo = qflList.at(n);
        QFile qfFile(fileInfo.absoluteFilePath());
        MenuListItem mi;
        bool blNoShow = false;
        bool blOkToParse = false;

        if (qfFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
            while (!qfFile.atEnd())
            {
                strProcess = qfFile.readLine();

                // set parse flag if we are in the Desktop Entry section
                if (strProcess.startsWith("[") && strProcess.contains("Desktop Entry")) {
                    blOkToParse = true;
                }
                if (blOkToParse) {
                    // app name
                    if (strProcess.startsWith("Name=")) {
                        strProcess.remove(0,5);
                        mi.strName = strProcess.trimmed().remove("_");
                    } else
                    // app icon
                    if (strProcess.startsWith("Icon=")) {
                        strProcess.remove(0,5);
                        mi.strIcon = strProcess.trimmed();
                    } else
                    // app exec line
                    if (strProcess.startsWith("Exec=")) {
                        strProcess.remove(0,5);
                        mi.strExec = strProcess.trimmed();
                        mi.strExec.remove("%F");
                        mi.strExec.remove("%f");
                        mi.strExec.remove("%U");
                        mi.strExec.remove("%u");
                    } else
                    // app category
                    if (strProcess.startsWith("Categories=")) {
                        if (blFirstLoop) {
                            strProcess.remove(0,11);
                            mi.strCategory = strProcess.trimmed();
                        } else {
                            mi.strCategory = "Other";
                        }
                    } else
                    // needs terminal?
                    if (strProcess.startsWith("Terminal=")) {
                        strProcess.remove(0,9);

                        if (strProcess.toLower().contains("true")) {
                            mi.blNeedsTerminal = true;
                        } else {
                            mi.blNeedsTerminal = false;
                        }
                    } else
                    // don't display?
                    if (strProcess.startsWith("NoDisplay=")) {
                        strProcess.remove(0,10);
                        if (strProcess.contains("True") ||
                           strProcess.contains("true")
                           ) {
                            blNoShow = true;
                        }
                    } else
                    // show gnome stuff?
                    if (strProcess.contains("OnlyShowIn=GNOME")) {
                        if (blShowGNOME == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // show lxde stuff?
                    if (strProcess.contains("OnlyShowIn=LXDE")) {
                        if (blShowLXDE == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // show kde stuff?
                    if (strProcess.contains("OnlyShowIn=KDE")) {
                        if (blShowKDE == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // show mate stuff?
                    if (strProcess.contains("OnlyShowIn=MATE")) {
                        if (blShowMATE == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // show xfce stuff?
                    if (strProcess.contains("OnlyShowIn=XFCE")) {
                        if (blShowXFCE == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // stop parsing if there are other sections
                    if (strProcess.startsWith("[") && !strProcess.contains("Desktop Entry")) {
                        break;
                    }
                }
            }

            if (mi.strName != "" && !blNoShow) {
                if (mi.blNeedsTerminal) {
                    mi.strExec = "x-terminal-emulator -e " + mi.strExec;
                }
                mliList.append(mi);
            }

        }

        if (qfFile.isOpen()) {
            qfFile.close();
        }

        // switch to local app folder and start over
        if (n == (nCount - 1) && blFirstLoop) {
            qdDir = QDir(QDir::homePath() + "/.local/share/applications");
            qflList = qdDir.entryInfoList();
            nCount = qflList.count() - 1;
            n = 0;
            blFirstLoop = false;
            QApplication::beep();
        } else {
            n++;
        }
    }


    // sort items alphabetically
    qSort(mliList);

    // set up category sub-menus
    menPref->setIcon(QIcon::fromTheme("preferences-desktop", QIcon::fromTheme("document-send")));
    menPref->setTitle("Preferences");
    menAcc->setIcon(QIcon::fromTheme("applications-accessories", QIcon::fromTheme("document-send")));
    menAcc->setTitle("Accessories");
    menDevel->setIcon(QIcon::fromTheme("applications-development", QIcon::fromTheme("document-send")));
    menDevel->setTitle("Development");
    menEdu->setIcon(QIcon::fromTheme("applications-science", QIcon::fromTheme("document-send")));
    menEdu->setTitle("Education");
    menGraph->setIcon(QIcon::fromTheme("applications-graphics", QIcon::fromTheme("document-send")));
    menGraph->setTitle("Graphics");
    menHam->setIcon(QIcon::fromTheme("applications-other", QIcon::fromTheme("document-send")));
    menHam->setTitle("Ham Radio");
    menInter->setIcon(QIcon::fromTheme("applications-internet", QIcon::fromTheme("document-send")));
    menInter->setTitle("Network");
    menMulti->setIcon(QIcon::fromTheme("applications-multimedia", QIcon::fromTheme("document-send")));
    menMulti->setTitle("Multimedia");
    menOffic->setIcon(QIcon::fromTheme("applications-office", QIcon::fromTheme("document-send")));
    menOffic->setTitle("Office");
    menOth->setIcon(QIcon::fromTheme("applications-other", QIcon::fromTheme("document-send")));
    menOth->setTitle("Other");
    menSci->setIcon(QIcon::fromTheme("applications-science", QIcon::fromTheme("document-send")));
    menSci->setTitle("Science");
    menSys->setIcon(QIcon::fromTheme("applications-system", QIcon::fromTheme("document-send")));
    menSys->setTitle("System");


    // *** collate by standard categories ***
    for (int i = mliList.size() - 1; i > -1; --i) {

        menTemp = menOth;

        mliListTemp = mliList.at(i);

        // custom items
        if (mliListTemp.strCategory.contains("CustomItems")) {
            menTemp = menMain;
        } else
        // settings / preferences
        if (mliListTemp.strCategory.contains("=Settings") ||
            mliListTemp.strCategory.contains(";Settings")
           ) {
            menTemp = menPref;
        } else
        // system
        if (mliListTemp.strCategory.contains("System")) {
            menTemp = menSys;
        } else
        // hamradio
        if (mliListTemp.strCategory.contains("HamRadio")) {
            menTemp = menHam;
        } else
        // science
        if (mliListTemp.strCategory.contains("Science")) {
            menTemp = menSci;
        } else
        // accessories / utility
        if (mliListTemp.strCategory.contains("Accessories") ||
            mliListTemp.strCategory.contains("Utility")
           ) {
            menTemp = menAcc;
        } else
        // development / programming
        if (mliListTemp.strCategory.contains("Development")) {
            menTemp = menDevel;
        } else
        // education / science
        if (mliListTemp.strCategory.contains("Education") ||
            mliListTemp.strCategory.contains("Science")
           ) {
            menTemp = menEdu;
        } else
        // graphics
        if (mliListTemp.strCategory.contains("Graphics")) {
            menTemp = menGraph;
        } else
        // internet / network
        if (mliListTemp.strCategory.contains("Internet") ||
                mliListTemp.strCategory.contains("WebBrowser") ||
                mliListTemp.strCategory.contains("Network")
                )
        {
            menTemp = menInter;
        } else

        // multimedia / sound/video
        if (mliListTemp.strCategory.contains("Audio") ||
                mliListTemp.strCategory.contains("AudioVideo") ||
                mliListTemp.strCategory.contains("Multimedia")
                )
        {
            menTemp = menMulti;
        } else
        // office / productivity
        if (mliListTemp.strCategory.contains("Office")  ||
                mliListTemp.strCategory.contains("Productivity")  ||
                mliListTemp.strCategory.contains("WordProcessor")
                )
        {
            menTemp = menOffic;
        }

        /* insert into menu */
        qaAction = new QAction(mliListTemp.strName, NULL);

        // figure out icon
        blIconHasExt = false;
        blIconHasPath = false;

        // has path
        if (mliListTemp.strIcon.contains("/")) {
            blIconHasPath = true;
        }

        // has extension
        if (mliListTemp.strIcon.contains(".png") ||
            mliListTemp.strIcon.contains(".xpm") ||
            mliListTemp.strIcon.contains(".svg")
            ) {
                blIconHasExt = true;
        }

        // no path and no extension
        if (blIconHasExt == false && blIconHasPath == false) {
            qaAction->setIcon(QIcon::fromTheme(mliListTemp.strIcon));
        } else
        // path
        if (blIconHasPath == true) {
            qaAction->setIcon(QIcon(mliListTemp.strIcon));
        } else
        // extension but no path
        if (blIconHasExt == true && blIconHasPath == false) {
            qaAction->setIcon(QIcon::fromTheme(mliListTemp.strIcon));
        }

        if (qaAction->icon().isNull()) {
            if (file.exists(strSysPix + "/" + mliListTemp.strIcon)) {
                qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon));
            } else
            if (file.exists(strSysIco + "/" + mliListTemp.strIcon + ".png")) {
                qaAction->setIcon(QIcon(strSysIco + "/" + mliListTemp.strIcon + ".png"));
            } else
            if (file.exists(strSysIco + "/hicolor/scalable/apps/" + mliListTemp.strIcon + ".svg")) {
                qaAction->setIcon(QIcon(strSysIco + "/hicolor/scalable/apps/" + mliListTemp.strIcon + ".svg"));
            } else
            if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".png")) {
                qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".png"));
            } else
            if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".xpm")) {
                qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".xpm"));
            } else
            if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".svg")) {
                qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".svg"));
            }
        }

        qaAction->setIconVisibleInMenu(true);
        qaAction->setData(mliListTemp.strExec);

        menTemp->addAction(qaAction);
    }


    // add separator if there are customs
    if (blHasCustoms) {
        menMain->addSeparator();
    }

    // preferences
    if (menPref->actions().count() > 0) {
        menMain->addMenu(menPref);
        menMain->addSeparator();
    }

    // accessories
    if (menAcc->actions().count() > 0) {
        menMain->addMenu(menAcc);
    }

    // development
    if (menDevel->actions().count() > 0) {
        menMain->addMenu(menDevel);
    }

    // education
    if (menEdu->actions().count() > 0) {
        menMain->addMenu(menEdu);
    }

    // graphics
    if (menGraph->actions().count() > 0) {
        menMain->addMenu(menGraph);
    }

    // ham radio
    if (menHam->actions().count() > 0) {
        menMain->addMenu(menHam);
    }

    // internet/networking
    if (menInter->actions().count() > 0) {
        menMain->addMenu(menInter);
    }

    // multimedia / sound/video
    if (menMulti->actions().count() > 0) {
        menMain->addMenu(menMulti);
    }

    // office
    if (menOffic->actions().count() > 0) {
        menMain->addMenu(menOffic);
    }

    // other
    if (menOth->actions().count() > 0) {
        menMain->addMenu(menOth);
    }

    // science
    if (menSci->actions().count() > 0) {
        menMain->addMenu(menSci);
    }

    // system
    if (menSys->actions().count() > 0) {
        menMain->addMenu(menSys);
    }

    menMain->addSeparator();

    qaAction = new QAction("About...", NULL);
    qaAction->setData("...about...");
    qaAction->setIcon(QIcon::fromTheme("dialog-information"));
    menMain->addAction(qaAction);

    menMain->addSeparator();

    qaAction = new QAction("Run...", NULL);
    qaAction->setData(strRunCommand);
    menMain->addAction(qaAction);

    menMain->addSeparator();

    qaAction = new QAction("Exit", NULL);
    qaAction->setData(strExitCommand);
    qaAction->setIcon(QIcon::fromTheme("system-log-out"));
    menMain->addAction(qaAction);

    qaAction = new QAction("Reboot", NULL);
    qaAction->setData(strRebootCommand);
    qaAction->setIcon(QIcon::fromTheme("view-refresh"));
    menMain->addAction(qaAction);

    qaAction = new QAction("Shutdown", NULL);
    qaAction->setData(strPoweroffCommand);
    qaAction->setIcon(QIcon::fromTheme("system-shutdown"));
    menMain->addAction(qaAction);

    // set correct positioning
    if (nLeft == -1) {
        nLeft = qrDesktop.left();
    }

    if (nTop == -1) {
        nTop = qrDesktop.bottom();
    }

    // show menu
    qaAction = menMain->exec(QPoint(nLeft, nTop));

    // perform/run selected action
    if (qaAction != 0) {
        QString qsExec = qaAction->data().toString();
        if (qsExec == "...about...") {
            QMessageBox::about(NULL,
                               "About Qt Menu - Standalone",
                                "<h3>Qt Menu - Standalone</h3><br><br>"
                                "Copyright 2014 - Will Brokenbourgh<br>"
                                "Blog: http://www.pismotek.com/brainout/<br><br>"
                                "Version 0.1.1");
        } else {
            QProcess *qp = new QProcess();
            qp->setWorkingDirectory(QDir::homePath());
            qp->start(qsExec);
        }
    }
}
Example #7
0
// Note: the QDesktopViewWidget Class will become it's own widget
// so others can easly create there own desktopsor file managers with
// only a few lines of code
QDesktopViewWidget::QDesktopViewWidget(QWidget *parent) :
    QListWidget(parent)
{
    // This sets the QDesktopViewWidget(QListWidget) to transparent so that the
    // desktop wallpaper below it can be seen. Note: the color: white propertiy
    // needs to be moved to the desktop config file
    setStyleSheet("QListView {background-color: transparent; color: white;}");

    // Note: Need to check if config files exist, if it doesnt we need to
    // create it.

    // In the future the below QDesktopViewWidget settings will be wrapped
    // in this block of code so every aspect of how the desktop looks and feels
    // can be configured.

    // Note: Needs to be moved to a class function of it's own
    //desktopSettings = new QSettings("chipara", "desktop");
    //desktopSettings->beginGroup("desktop");
    //desktopSettings->endGroup();

    // Variouse settings for the QDesktopViewWidget(QListWidget) class
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setViewMode(QListView::IconMode);
    setSpacing(20);
    setFlow(QListView::TopToBottom);
    setMovement(QListView::Snap);
    setLayoutMode(QListView::Batched);
    setBatchSize(100);
    setMovement(QListView::Snap);
    setIconSize(QSize(48, 48));
    setUniformItemSizes(true);
    setWrapping(true);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setSortingEnabled(true);
    setLayoutDirection(Qt::LeftToRight);
    setSelectionRectVisible(true);
    setTextElideMode(Qt::ElideMiddle);
    setDragEnabled(true);
    setFrameStyle(0);
    setFrameShape(QFrame::NoFrame);
    setAutoScroll(true);
    setResizeMode(QListView::Adjust);

    // Right Click Desktop Menu
    menu = new QMenu(this);

    // Create submenu for Create Document
    QMenu *viewMenu = menu->addMenu(tr("&View"));
    QActionGroup *viewGroup = new QActionGroup(this);

    // Large Icons
    extraLargeIcons = new QAction(QIcon::fromTheme("folder"), "X-Large Icons", this);
    extraLargeIcons->setCheckable(true);
    viewGroup->addAction(extraLargeIcons);
    viewMenu->addAction(extraLargeIcons);
    connect(extraLargeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons()));

    // Large Icons
    largeIcons = new QAction(QIcon::fromTheme("folder"), "Large Icons", this);
    largeIcons->setCheckable(true);
    viewGroup->addAction(largeIcons);
    viewMenu->addAction(largeIcons);
    connect(largeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons()));

    // Medium Icons
    mediumIcons = new QAction(QIcon::fromTheme("folder"), "Medium Icons", this);
    mediumIcons->setCheckable(true);
    mediumIcons->setChecked(true);
    viewGroup->addAction(mediumIcons);
    viewMenu->addAction(mediumIcons);
    connect(mediumIcons, SIGNAL(triggered()), this, SLOT(resizeIcons()));

    // Medium Icons
    smallIcons = new QAction(QIcon::fromTheme("folder"), "Small Icons", this);
    smallIcons->setCheckable(true);
    viewGroup->addAction(smallIcons);
    viewMenu->addAction(smallIcons);
    connect(smallIcons, SIGNAL(triggered()), this, SLOT(resizeIcons()));

    // Add a separator to the menu
    viewMenu->addSeparator();

    QActionGroup *layoutGroup = new QActionGroup(this);
    // Medium Icons
    leftToRight = new QAction(QIcon::fromTheme("folder"), "Left To Right", this);
    leftToRight->setCheckable(true);
    layoutGroup->addAction(leftToRight);
    viewMenu->addAction(leftToRight);
    connect(leftToRight, SIGNAL(triggered()), this, SLOT(layoutDirection()));

    // Medium Icons
    rightToLeft = new QAction(QIcon::fromTheme("folder"), "Right To Left", this);
    rightToLeft->setCheckable(true);
    layoutGroup->addAction(rightToLeft);
    viewMenu->addAction(rightToLeft);
    connect(rightToLeft, SIGNAL(triggered()), this, SLOT(layoutDirection()));

    // Add a separator to the menu
    viewMenu->addSeparator();

    // Sort By Size
    showIcons = new QAction(QIcon::fromTheme("folder"), "Show Desktop Icons", this);
    showIcons->setCheckable(true);
    showIcons->setChecked(true);
    viewMenu->addAction(showIcons);
    connect(showIcons, SIGNAL(triggered()), this, SLOT(showDesktopIcons()));

    // Create submenu for Create Document
    QMenu *sortMenu = menu->addMenu(tr("&Sort By"));
    QActionGroup *sortGroup = new QActionGroup(this);

    // Sort By Name
    QAction *nameSort = new QAction(QIcon::fromTheme("folder"), "Name", this);
    nameSort->setCheckable(true);
    nameSort->setChecked(true);
    sortGroup->addAction(nameSort);
    sortMenu->addAction(nameSort);

    // Sort By Size
    QAction *sizeSort = new QAction(QIcon::fromTheme("folder"), "Size", this);
    sizeSort->setCheckable(true);
    sizeSort->setDisabled(true);
    sortGroup->addAction(sizeSort);
    sortMenu->addAction(sizeSort);

    // Sort By Size
    QAction *typeSort = new QAction(QIcon::fromTheme("folder"), "Item Type", this);
    typeSort->setCheckable(true);
    typeSort->setDisabled(true);
    sortGroup->addAction(typeSort);
    sortMenu->addAction(typeSort);

    // Sort By Size
    QAction *dateSort = new QAction(QIcon::fromTheme("folder"), "Date Modified", this);
    dateSort->setCheckable(true);
    dateSort->setDisabled(true);
    sortGroup->addAction(dateSort);
    sortMenu->addAction(dateSort);

    // Refresh
    QAction *refresh = new QAction(QIcon::fromTheme("folder"), "Refresh", this);
    menu->addAction(refresh);

    // Add a separator to the menu
    menu->addSeparator();

    // Paste
    QAction *paste = new QAction(QIcon::fromTheme("folder"), "Paste", this);
    paste->setEnabled(false);
    menu->addAction(paste);

    // Paste Shortcut
    QAction *pasteShortCut = new QAction(QIcon::fromTheme("folder"), "Paste Shortcut", this);
    pasteShortCut->setEnabled(false);
    menu->addAction(pasteShortCut);

    // Add a separator to the menu
    menu->addSeparator();

    // New Menu
    QMenu *create = menu->addMenu(tr("&New"));

    // Create Folder
    QAction *createFolder = new QAction(QIcon::fromTheme("folder"), tr("&Folder"), this);
    create->addAction(createFolder);
    createFolder->setIconVisibleInMenu(true);
    connect(createFolder, SIGNAL(triggered()), this, SLOT(createFolder()));

    // Create Launcher
    QAction *createLauncher = new QAction(QIcon::fromTheme("application-x-desktop"), tr("&Launcher"), this);
    create->addAction(createLauncher);
    createLauncher->setIconVisibleInMenu(true);
    connect(createLauncher, SIGNAL(triggered()), this, SLOT(createLauncher()));

    // Create Empty File
    QAction *createEmptyFile = new QAction(QIcon::fromTheme("text-plain"), tr("&Empty File"), this);
    create->addAction(createEmptyFile);
    createEmptyFile->setIconVisibleInMenu(true);
    connect(createEmptyFile, SIGNAL(triggered()), this, SLOT(createEmptyFile()));

    // Add a separator to the menu
    menu->addSeparator();

    // Paste
    QAction *desktopSettings = new QAction(QIcon::fromTheme("preferences-desktop"), "Desktop Settings", this);
    desktopSettings->setIconVisibleInMenu(true);
    menu->addAction(desktopSettings);
    connect(desktopSettings, SIGNAL(triggered()), this, SLOT(execDesktopSettings()));

    // Right Click Desktop Icon Menu
    iconMenu = new QIconMenu(this);

    //
    desktopDir = new QFileSystemWatcher;
    desktopDir->addPath(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));

    //
    dSettings = new QSettings("chipara", "desktop");
    dSettings->beginGroup("window");

    if (dSettings->value("showIcons") == 1) {
        showIcons->setChecked(true);
    } else {
        showIcons->setChecked(false);
    }

    //
    if (dSettings->value("layoutDirection") == 1) {
        setLayoutDirection(Qt::LeftToRight);
        leftToRight->setChecked(true);
    } else {
        setLayoutDirection(Qt::RightToLeft);
        rightToLeft->setChecked(true);
    }

    //
    if (dSettings->value("iconSize") == 1) {
        this->setIconSize(QSize(128, 128));
        extraLargeIcons->setChecked(true);
    } else if (dSettings->value("iconSize") == 2) {
        this->setIconSize(QSize(64, 64));
        largeIcons->setChecked(true);
    } else if (dSettings->value("iconSize") == 3) {
        this->setIconSize(QSize(48, 48));
        mediumIcons->setChecked(true);
    } else if (dSettings->value("iconSize") == 4) {
        this->setIconSize(QSize(36, 36));
        smallIcons->setChecked(true);
    }


    populatedDesktop();

    dSettings->endGroup();

    // Desktop Icon Double Click EventexecDesktopSettings
    connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(iconClicked(QListWidgetItem*)));
    connect(desktopDir, SIGNAL(directoryChanged(QString)), this, SLOT(populatedDesktop()));
}
Example #8
0
void TupMainWindow::setupMenu()
{
    // Setting up the file menu
    setupFileActions();

    // Menu File	
    m_fileMenu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(m_fileMenu);

    // Adding Option New	
    /*
    QMenu *newMenu = new QMenu(tr("&New"), this);
    newMenu->setIcon(QPixmap(THEME_DIR + "icons/file_new.png"));
    m_fileMenu->addMenu(newMenu);
    newMenu->addAction(m_actionManager->find("newproject"));
    newMenu->addSeparator();
    */

    m_fileMenu->addAction(m_actionManager->find("newproject"));
    m_fileMenu->addAction(m_actionManager->find("openproject"));
    m_fileMenu->addAction(m_actionManager->find("opennetproject"));
    m_fileMenu->addAction(m_actionManager->find("exportprojectserver"));

    // Adding Option Open Recent	
    m_recentProjectsMenu = new QMenu(tr("Recents"), this);
    // m_recentProjectsMenu->setIcon(QPixmap(THEME_DIR + "icons/recent_files.png"));

    TCONFIG->beginGroup("General");
    QStringList recents = TCONFIG->value("Recents").toString().split(';');
    updateOpenRecentMenu(m_recentProjectsMenu, recents);	
    m_fileMenu->addMenu(m_recentProjectsMenu);

    // Adding Options save, save as, close, export, import palettes and exit	
    m_fileMenu->addAction(m_actionManager->find("saveproject"));

    m_fileMenu->addAction(m_actionManager->find("saveprojectas"));
    m_fileMenu->addAction(m_actionManager->find("closeproject"));

    m_fileMenu->addSeparator();
    m_fileMenu->addAction(m_actionManager->find("export"));
    m_fileMenu->addSeparator();
    m_fileMenu->addAction(m_actionManager->find("ImportPalettes"));
    m_fileMenu->addSeparator();
    m_fileMenu->addAction(m_actionManager->find("Exit"));
    m_fileMenu->addSeparator();

    // Setting up the Settings menu
    setupSettingsActions();
    m_settingsMenu = new QMenu(tr("&Edit"), this);
    menuBar()->addMenu(m_settingsMenu);

    // Adding Options wizard and preferences
    //m_settingsMenu->addAction(m_actionManager->find("wizard"));
    m_settingsMenu->addAction(m_actionManager->find("preferences"));
    // Temporary out while SQA is done
    m_actionManager->enable("preferences", false);

// Temporary out while SQA is done
    // Setting up the insert menu
    // setupInsertActions();
    // Menu Insert
    m_insertMenu = new QMenu(tr("&Import"), this);
    menuBar()->addMenu(m_insertMenu);

    // Adding Options insert scene, insert layer and insert frame
    /*
    m_insertMenu->addAction(m_actionManager->find("InsertScene"));
    m_insertMenu->addAction(m_actionManager->find("InsertLayer"));
    m_insertMenu->addAction(m_actionManager->find("InsertFrame"));
    m_insertMenu->addSeparator();
    */

    // Adding Options import bitmap and import audio file
    m_insertMenu->addAction(m_actionManager->find("importbitmap"));
    m_insertMenu->addAction(m_actionManager->find("importbitmaparray"));
    m_insertMenu->addAction(m_actionManager->find("importsvg"));
    m_insertMenu->addAction(m_actionManager->find("importsvgarray"));

    //m_insertMenu->addAction(m_actionManager->find("importaudiofile"));

    // Setting up the window menu
    // setupWindowActions();
    m_windowMenu = new QMenu(tr("&Window"),this);
    menuBar()->addMenu(m_windowMenu);

    // Adding Options show debug, palette, pen, library, timeline, scenes, exposure, help
    m_windowMenu->addAction(m_actionManager->find("show palette"));
    m_windowMenu->addAction(m_actionManager->find("show pen"));
    m_windowMenu->addAction(m_actionManager->find("show library"));
    m_windowMenu->addAction(m_actionManager->find("show timeline"));
    m_actionManager->enable("show timeline", false);
    m_windowMenu->addAction(m_actionManager->find("show scenes"));
    m_windowMenu->addAction(m_actionManager->find("show exposure"));
    m_windowMenu->addAction(m_actionManager->find("show help"));

#if defined(QT_GUI_LIB) && defined(K_DEBUG)
    m_windowMenu->addAction(m_actionManager->find("show debug"));
#endif

    // m_actionManager->enable("show help", false);
    m_windowMenu->addSeparator();

    // Setup perspective menu
    m_viewMenu = new QMenu(tr("Modules"),this);
    QActionGroup *group = new QActionGroup(this);
    group->setExclusive(true);

    // Adding Option Animation
    QAction *drawingPerspective = new QAction(tr("Animation"), this);
    drawingPerspective->setIcon(QPixmap(THEME_DIR + "icons/animation_mode.png")); 
    drawingPerspective->setIconVisibleInMenu(true);
    drawingPerspective->setShortcut(QKeySequence("Ctrl+1"));
    drawingPerspective->setData(Animation);
    group->addAction(drawingPerspective);

    // Adding Option Player 
    QAction *animationPerspective = new QAction(tr("Player"), this);
    animationPerspective->setIcon(QPixmap(THEME_DIR + "icons/play_small.png"));
    animationPerspective->setIconVisibleInMenu(true);
    animationPerspective->setShortcut(QKeySequence("Ctrl+2"));
    animationPerspective->setData(Player);
    group->addAction(animationPerspective);

   // Adding Option Help 
    QAction *helpPerspective = new QAction(tr("Help"), this);
    helpPerspective->setIcon(QPixmap(THEME_DIR + "icons/help_mode.png"));
    helpPerspective->setIconVisibleInMenu(true);
    helpPerspective->setShortcut(QKeySequence("Ctrl+3"));
    helpPerspective->setData(Help);
    group->addAction(helpPerspective);

   // Adding Option News 
    QAction *newsPerspective = new QAction(tr("News"), this);
    newsPerspective->setIcon(QPixmap(THEME_DIR + "icons/news_mode.png"));
    newsPerspective->setIconVisibleInMenu(true);
    newsPerspective->setShortcut(QKeySequence("Ctrl+4"));
    newsPerspective->setData(News);
    group->addAction(newsPerspective);

    m_viewMenu->addActions(group->actions());
    connect(group, SIGNAL(triggered(QAction *)), this, SLOT(changePerspective(QAction *)));
    menuBar()->addMenu(m_viewMenu);
	
    // Setting up the help menu
    setupHelpActions();
    m_helpMenu = new QMenu(tr("&Help"),this);
    menuBar()->addMenu(m_helpMenu);
    m_helpMenu->addAction(m_actionManager->find("tipofday"));
    m_helpMenu->addSeparator();
    m_helpMenu->addAction(m_actionManager->find("about tupi"));

    setMenuItemsContext(false);
}
Example #9
0
void QActionProto::setIconVisibleInMenu(bool visible)
{
  QAction *item = qscriptvalue_cast<QAction*>(thisObject());
  if (item)
    item->setIconVisibleInMenu(visible);
}
Example #10
0
void EffectsListWidget::initList(QMenu *effectsMenu, KActionCategory *effectActions, QString categoryFile, bool transitionMode)
{
    QString current;
    QString currentFolder;
    bool found = false;
    effectsMenu->clear();

    if (currentItem()) {
        current = currentItem()->text(0);
        if (currentItem()->parent())
            currentFolder = currentItem()->parent()->text(0);
        else if (currentItem()->data(0, TypeRole) == EffectsList::EFFECT_FOLDER)
            currentFolder = currentItem()->text(0);
    }

    QTreeWidgetItem *misc = NULL;
    QTreeWidgetItem *audio = NULL;
    QTreeWidgetItem *custom = NULL;
    QList <QTreeWidgetItem *> folders;

    if (!categoryFile.isEmpty()) {
        QDomDocument doc;
        QFile file(categoryFile);
        doc.setContent(&file, false);
        file.close();
        QStringList folderNames;
        QDomNodeList groups = doc.documentElement().elementsByTagName(QStringLiteral("group"));
        for (int i = 0; i < groups.count(); ++i) {
            folderNames << i18n(groups.at(i).firstChild().firstChild().nodeValue().toUtf8().constData());
        }
        for (int i = 0; i < topLevelItemCount(); ++i) {
            topLevelItem(i)->takeChildren();
            QString currentName = topLevelItem(i)->text(0);
            if (currentName != i18n("Misc") && currentName != i18n("Audio") && currentName != i18nc("Folder Name", "Custom") && !folderNames.contains(currentName)) {
                takeTopLevelItem(i);
                --i;
            }
        }

        for (int i = 0; i < groups.count(); ++i) {
            QTreeWidgetItem *item = findFolder(folderNames.at(i));
            if (item) {
                item->setData(0, IdRole, groups.at(i).toElement().attribute(QStringLiteral("list")));
            } else {
                item = new QTreeWidgetItem((QTreeWidget*)0, QStringList(folderNames.at(i)));
                item->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
                item->setData(0, IdRole, groups.at(i).toElement().attribute(QStringLiteral("list")));
                item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
                item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
                insertTopLevelItem(0, item);
            }
            folders.append(item);
        }

        misc = findFolder(i18n("Misc"));
        if (misc == NULL) {
            misc = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Misc")));
            misc->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
            misc->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            insertTopLevelItem(0, misc);
        }

        audio = findFolder(i18n("Audio"));
        if (audio == NULL) {
            audio = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Audio")));
            audio->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
            audio->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            insertTopLevelItem(0, audio);
        }

        custom = findFolder(i18nc("Folder Name", "Custom"));
        if (custom == NULL) {
            custom = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18nc("Folder Name", "Custom")));
            custom->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
            custom->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            insertTopLevelItem(0, custom);
        }
    }

    //insertTopLevelItems(0, folders);
    if (transitionMode) {
        loadEffects(&MainWindow::transitions, misc, &folders, EffectsList::TRANSITION_TYPE, current, &found);
    }
    else {
        loadEffects(&MainWindow::videoEffects, misc, &folders, EffectsList::EFFECT_VIDEO, current, &found);
        loadEffects(&MainWindow::audioEffects, audio, &folders, EffectsList::EFFECT_AUDIO, current, &found);
        loadEffects(&MainWindow::customEffects, custom, static_cast<QList<QTreeWidgetItem *> *>(0), EffectsList::EFFECT_CUSTOM, current, &found);
        if (!found && !currentFolder.isEmpty()) {
            // previously selected effect was removed, focus on its parent folder
            for (int i = 0; i < topLevelItemCount(); ++i) {
                if (topLevelItem(i)->text(0) == currentFolder) {
                    setCurrentItem(topLevelItem(i));
                    break;
                }
            }
        }
    }
    setSortingEnabled(true);
    sortByColumn(0, Qt::AscendingOrder);

    // populate effects menu
    QMenu *sub1 = NULL;
    QMenu *sub2 = NULL;
    QMenu *sub3 = NULL;
    QMenu *sub4 = NULL;
    for (int i = 0; i < topLevelItemCount(); ++i) {
        if (topLevelItem(i)->data(0, TypeRole) == EffectsList::TRANSITION_TYPE) {
            QTreeWidgetItem *item = topLevelItem(i);
            QAction *a = new QAction(item->icon(0), item->text(0), effectsMenu);
            QStringList data = item->data(0, IdRole).toStringList();
            QString id = data.at(1);
            if (id.isEmpty()) id = data.at(0);
            a->setData(data);
            a->setIconVisibleInMenu(false);
            effectsMenu->addAction(a);
            effectActions->addAction("transition_" + id, a);
            continue;
        }
        if (!topLevelItem(i)->childCount())
            continue;
        QMenu *sub = new QMenu(topLevelItem(i)->text(0), effectsMenu);
        effectsMenu->addMenu(sub);
        int effectsInCategory = topLevelItem(i)->childCount();
        bool hasSubCategories = false;
        if (effectsInCategory > 60) {
            // create subcategories if there are too many effects
            hasSubCategories = true;
            sub1 = new QMenu(i18nc("menu name for effects names between these 2 letters", "0 - F"), sub);
            sub->addMenu(sub1);
            sub2 = new QMenu(i18nc("menu name for effects names between these 2 letters", "G - L"), sub);
            sub->addMenu(sub2);
            sub3 = new QMenu(i18nc("menu name for effects names between these 2 letters", "M - R"), sub);
            sub->addMenu(sub3);
            sub4 = new QMenu(i18nc("menu name for effects names between these 2 letters", "S - Z"), sub);
            sub->addMenu(sub4);
        }
        for (int j = 0; j < effectsInCategory; ++j) {
            QTreeWidgetItem *item = topLevelItem(i)->child(j);
            QAction *a = new QAction(item->icon(0), item->text(0), sub);
            QStringList data = item->data(0, IdRole).toStringList();
            QString id = data.at(1);
            if (id.isEmpty()) id = data.at(0);
            a->setData(data);
            a->setIconVisibleInMenu(false);
            if (hasSubCategories) {
                // put action in sub category
                QRegExp rx("^[s-z].+");
                if (rx.exactMatch(item->text(0).toLower())) {
                    sub4->addAction(a);
                } else {
                    rx.setPattern(QStringLiteral("^[m-r].+"));
                    if (rx.exactMatch(item->text(0).toLower())) {
                        sub3->addAction(a);
                    }
                    else {
                        rx.setPattern(QStringLiteral("^[g-l].+"));
                        if (rx.exactMatch(item->text(0).toLower())) {
                            sub2->addAction(a);
                        }
                        else sub1->addAction(a);
                    }
                }
            }
            else sub->addAction(a);
            effectActions->addAction("video_effect_" + id, a);
        }
    }
}
Example #11
0
void Plot::createMenu ()
{
  setContextMenuPolicy(Qt::CustomContextMenu);
  connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu()));

  _menu = new QMenu(this);
  
  _dateAction = new QAction(QIcon(":icons/calendar"), tr("Show &Dates"), this);
  _dateAction->setIconVisibleInMenu(true);
  _dateAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
  _dateAction->setToolTip(tr("Show/Hide Date"));
  _dateAction->setStatusTip(tr("Show/Hide Date"));
  _dateAction->setCheckable(true);
  _dateAction->setChecked(true);
  connect(_dateAction, SIGNAL(triggered(bool)), this, SLOT(showDate(bool)));
  _menu->addAction(_dateAction);

  _gridAction = new QAction(QIcon(":icons/grid"), tr("Show &Grid"), this);
  _gridAction->setIconVisibleInMenu(true);
  _gridAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
  _gridAction->setToolTip(tr("Show/Hide Grid"));
  _gridAction->setStatusTip(tr("Show/Hide Grid"));
  _gridAction->setCheckable(true);
  _gridAction->setChecked(true);
  connect(_gridAction, SIGNAL(triggered(bool)), this, SLOT(setGrid(bool)));
  _menu->addAction(_gridAction);

  _infoAction = new QAction(QIcon(":icons/info"), tr("Show Bar &Info"), this);
  _infoAction->setIconVisibleInMenu(true);
  _infoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_I));
  _infoAction->setToolTip(tr("Show/Hide Bar Info"));
  _infoAction->setStatusTip(tr("Show/Hide Bar Info"));
  _infoAction->setCheckable(true);
  _infoAction->setChecked(true);
  connect(_infoAction, SIGNAL(triggered(bool)), this, SLOT(setInfo(bool)));
  _menu->addAction(_infoAction);

  _menu->addSeparator();
  
  // create the chart object menu
  QMenu *mm = new QMenu(this);
  mm->setTitle(tr("New Plot Marker..."));
  connect(mm, SIGNAL(triggered(QAction *)), this, SLOT(markerMenuSelected(QAction *)));
  _menu->addMenu(mm);

  // buy
  QAction *a = new QAction(QIcon(":icons/buy"), tr("&Buy"), this);
  a->setToolTip(tr("Create Buy Arrow Plot Marker"));
  a->setIconVisibleInMenu(true);
  a->setStatusTip(QString(tr("Create Buy Arrow Plot Marker")));
  a->setData(QVariant("MarkerBuy"));
  mm->addAction(a);

  // sell
  a = new QAction(QIcon(":icons/sell"), tr("&Sell"), this);
  a->setToolTip(tr("Create Sell Arrow Plot Marker"));
  a->setIconVisibleInMenu(true);
  a->setStatusTip(QString(tr("Create Sell Arrow Plot Marker")));
  a->setData(QVariant("MarkerSell"));
  mm->addAction(a);

  // tline
  a = new QAction(QIcon(":icons/trend"), tr("Trend &Line"), this);
  a->setIconVisibleInMenu(true);
  a->setToolTip(tr("Create Trend Line Plot Marker"));
  a->setStatusTip(QString(tr("Create Trend Line Plot Marker")));
  a->setData(QVariant("MarkerTLine"));
  mm->addAction(a);

  // tline
  a = new QAction(QIcon(":icons/trend"), tr("&Horizontal Line"), this);
  a->setIconVisibleInMenu(true);
  a->setToolTip(tr("Create Trend Line Plot Marker"));
  a->setStatusTip(QString(tr("Create Trend Line Plot Marker")));
  a->setData(QVariant("MarkerHLine"));
  mm->addAction(a);

  // marker menu
  _markerMenu = new QMenu(this);
  _markerMenu->addAction(QIcon(":icons/edit"), QObject::tr("&Edit"), this, SLOT(markerDialog()), QKeySequence(Qt::ALT+Qt::Key_E));
  _markerMenu->addAction(QIcon(":icons/delete"), QObject::tr("&Delete"), this, SLOT(deleteMarker()), QKeySequence(Qt::ALT+Qt::Key_D));
  _markerMenu->menuAction()->setIconVisibleInMenu(true);
}
Example #12
0
/**
 * Update the account menu when accounts changed
 */
void AccountView::onAccountChanged()
{
    const std::vector<Account>& accounts = seafApplet->accountManager()->accounts();

    // Remove all menu items
    account_menu_->clear();

    if (!accounts.empty()) {
        for (size_t i = 0, n = accounts.size(); i < n; i++) {
            const Account &account = accounts[i];
            QString text = account.username + "(" + account.serverUrl.host() + ")";
            if (!account.isValid()) {
                text += ", " + tr("not logged in");
            }
            QMenu *submenu = new QMenu(text, account_menu_);
            if (i == 0) {
                submenu->setIcon(QIcon(":/images/account-checked.png"));
            } else {
                submenu->setIcon(QIcon(":/images/account-else.png"));
            }

            QAction *submenu_action = submenu->menuAction();
            submenu_action->setData(QVariant::fromValue(account));
            connect(submenu_action, SIGNAL(triggered()), this, SLOT(onAccountItemClicked()));

            QAction *action = new QAction(tr("Choose"), submenu);
            action->setIcon(QIcon(":/images/account-checked.png"));
            action->setIconVisibleInMenu(true);
            action->setData(QVariant::fromValue(account));
            connect(action, SIGNAL(triggered()), this, SLOT(onAccountItemClicked()));

            submenu->addAction(action);
            submenu->setDefaultAction(action);

            QAction *account_settings_action = new QAction(tr("Account settings"), this);
            account_settings_action->setIcon(QIcon(":/images/account-settings.png"));
            account_settings_action->setIconVisibleInMenu(true);
            account_settings_action->setData(QVariant::fromValue(account));
            connect(account_settings_action, SIGNAL(triggered()), this, SLOT(editAccountSettings()));
            submenu->addAction(account_settings_action);

            QAction *toggle_action = new QAction(this);
            toggle_action->setIcon(QIcon(":/images/logout.png"));
            toggle_action->setIconVisibleInMenu(true);
            toggle_action->setData(QVariant::fromValue(account));
            connect(toggle_action, SIGNAL(triggered()), this, SLOT(toggleAccount()));
            if (account.isValid())
                toggle_action->setText(tr("Logout"));
            else
                toggle_action->setText(tr("Login"));
            submenu->addAction(toggle_action);

            QAction *delete_account_action = new QAction(tr("Delete"), this);
            delete_account_action->setIcon(QIcon(":/images/delete-account.png"));
            delete_account_action->setIconVisibleInMenu(true);
            delete_account_action->setData(QVariant::fromValue(account));
            connect(delete_account_action, SIGNAL(triggered()), this, SLOT(deleteAccount()));
            submenu->addAction(delete_account_action);

            account_menu_->addMenu(submenu);
        }

        account_menu_->addSeparator();
    }

    add_account_action_ = new QAction(tr("Add an account"), this);
    add_account_action_->setIcon(QIcon(":/images/add-account.png"));
    add_account_action_->setIconVisibleInMenu(true);
    connect(add_account_action_, SIGNAL(triggered()), this, SLOT(showAddAccountDialog()));
    account_menu_->addAction(add_account_action_);

    updateAccountInfoDisplay();
}