void PaletteBoxButton::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; QAction* actionProperties = menu.addAction(tr("Palette Properties…")); QAction* actionInsert = menu.addAction(tr("Insert New Palette…")); QAction* actionUp = menu.addAction(tr("Move Palette Up")); QAction* actionDown = menu.addAction(tr("Move Palette Down")); QAction* actionEdit = menu.addAction(tr("Enable Editing")); actionEdit->setCheckable(true); actionEdit->setChecked(!palette->readOnly()); if (palette->isFilterActive()) actionEdit->setVisible(false); bool _systemPalette = palette->systemPalette(); actionProperties->setDisabled(_systemPalette); actionInsert->setDisabled(_systemPalette); actionUp->setDisabled(_systemPalette); actionDown->setDisabled(_systemPalette); actionEdit->setDisabled(_systemPalette); menu.addSeparator(); QAction* actionSave = menu.addAction(tr("Save Palette…")); QAction* actionLoad = menu.addAction(tr("Load Palette…")); actionLoad->setDisabled(_systemPalette); menu.addSeparator(); QAction* actionDelete = menu.addAction(tr("Delete Palette")); actionDelete->setDisabled(_systemPalette); QAction* action = menu.exec(mapToGlobal(event->pos())); if (action == actionProperties) propertiesTriggered(); else if (action == actionInsert) newTriggered(); else if (action == actionUp) upTriggered(); else if (action == actionDown) downTriggered(); else if (action == actionEdit) enableEditing(action->isChecked()); else if (action == actionSave) saveTriggered(); else if (action == actionLoad) loadTriggered(); else if (action == actionDelete) deleteTriggered(); }
/*! * This is our default constructor, which creates a new menu bar populated with * the actions for our application. * * \param p The menu bar's parent widget. */ CSMainMenuBar::CSMainMenuBar(QWidget *p) : QMenuBar(p) { // Initialize our dialog. aboutDialog = new CSAboutDialog(this); // Initialize the file menu. fileMenu = addMenu(tr("&File")); newCollectionAction = fileMenu->addAction(tr("&New Collection...")); newCollectionAction->setIcon(CSGUIUtils::getIconFromTheme("list-add")); newCollectionAction->setShortcut(Qt::CTRL + Qt::Key_N); newCollectionAction->setStatusTip(tr("Create a new collection")); syncAction = fileMenu->addAction(tr("&Sync...")); syncAction->setIcon( CSGUIUtils::getIconFromTheme("sync-synchronizing")); syncAction->setShortcut(Qt::CTRL + Qt::Key_S); syncAction->setStatusTip(tr("Sync two collections")); removeCollectionAction = fileMenu->addAction( tr("&Remove Collection...")); removeCollectionAction->setIcon( CSGUIUtils::getIconFromTheme("list-remove")); removeCollectionAction->setStatusTip( tr("Remove the current collection")); fileMenu->addSeparator(); exitAction = fileMenu->addAction(tr("E&xit")); exitAction->setIcon(CSGUIUtils::getIconFromTheme("application-exit")); exitAction->setStatusTip(tr("Exit CuteSync")); // Initialize the settings menu. settingsMenu = addMenu(tr("&Settings")); resetSettingsAction = settingsMenu->addAction(tr("Reset Settings")); resetSettingsAction->setStatusTip( tr("Reset all saved data to its default state")); // Initialize the tools menu. toolsMenu = addMenu(tr("&Tools")); checkIPodAction = toolsMenu->addAction(tr("Check iPod Filesystem")); checkIPodAction->setStatusTip( tr("Check an iPod's filesystem for errors.")); #ifdef CUTESYNC_DEBUG createIPodAction = toolsMenu->addAction( tr("Create Testing iPod")); createIPodAction->setStatusTip( tr("Create a false iPod for testing purposes.")); #endif // Initialize the help menu. helpMenu = addMenu(tr("&Help")); aboutCuteSyncAction = helpMenu->addAction(tr("&About CuteSync...")); aboutCuteSyncAction->setIcon( CSGUIUtils::getIconFromTheme("help-about")); aboutCuteSyncAction->setStatusTip( tr("Display CuteSync's about dialog")); aboutQtAction = helpMenu->addAction(tr("About &Qt...")); aboutQtAction->setIcon(CSGUIUtils::getIconFromTheme("help-about")); aboutQtAction->setStatusTip( tr("Display the Qt library's about dialog")); // Connect actions. QObject::connect(newCollectionAction, SIGNAL(triggered()), this, SIGNAL(newTriggered())); QObject::connect(syncAction, SIGNAL(triggered()), this, SIGNAL(syncTriggered())); QObject::connect(removeCollectionAction, SIGNAL(triggered()), this, SIGNAL(removeTriggered())); QObject::connect(exitAction, SIGNAL(triggered()), this, SIGNAL(exitTriggered())); QObject::connect(resetSettingsAction, SIGNAL(triggered()), this, SIGNAL(resetSettingsTriggered())); QObject::connect(checkIPodAction, SIGNAL(triggered()), this, SIGNAL(checkIPodTriggered())); #ifdef CUTESYNC_DEBUG QObject::connect(createIPodAction, SIGNAL(triggered()), this, SIGNAL(createIPodTriggered())); #endif QObject::connect(aboutCuteSyncAction, SIGNAL(triggered()), this, SLOT(doAboutCuteSync())); QObject::connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); }