void MuseScore::showWorkspaceMenu() { if (workspaces == 0) { workspaces = new QActionGroup(this); workspaces->setExclusive(true); connect(workspaces, SIGNAL(triggered(QAction*)), SLOT(changeWorkspace(QAction*))); } else { foreach(QAction* a, workspaces->actions()) workspaces->removeAction(a); } menuWorkspaces->clear(); const QList<Workspace*> pl = Workspace::workspaces(); foreach (Workspace* p, pl) { QAction* a = workspaces->addAction(p->name()); a->setCheckable(true); a->setData(p->path()); a->setChecked(a->text() == preferences.workspace); menuWorkspaces->addAction(a); }
QWidget* PropertyEditor::createWidgetForFlags(const QString& name, const QVariant& value, QMetaEnum me, const QString &detail, QWidget* parent) { mProperties[name] = value; QToolButton *btn = new QToolButton(parent); if (!detail.isEmpty()) btn->setToolTip(detail); btn->setObjectName(name); btn->setText(QObject::tr(name.toUtf8().constData())); btn->setPopupMode(QToolButton::InstantPopup); ClickableMenu *menu = new ClickableMenu(btn); menu->setObjectName(name); btn->setMenu(menu); for (int i = 0; i < me.keyCount(); ++i) { QAction * a = menu->addAction(me.key(i)); a->setCheckable(true); a->setData(me.value(i)); a->setChecked(value.toInt() & me.value(i)); } connect(menu, SIGNAL(triggered(QAction*)), SLOT(onFlagChange(QAction*))); return btn; }
void LDViewMainWindow::populateRecentFileMenuItems(void) { #ifdef __APPLE__ if (!openRecentMenu) { return; } #endif // __APPLE__ clearRecentFileMenuItems(); if (recentFiles->stringAtIndex(0)) { int i; long maxRecentFiles = Preferences::getMaxRecentFiles(); for (i = 0; i < maxRecentFiles; i++) { char *filename = truncateFilename(recentFiles->stringAtIndex(i)); if (filename) { #ifdef __APPLE__ QMenu *menu = openRecentMenu; #else // __APPLE__ QMenu *menu = fileMenu; #endif // __APPLE__ QAction *act; act = new QAction(filename,this); act->setData(i); menu->insertAction(fileMenu->actions()[fileMenu->actions().count() - 1], act); connect( act, SIGNAL( triggered() ), this, SLOT(doRecentFile()) ); delete filename; } } #ifndef __APPLE__ fileMenu->insertSeparator(fileMenu->actions()[fileMenu->actions().count() - 1]); #endif // __APPLE__ } }
QMenu *BrowserWindow::createWindowMenu(TabWidget *tabWidget) { QMenu *menu = new QMenu(tr("&Window")); QAction *nextTabAction = new QAction(tr("Show Next Tab"), this); QList<QKeySequence> shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Less)); nextTabAction->setShortcuts(shortcuts); connect(nextTabAction, &QAction::triggered, tabWidget, &TabWidget::nextTab); QAction *previousTabAction = new QAction(tr("Show Previous Tab"), this); shortcuts.clear(); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Greater)); previousTabAction->setShortcuts(shortcuts); connect(previousTabAction, &QAction::triggered, tabWidget, &TabWidget::previousTab); connect(menu, &QMenu::aboutToShow, [this, menu, nextTabAction, previousTabAction]() { menu->clear(); menu->addAction(nextTabAction); menu->addAction(previousTabAction); menu->addSeparator(); QVector<BrowserWindow*> windows = Browser::instance().windows(); int index(-1); for (auto window : windows) { QAction *action = menu->addAction(window->windowTitle(), this, &BrowserWindow::handleShowWindowTriggered); action->setData(++index); action->setCheckable(true); if (window == this) action->setChecked(true); } }); return menu; }
void ossimQtSingleImageWindow::buildResolutionLevelMenu() { if (!theResolutionLevelMenu) return; ossim_uint32 count = theResolutionLevelMenu->count(); ossim_uint32 numberOfReducedResSets = 1; ossimRLevelFilter* rf = getRLevelFilter(); if (rf) { numberOfReducedResSets = rf->getNumberOfDecimationLevels(); } if (count != numberOfReducedResSets) { theResolutionLevelMenu->clear(); QActionGroup* rsetGroup = new QActionGroup(theResolutionLevelMenu); for (ossim_uint32 i = 0; i < numberOfReducedResSets; ++i) { int id = static_cast<int>(i); QString qs = ossimString::toString(i).c_str(); //--- //Create the QAction button (Rset button) and assign it to the // rset group so that only one Rset is checked at any given time. //--- QAction* rsetAct = new QAction(qs, rsetGroup); rsetAct->setCheckable(true); //Set the Rset 0 button to checked upon initial entry if (i == 0)rsetAct->setChecked(true); rsetAct->setData(id); rsetAct->setEnabled(true); theResolutionLevelMenu->addAction( rsetAct ); rsetGroup->addAction( rsetAct ); } } }
void MainWindow::langListSync() { // format systems language ui->menuLanguage->clear(); QDir dir(m_langPath); QStringList fileNames = dir.entryList(QStringList("editor_*.qm")); for (int i = 0; i < fileNames.size(); ++i) { // get locale extracted by filename QString locale; locale = fileNames[i]; // "TranslationExample_de.qm" locale.truncate(locale.lastIndexOf('.')); // "TranslationExample_de" locale.remove(0, locale.indexOf('_') + 1); // "de" QString lang = QLocale::languageToString(QLocale(locale).language()); QIcon ico(QString("%1/%2.png").arg(m_langPath).arg(locale)); QAction *action = new QAction(ico, lang, this); action->setCheckable(true); action->setData(locale); WriteToLog(QtDebugMsg, QString("Locale: %1 %2").arg(m_langPath).arg(locale)); ui->menuLanguage->addAction(action); if (GlobalSettings::locale == locale) { action->setChecked(true); } } if(fileNames.size()==0) { QAction *action = ui->menuLanguage->addAction("[translations not found]"); action->setCheckable(false); action->setDisabled(true); } }
QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid ) { QgsAttributeTableConfig attributeTableConfig = mFilterModel->layer()->attributeTableConfig(); QToolButton *toolButton = nullptr; QWidget *container = nullptr; if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown ) { toolButton = new QToolButton(); toolButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); toolButton->setPopupMode( QToolButton::MenuButtonPopup ); container = toolButton; } else { container = new QWidget(); container->setLayout( new QHBoxLayout() ); container->layout()->setMargin( 0 ); } QList< QAction * > actionList; QAction *defaultAction = nullptr; // first add user created layer actions QList<QgsAction> actions = mFilterModel->layer()->actions()->actions( QStringLiteral( "Feature" ) ); Q_FOREACH ( const QgsAction &action, actions ) { QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() : QLatin1String( "" ); QAction *act = new QAction( action.icon(), actionTitle, container ); act->setToolTip( action.name() ); act->setData( "user_action" ); act->setProperty( "fid", fid ); act->setProperty( "action_id", action.id() ); connect( act, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered ); actionList << act; if ( mFilterModel->layer()->actions()->defaultAction( QStringLiteral( "AttributeTableRow" ) ).id() == action.id() ) defaultAction = act; }
/** * Constructeur * @param parent Parent du widget */ DocumentWidget::DocumentWidget(QWidget *parent) : NoteWidget(parent) { //Construction du layout du widget QVBoxLayout *layout = new QVBoxLayout; //Construction de l'edition du titre du document titleEdit = new QLineEdit; connect(titleEdit,SIGNAL(textChanged(QString)),this,SLOT(changeTitle(QString))); layout->addWidget(titleEdit,1,Qt::AlignTop); // QScrollArea *scroll = new QScrollArea(); // QWidget *childrenWidget = new QWidget(); childrenLayout = new QVBoxLayout; layout->addLayout(childrenLayout); //Construction du menu associé au bouton "ajouter" noteTypeMenu = new QMenu(tr("...")); QMap<QString, NoteFactory*> &factories = NotesManager::getInstance()->getFactories(); QMap<QString, NoteFactory*>::iterator it = factories.begin(); QMap<QString, NoteFactory*>::iterator end = factories.end(); while (it != end) { if (*it) { QAction *newNote = noteTypeMenu->addAction((*it)->getName()); newNote->setData(it.key()); newNote->setIcon(QIcon((*it)->getIcon())); connect(newNote,SIGNAL(triggered()),this,SLOT(addChild())); } it++; } QPushButton *more = new QPushButton(tr("Add child")); more->setMenu(noteTypeMenu); layout->addWidget(more,0,Qt::AlignBottom); setLayout(layout); }
void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf ) { QAction *action; /* Faster/Slower */ action = menu->addAction( qtr( "&Faster" ), THEMIM->getIM(), SLOT( faster() ) ); action->setIcon( QIcon( ":/toolbar/faster") ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "Faster (fine)" ), THEMIM->getIM(), SLOT( littlefaster() ) ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "N&ormal Speed" ), THEMIM->getIM(), SLOT( normalRate() ) ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "Slower (fine)" ), THEMIM->getIM(), SLOT( littleslower() ) ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "Slo&wer" ), THEMIM->getIM(), SLOT( slower() ) ); action->setIcon( QIcon( ":/toolbar/slower") ); action->setData( STATIC_ENTRY ); menu->addSeparator(); action = menu->addAction( qtr( "&Jump Forward" ), THEMIM->getIM(), SLOT( jumpFwd() ) ); action->setIcon( QIcon( ":/toolbar/skip_fw") ); action->setData( STATIC_ENTRY ); action = menu->addAction( qtr( "Jump Bac&kward" ), THEMIM->getIM(), SLOT( jumpBwd() ) ); action->setIcon( QIcon( ":/toolbar/skip_back") ); action->setData( STATIC_ENTRY ); addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"", SLOT( gotoTimeDialog() ), "Ctrl+T" ); menu->addSeparator(); }
void ProtocolPreferencesMenu::setModule(const char *module_name) { QAction *action; int proto_id = -1; protocol_t *protocol; clear(); module_name_.clear(); module_ = NULL; if (module_name) { proto_id = proto_get_id_by_filter_name(module_name); protocol = find_protocol_by_id(proto_id); } if (proto_id < 0 || !protocol) { action = addAction(tr("No protocol preferences available")); action->setDisabled(true); return; } module_ = prefs_find_module(module_name); const QString proto_name = proto_get_protocol_long_name(protocol); if (!module_ || !prefs_is_registered_protocol(module_name)) { action = addAction(tr("%1 has no preferences").arg(proto_name)); action->setDisabled(true); return; } module_name_ = module_name; action = addAction(tr("Open %1 preferences" UTF8_HORIZONTAL_ELLIPSIS).arg(proto_name)); action->setData(QString(module_name)); connect(action, SIGNAL(triggered(bool)), this, SLOT(modulePreferencesTriggered())); addSeparator(); prefs_pref_foreach(module_, add_prefs_menu_item, this); }
//uses dir name as menuitem, no recursion void create_menu_from_dir_dir (QObject *handler, QMenu *menu, const QString &dir, const char *method ) { menu->setTearOffEnabled (true); QDir d (dir); QFileInfoList lst_fi = d.entryInfoList (QDir::NoDotAndDotDot | QDir::Dirs, QDir::IgnoreCase | QDir::LocaleAware | QDir::Name); foreach (QFileInfo fi, lst_fi) { if (fi.isDir()) { QAction *act = new QAction (fi.fileName(), menu->parentWidget()); act->setData (fi.filePath()); handler->connect (act, SIGNAL(triggered()), handler, method); menu->addAction (act); } } }
void DocumentManager::add(DocumentInfo *documentInfo) { QMainWindow *mainWindow = documentInfo->mainWindow; d->documentInfos.append(documentInfo); connect(mainWindow, SIGNAL(destroyed(QObject *)), this, SLOT(remove(QObject *))); // update object name ("window ID") mainWindow->setObjectName(mainWindow->objectName() + QString::number(d->nextWindowId)); mainWindow->installEventFilter(this); /*!\todo This gets messy: make DocumentInfo a proper class. */ documentInfo->id = d->nextWindowId; ++d->nextWindowId; documentInfo->windowTitle = tr("New %1", "New document title + ID").arg(d->nextWindowId); QAction *action = new QAction(d->windowActionGroup); action->setCheckable(true); action->setData(documentInfo->id); action->setText(documentInfo->windowTitle); d->windowMapper.setMapping(action, documentInfo->id); connect(action, SIGNAL(triggered()), &d->windowMapper, SLOT(map())); emit changed(); }
/** \brief Rebuild the patients' history menu */ void PatientActionHandler::aboutToShowRecentPatients() { // update patient history Core::ActionContainer *recentsMenu = actionManager()->actionContainer(Core::Constants::M_PATIENTS_NAVIGATION); if (!recentsMenu) return; if (!recentsMenu->menu()) return; recentsMenu->menu()->clear(); bool hasRecentFiles = false; const QStringList &uuids = m_RecentPatients->recentFiles(); const QHash<QString, QString> &names = patient()->fullPatientName(uuids); for(int i = 0; i < uuids.count(); ++i) { hasRecentFiles = true; QAction *action = recentsMenu->menu()->addAction(tkTr(Trans::Constants::_1_COLON_2).arg(i).arg(names.value(uuids.at(i)))); action->setData(uuids.at(i)); connect(action, SIGNAL(triggered()), this, SLOT(openRecentPatient())); } recentsMenu->menu()->setEnabled(hasRecentFiles); }
/** * @brief Add static entries to MIM in menus **/ QAction* addMIMStaticEntry( intf_thread_t *p_intf, QMenu *menu, const QString& text, const char *icon, const char *member, bool bStatic = false ) { QAction *action; #ifndef __APPLE__ /* We don't set icons in menus in MacOS X */ if( !EMPTY_STR( icon ) ) { action = menu->addAction( text, THEMIM, member ); action->setIcon( QIcon( icon ) ); } else #endif { action = menu->addAction( text, THEMIM, member ); } action->setData( bStatic ? STATIC_ENTRY : ENTRY_ALWAYS_ENABLED ); return action; }
void PlaylistHeaderView::setModel(QAbstractItemModel *model) { QHeaderView::setModel(model); for (int i = 0; i < count(); i++) { QString label = labels.at(i); // Exclude hidden columns (should be improved?) if (QString::compare(label, "TrackDAO") != 0) { model->setHeaderData(i, Qt::Horizontal, tr(label.toStdString().data()), Qt::DisplayRole); // Match actions with columns using index of labels QAction *actionColumn = new QAction(label, this); actionColumn->setData(i); actionColumn->setEnabled(actionColumn->text() != tr("Title")); actionColumn->setCheckable(true); actionColumn->setChecked(!isSectionHidden(i)); // Then populate the context menu _columns->addAction(actionColumn); } } }
void ComboBox::insertItem(int index, const QString & item, QIcon icon, QKeySequence key, const QString & toolTip) { if (_cascading) { qDebug() << "Combobox::insertItem is unsupported when in cascading mode."; return; } assert(index >= 0); QAction* action = new QAction(this); action->setText(item); action->setData( QVariant(index) ); if ( !toolTip.isEmpty() ) { action->setToolTip( GuiUtils::convertFromPlainText(toolTip.trimmed(), Qt::WhiteSpaceNormal) ); } if ( !icon.isNull() ) { action->setIcon(icon); } if ( !key.isEmpty() ) { action->setShortcut(key); } growMaximumWidthFromText(item); boost::shared_ptr<ComboBoxMenuNode> node( new ComboBoxMenuNode() ); node->text = item; node->isLeaf = action; node->parent = _rootNode.get(); _rootNode->isMenu->addAction(node->isLeaf); _rootNode->children.insert(_rootNode->children.begin() + index, node); /*if this is the first action we add, make it current*/ if (_rootNode->children.size() == 1) { setCurrentText_no_emit( itemText(0) ); } }
void TextEdit::setupSpeller() { BehaviorSettings::self()->readConfig(); d->curLang = BehaviorSettings::spellerLanguage(); Sonnet::Speller s; if(d->curLang.isEmpty()){ d->curLang = s.defaultLanguage(); } kDebug()<<"Current LANG: "<<d->curLang; QMap<QString, QString> list = s.availableDictionaries(); QMap<QString, QString>::const_iterator it = list.constBegin(), endIt = list.constEnd(); for(; it!=endIt; ++it){ QAction *act = new QAction(it.key(), d->langActions); act->setData(it.value()); act->setCheckable(true); if(d->curLang == it.value()) act->setChecked(true); connect(act, SIGNAL(triggered(bool)), SLOT(slotChangeSpellerLanguage())); d->langActions->addAction(act); d->langActionMap.insert(it.value(), act); } }
PageControlWidget::PageControlWidget(Book *book, Page *page, QWidget *parent) : QWidget(parent) { pBook = book; pPage = page; layout = new QHBoxLayout; bAddPage = new QPushButton(tr("Add a page after this page")); bRemovePage = new QPushButton(tr("Remove this page")); bAdvancedOptions = new QPushButton(tr("Advanced")); bAdvancedOptions->setMenu(new QMenu); layout->addWidget(bAddPage); layout->addWidget(bRemovePage); if( book->mainWindow()->showAdvancedPageOptions() ) { layout->addWidget(bAdvancedOptions); bAdvancedOptions->menu()->addAction(tr("About this page"),this,SLOT(aboutThisPage())); QMenu *tMenu = templateMenu(); if(tMenu->actions().count() > 1) bAdvancedOptions->menu()->addMenu( tMenu ); } if( book->templateMode() == Book::BreakoutMode ) { QMenu *ltMenu = new QMenu; QList<LayoutTemplate*> lt = book->mainWindow()->getLayoutTemplatesForPageTemplate(book->pageTemplate()); QActionGroup *ltGroup = new QActionGroup(ltMenu); for(int i=0; i < lt.count(); i++ ) { QAction *tmp = new QAction(lt.at(i)->longName(),this); tmp->setData( lt.at(i)->name() ); ltMenu->addAction(tmp); ltGroup->addAction(tmp); } connect(ltGroup,SIGNAL(triggered(QAction*)),this,SLOT(addPageFromAction(QAction*))); bAddPage->setMenu(ltMenu); }
/** * Creates the right-click menu */ void KMixDockWidget::createMenuActions() { QMenu *menu = contextMenu(); if (!menu) return; // We do not use a menu shared_ptr<MixDevice> md = Mixer::getGlobalMasterMD(); if ( md.get() != 0 && md->hasMuteSwitch() ) { // Put "Mute" selector in context menu #ifdef X_KMIX_KF5_BUILD KToggleAction *action = new KToggleAction(i18n("M&ute"), this); action->setData("dock_mute"); addAction("dock_mute", action); #else KToggleAction *action = actionCollection()->add<KToggleAction>( "dock_mute" ); action->setText( i18n("M&ute") ); #endif updateDockMuteAction(action); connect(action, SIGNAL(triggered(bool)), SLOT(dockMute())); menu->addAction( action ); } // Put "Select Master Channel" dialog in context menu #ifdef X_KMIX_KF5_BUILD QAction *action = new QAction(i18n("Select Master Channel..."), this); action->setData("select_master"); addAction("select_master", action); #else QAction *action = actionCollection()->addAction( "select_master" ); action->setText( i18n("Select Master Channel...") ); #endif action->setEnabled(Mixer::getGlobalMasterMixer() != 0); connect(action, SIGNAL(triggered(bool)), _kmixMainWindow, SLOT(slotSelectMaster())); menu->addAction( action ); //Context menu entry to access phonon settings menu->addAction(_kmixMainWindow->actionCollection()->action("launch_kdesoundsetup")); }
void VideoItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *) { QMenu menu; QFont menuFont = qApp->font(); menuFont.setPixelSize(14); menu.setFont(menuFont); int screenCount = m_video->getScreenCount(); if (screenCount > 0) { for (int i = 0; i < screenCount; i++) { QAction *scrAction = new QAction(tr("Screen %1").arg(i + 1), this); scrAction->setCheckable(true); if (m_video->screen() == i) scrAction->setChecked(true); scrAction->setData(i); connect(scrAction, SIGNAL(triggered()), this, SLOT(slotScreenChanged())); menu.addAction(scrAction); } } menu.addAction(m_fullscreenAction); menu.addAction(m_alignToCursor); if (isLocked()) { m_lockAction->setText(tr("Unlock item")); m_lockAction->setIcon(QIcon(":/unlock.png")); } else { m_lockAction->setText(tr("Lock item")); m_lockAction->setIcon(QIcon(":/lock.png")); } menu.addAction(m_lockAction); menu.exec(QCursor::pos()); }
void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos) { if (!QDeclarativeViewObserverPrivate::get(observer())->mouseInsideContextItem()) return; QMenu contextMenu; connect(&contextMenu, SIGNAL(hovered(QAction*)), this, SLOT(contextMenuElementHovered(QAction*))); m_contextMenuItemList = itemList; contextMenu.addAction("Items"); contextMenu.addSeparator(); int shortcutKey = Qt::Key_1; bool addKeySequence = true; int i = 0; foreach (QGraphicsItem * const item, itemList) { QString itemTitle = titleForItem(item); QAction *elementAction = contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected())); if (observer()->selectedItems().contains(item)) { QFont boldFont = elementAction->font(); boldFont.setBold(true); elementAction->setFont(boldFont); } elementAction->setData(i); if (addKeySequence) elementAction->setShortcut(QKeySequence(shortcutKey)); shortcutKey++; if (shortcutKey > Qt::Key_9) addKeySequence = false; ++i; }
GroupMenu::GroupMenu(QWidget* parent) : QMenu(parent) { QAction* a; // Sub menu Add to Group myGroupsMenu = new QMenu(tr("Add Users to"), this); myUserGroupActions = new QActionGroup(this); myUserGroupActions->setExclusive(false); connect(myUserGroupActions, SIGNAL(triggered(QAction*)), SLOT(addUsersToGroup(QAction*))); mySystemGroupActions = new QActionGroup(this); mySystemGroupActions->setExclusive(false); connect(mySystemGroupActions, SIGNAL(triggered(QAction*)), SLOT(addUsersToGroup(QAction*))); // System groups for (int i = ContactListModel::SystemGroupOffset; i <= ContactListModel::LastSystemGroup; ++i) { a = mySystemGroupActions->addAction(ContactListModel::systemGroupName(i)); a->setData(i); } myGroupSeparator = myGroupsMenu->addSeparator(); myGroupsMenu->addActions(mySystemGroupActions->actions()); // Menu myMoveUpAction = addAction(tr("Move &Up"), this, SLOT(moveGroupUp())); myMoveDownAction = addAction(tr("Move &Down"), this, SLOT(moveGroupDown())); myRenameAction = addAction(tr("Rename"), this, SLOT(renameGroup())); mySettingsAction = addAction(tr("Sounds..."), this, SLOT(settings())); addMenu(myGroupsMenu); myRemoveGroupAction = addAction(tr("Remove Group"), this, SLOT(removeGroup())); updateIcons(); updateGroups(); connect(this, SIGNAL(aboutToShow()), SLOT(aboutToShowMenu())); connect(IconManager::instance(), SIGNAL(iconsChanged()), SLOT(updateIcons())); }
void MenuCallback::addCommand(QString commandId, QString label, QString tooltip, QString shortcut, bool checkable) { shortcut = shortcut.replace(QString::fromUtf8("Enter"), QString::fromAscii("\n")); QKeySequence keySequence(shortcut); #ifndef Q_WS_MAC if (shortcut.contains(QString::fromAscii("\n"))) { int value = (keySequence[0] & Qt::MODIFIER_MASK) + Qt::Key_Enter; keySequence = QKeySequence(value); } #endif // allow custom action handlers first shot QAction* pAction = addCustomAction(commandId, label, tooltip); // if there was no custom handler then do stock command-id processing if (pAction == NULL) { pAction = menuStack_.top()->addAction(QIcon(), label, this, SLOT(actionInvoked()), keySequence); pAction->setData(commandId); pAction->setToolTip(tooltip); if (checkable) pAction->setCheckable(true); MenuActionBinder* pBinder = new MenuActionBinder(menuStack_.top(), pAction); connect(pBinder, SIGNAL(manageCommand(QString,QAction*)), this, SIGNAL(manageCommand(QString,QAction*))); }
void MainWindow::createInterfaceLanguageMenu(void) { // Adapted from : https://wiki.qt.io/How_to_create_a_multi_language_application interfaceLangGroup = new QActionGroup(interfaceLangSubMenu); interfaceLangGroup->setExclusive(true); QAction* select_auto = new QAction(this); select_auto->setCheckable(true); select_auto->setData("auto"); interfaceLangSubMenu->addAction(select_auto); interfaceLangGroup->addAction(select_auto); connect(interfaceLangGroup, SIGNAL(triggered(QAction*)), this, SLOT(interfaceLanguageChanged(QAction*))); langPath = QApplication::applicationDirPath().append("/translations/"); QStringList fileNames = QDir(langPath).entryList(QStringList("PkmGCSaveEditor_*.qm")); QAction *actionToCheck = select_auto; for (int i = 0; i < fileNames.size(); ++i) { QString locale; locale = fileNames[i]; locale.truncate(locale.lastIndexOf('.')); locale.remove(0, locale.indexOf('_') + 1); QAction *action = new QAction(this); if (locale == interfaceLanguage) actionToCheck = action; action->setCheckable(true); action->setData(locale); interfaceLangGroup->addAction(action); interfaceLangSubMenu->addAction(action); } actionToCheck->setChecked(true); }
void ListingTable::buildHeaderSectionMenu(QMenu* menu) { QHeaderView* header = horizontalHeader(); QAction* scaleToFitAction = new QAction(tr("Scale To Fit Viewport"), menu); connect(scaleToFitAction, SIGNAL(triggered()), this, SLOT(scaleSectionsToFit())); menu->addAction(scaleToFitAction); menu->addSeparator(); int nc = model->columnCount(); for (int i = 0 ; i < nc ; i++) { QString headerStr = model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(); QAction* action = new QAction(headerStr, menu); connect(action, SIGNAL(triggered()), this, SLOT(headerSectionVisibilityActionTriggered())); action->setData(i); action->setCheckable(true); action->setChecked(!header->isSectionHidden(i)); menu->addAction(action); } }
void MainWindow::fillLanguages() { languages = menuBar()->addMenu( "" ); // make a group of language actions QActionGroup* actions = new QActionGroup( this ); connect( actions, SIGNAL( triggered( QAction* ) ), this, SLOT( setLanguage( QAction* ) ) ); foreach ( QString avail, Application::availableLanguages() ) { // figure out nice names for locales QLocale locale( avail ); QString language = QLocale::languageToString( locale.language() ); QString country = QLocale::countryToString( locale.country() ); QString name = language + " (" + country + ")"; // construct an action QAction* action = languages->addAction( name ); action->setData( avail ); action->setCheckable( true ); actions->addAction( action ); }
void LkInputTableView::setModel(QAbstractItemModel *m_model){ QTableView::setModel(m_model); this->setContextMenuPolicy(Qt::ActionsContextMenu); this->actions().clear(); for(int i=0; i < this->model()->columnCount(); i++){ int data = this->model()->headerData(i, Qt::Horizontal, Qt::UserRole).toInt(); if(data == hideColumnFlag) QTableView::hideColumn(i); else { QString text = this->model()->headerData(i, Qt::Horizontal).toString(); QAction *openAct = new QAction(text, this); openAct->setCheckable(true); openAct->setChecked(!isColumnHidden(i)); openAct->setData(i); openAct->setStatusTip(text); connect(openAct, SIGNAL(triggered(bool)), this, SLOT(on_action(bool))); this->addAction(openAct); } } }
void MainWindow::addWidget( const QString &page, const QIcon &icon, QWidget *widget ) { QString topLevel = d->pluginTree.page( page ); bool pageExists = d->pluginTree.pages().contains( topLevel ); d->pluginTree.add( page, widget ); if (!pageExists) { QAction *action = new QAction( icon, page, this ); action->setCheckable( true ); action->setChecked( false ); int index = d->stackedLayout->addWidget( widget ); action->setData( index ); connect(action, SIGNAL(triggered()), this, SLOT(slotPagesClick())); d->pagesActionGroup->addAction( action ); //toolbarIcons.insert(page); d->pagesBar->addAction( action ); } if (d->pagesActionGroup->actions().count() == 1) { //First icon d->pagesActionGroup->actions().first()->setChecked( true ); } }
void MainWindow::createDumpedNamesLanguageMenu(void) { dumpedNamesLangGroup = new QActionGroup(dumpedNamesLangSubMenu); dumpedNamesLangGroup->setExclusive(true); QAction* select_auto = new QAction(this); select_auto->setCheckable(true); select_auto->setData(0); connect(dumpedNamesLangGroup, SIGNAL(triggered(QAction*)), this, SLOT(dumpedNamesLanguageChanged(QAction*))); dumpedNamesLangGroup->addAction(select_auto); dumpedNamesLangSubMenu->addAction(select_auto); for (int i = 1; i < 7; ++i) { QAction* action = new QAction(this); action->setCheckable(true); action->setData(i); dumpedNamesLangGroup->addAction(action); dumpedNamesLangSubMenu->addAction(action); } dumpedNamesLangGroup->actions()[(size_t)dumpedNamesLanguage]->setChecked(true); }
/** * Navigation Menu * For DVD, MP4, MOV and other chapter based format **/ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu ) { QAction *action; QMenu *submenu = new QMenu( qtr( "&Bookmarks" ), menu ); addDPStaticEntry( submenu, qtr( "Manage &bookmarks" ), "", SLOT( bookmarksDialog() ) ); submenu->addSeparator(); action = menu->addMenu( submenu ); action->setData( "bookmark" ); ACT_ADDMENU( menu, "title", qtr( "T&itle" ) ); ACT_ADDMENU( menu, "chapter", qtr( "&Chapter" ) ); ACT_ADDMENU( menu, "navigation", qtr( "&Navigation" ) ); ACT_ADDMENU( menu, "program", qtr( "&Program" ) ); menu->addSeparator(); PopupMenuPlaylistControlEntries( menu, p_intf ); PopupMenuControlEntries( menu, p_intf ); EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) ); return RebuildNavigMenu( p_intf, menu ); }