void DataTable::showContextMenu(const QPoint &pos, QModelIndex index) //pos is in global coordinates { if(!model() || !index.isValid()){ return; } QList<QAction*> actions; //first add copy actions. actions.append(createCopyMenu(false)); actions.append(createCopyMenu(true)); actions.append(WidgetHelper::createSeparatorAction()); int row=index.row(); actions.append(getActionsForObject(row)); if(actions.size()==0){ return; } QMenu *menu = new QMenu(); menu->addActions(actions); menu->setDefaultAction(WidgetHelper::findDefaultAction(actions)); connect(menu, SIGNAL(triggered(QAction*)), this, SIGNAL(contextMenuTriggered(QAction*))); menu->exec(pos); WidgetHelper::deleteMenu(menu); }
void MainWindow::updateTrayIcon() { QSettings settings; if (bool(m_trayIcon) == settings.value(QLatin1String("ui/main/closeToTray"), false)) return; if (m_trayIcon) { m_trayIcon->hide(); m_trayIcon->deleteLater(); m_trayIcon = 0; } else { m_trayIcon = new QSystemTrayIcon(windowIcon(), this); m_trayIcon->setToolTip(tr("Bluecherry Client")); QMenu *menu = new QMenu(this); menu->setDefaultAction(menu->addAction(tr("Open Bluecherry Client"), this, SLOT(showFront()))); menu->addAction(tr("Quit"), qApp, SLOT(quit())); m_trayIcon->setContextMenu(menu); connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); m_trayIcon->show(); } }
void TwitterApiPostWidget::initUi() { Choqok::UI::PostWidget::initUi(); KPushButton *btnRe = addButton( "btnReply",i18nc( "@info:tooltip", "Reply" ), "edit-undo" ); QMenu *menu = new QMenu(btnRe); KAction *actRep = new KAction(KIcon("edit-undo"), i18n("Reply to %1", currentPost().author.userName), menu); menu->addAction(actRep); connect( actRep, SIGNAL(triggered(bool)), SLOT(slotReply()) ); connect( btnRe, SIGNAL(clicked(bool)), SLOT(slotReply()) ); KAction *actWrite = new KAction( KIcon("document-edit"), i18n("Write to %1", currentPost().author.userName), menu ); menu->addAction(actWrite); connect( actWrite, SIGNAL(triggered(bool)), SLOT(slotWriteTo()) ); if( !currentPost().isPrivate ) { KAction *actReplytoAll = new KAction(i18n("Reply to all"), menu); menu->addAction(actReplytoAll); connect( actReplytoAll, SIGNAL(triggered(bool)), SLOT(slotReplyToAll()) ); } menu->setDefaultAction(actRep); btnRe->setDelayedMenu(menu); if( !currentPost().isPrivate ) { d->btnFav = addButton( "btnFavorite",i18nc( "@info:tooltip", "Favorite" ), "rating" ); d->btnFav->setCheckable(true); connect( d->btnFav, SIGNAL(clicked(bool)), SLOT(setFavorite()) ); updateFavStat(); }
void RSImageBlockWidget::addButtonAction(const QString &text, const QObject *receiver, const char *member, bool standardAction) { QMenu *menu = ui->loadImagesButton->menu(); if (!menu) { /* Set popup mode */ ui->loadImagesButton->setPopupMode(QToolButton::MenuButtonPopup); ui->loadImagesButton->setIcon(ui->loadImagesButton->icon()); // Sometimes Qt doesn't recalculate sizeHint /* Create popup menu */ menu = new QMenu; ui->loadImagesButton->setMenu(menu); /* Add 'click' action as action */ QAction *action = menu->addAction(ui->loadImagesButton->text(), this, SIGNAL(showImages())); menu->setDefaultAction(action); } /* Add new action */ QAction *action = menu->addAction(text, receiver, member); ui->loadImagesButton->addAction(action); if (standardAction) { /* Connect standard action */ connect(action, SIGNAL(triggered()), this, SIGNAL(showImages())); } }
void UFunctionTag::menu(QMenu& menu) { menu.setDefaultAction( menu.addAction(QIcon(":/images/algorithm/function.png"),"Edit function name",this,SLOT(editName())) ); menu.addAction(QIcon(":/images/algorithm/tag.png"),"Edit function hint",hintTag,SLOT(edit())); menu.addAction(QIcon(":/images/algorithm/var.png"),"Edit arguments list",this,SLOT(editArgs())); }
void ezQtPropertyAnimAssetTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu m; QAction* pFrameAction = m.addAction("Frame Curve"); QAction* pRemoveAction = m.addAction("Remove Track"); QAction* pBindingAction = m.addAction("Change Binding..."); m.setDefaultAction(pFrameAction); pRemoveAction->setShortcut(Qt::Key_Delete); connect(pFrameAction, &QAction::triggered, this, [this](bool) { Q_EMIT FrameSelectedItemsEvent(); }); connect(pRemoveAction, &QAction::triggered, this, [this](bool) { Q_EMIT DeleteSelectedItemsEvent(); }); connect(pBindingAction, &QAction::triggered, this, [this](bool) { Q_EMIT RebindSelectedItemsEvent(); }); m.exec(QCursor::pos()); }
BeaconWindow::BeaconWindow(QWidget *parent) : QDialog(parent), ui(new Ui::BeaconWindow) { //Load configuration settings QSettings settings("config.ini", QSettings::IniFormat, this); QString name = settings.value("Name", "").toString(); while(name == "") { name = QInputDialog::getText(this, "User Name", "Enter your name", QLineEdit::Normal, "", 0, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::CustomizeWindowHint); settings.setValue("Name", name); settings.sync(); } //Setup model for peers peers = new QStandardItemModel(this); //Create connections to all peers manager = new ConnectionManager(name); connect(manager, SIGNAL(changedPeers()), this, SLOT(updatePeers())); connect(manager, SIGNAL(gotMessage(QString,Peer*)), this, SLOT(handleMessage(QString,Peer*))); manager->sendOnlineBroadcast(); //Setup ui ui->setupUi(this); setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::CustomizeWindowHint); ui->lstPeers->setModel(peers); //Create system tray tray = new QSystemTrayIcon(this); tray->setIcon(QIcon(":/Icons/megaphone.png")); QMenu *menu = new QMenu(this); menu->setDefaultAction(menu->addAction("Send Message...", this, SLOT(show()))); menu->addAction("Quit", this, SLOT(close())); tray->setContextMenu(menu); connect(tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleTrayEvent(QSystemTrayIcon::ActivationReason))); tray->show(); }
void UCommentTag::menu(QMenu &menu) { menu.setDefaultAction( menu.addAction("Set comment",this,SLOT(edit())) ); }
MainWindow::MainWindow(App *a) : m_close_shutdown(false), m_app(a) { setupUi(this); setDocumentName(""); instruments->setIconSize(QSize(16,16)); speed->setRange(MIN_SPEED, MAX_SPEED); tempo->setRange(MIN_TEMPO, MAX_TEMPO); rows->setRange(1, MAX_PATTERN_LENGTH); frames->setRange(1, MAX_FRAMES); title->setMaxLength(MAX_SONGINFO_LENGTH); author->setMaxLength(MAX_SONGINFO_LENGTH); copyright->setMaxLength(MAX_SONGINFO_LENGTH); instrumentName->setMaxLength(MAX_INSTRUMENT_NAME_LENGTH); QObject::connect(actionNew, SIGNAL(triggered()), this, SLOT(newDoc())); actionNew->setIcon(QIcon::fromTheme("document-new")); QObject::connect(action_Open, SIGNAL(triggered()), this, SLOT(open())); action_Open->setIcon(QIcon::fromTheme("document-open")); QObject::connect(action_Save, SIGNAL(triggered()), this, SLOT(save())); action_Save->setIcon(QIcon::fromTheme("document-save")); QObject::connect(actionSave_As, SIGNAL(triggered()), this, SLOT(saveAs())); QObject::connect(action_Create_NSF, SIGNAL(triggered()), this, SLOT(unimplemented())); QObject::connect(actionCreate_WAV, SIGNAL(triggered()), this, SLOT(createWAV())); QObject::connect(actionImport_MIDI, SIGNAL(triggered()), this, SLOT(unimplemented())); QObject::connect(action_Configuration, SIGNAL(triggered()), this, SLOT(unimplemented())); QObject::connect(actionE_xit, SIGNAL(triggered()), this, SLOT(quit())); QObject::connect(actionModule_Properties, SIGNAL(triggered()), this, SLOT(moduleProperties())); QObject::connect(action_ViewToolbar, SIGNAL(toggled(bool)), this, SLOT(viewToolbar(bool))); QObject::connect(action_ViewStatusBar, SIGNAL(toggled(bool)), this, SLOT(viewStatusBar(bool))); QObject::connect(action_ViewControlpanel, SIGNAL(toggled(bool)), this, SLOT(viewControlpanel(bool))); QObject::connect(toolBar, SIGNAL(visibilityChanged(bool)), action_ViewToolbar, SLOT(setChecked(bool))); QObject::connect(controlPanel, SIGNAL(visibilityChanged(bool)), this, SLOT(controlPanelVisibilityChanged())); QObject::connect(action_About, SIGNAL(triggered()), this, SLOT(about())); QObject::connect(actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); QObject::connect(songs, SIGNAL(activated(int)), this, SLOT(setSong(int))); QObject::connect(incPattern, SIGNAL(clicked()), this, SLOT(incrementPattern())); QObject::connect(decPattern, SIGNAL(clicked()), this, SLOT(decrementPattern())); QObject::connect(instruments, SIGNAL(itemSelectionChanged()), this, SLOT(instrumentSelect())); QObject::connect(instrumentName, SIGNAL(textEdited(QString)), this, SLOT(instrumentNameChange(QString))); QObject::connect(instruments, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(instrumentDoubleClicked(QModelIndex))); QObject::connect(speed, SIGNAL(valueChanged(int)), this, SLOT(speedTempoChange(int))); QObject::connect(tempo, SIGNAL(valueChanged(int)), this, SLOT(speedTempoChange(int))); QObject::connect(rows, SIGNAL(valueChanged(int)), this, SLOT(rowsChange(int))); QObject::connect(frames, SIGNAL(valueChanged(int)), this, SLOT(framesChange(int))); QObject::connect(title, SIGNAL(editingFinished()), this, SLOT(changeSongTitle())); QObject::connect(author, SIGNAL(editingFinished()), this, SLOT(changeSongAuthor())); QObject::connect(copyright, SIGNAL(editingFinished()), this, SLOT(changeSongCopyright())); QObject::connect(action_Play, SIGNAL(triggered()), this, SLOT(play())); action_Play->setIcon(QIcon::fromTheme("media-playback-start")); QObject::connect(action_Stop, SIGNAL(triggered()), this, SLOT(stop())); action_Stop->setIcon(QIcon::fromTheme("media-playback-stop")); QObject::connect(actionToggle_edit_mode, SIGNAL(triggered()), this, SLOT(toggleEditMode())); actionToggle_edit_mode->setIcon(QIcon::fromTheme("media-record")); QObject::connect(addInstrument_button, SIGNAL(clicked()), this, SLOT(addInstrument_2A03())); addInstrument_button->setIcon(QIcon::fromTheme("list-add")); addInstrument_button->setText(tr("Add Instrument")); QObject::connect(removeInstrument_button, SIGNAL(clicked()), this, SLOT(removeInstrument())); removeInstrument_button->setIcon(QIcon::fromTheme("list-remove")); removeInstrument_button->setText(tr("Remove Instrument")); QObject::connect(editInstrument_button, SIGNAL(clicked()), this, SLOT(editInstrument())); editInstrument_button->setText(tr("Edit Instrument")); { QMenu *m = new QMenu(this); QAction *add2a03 = m->addAction(tr("New 2A03 Instrument")); QAction *addmmc5 = m->addAction(tr("New MMC5 Instrument")); QAction *addvrc6 = m->addAction(tr("New VRC6 Instrument")); QAction *addvrc7 = m->addAction(tr("New VRC7 Instrument")); QAction *addfds = m->addAction(tr("New FDS Instrument")); QObject::connect(add2a03, SIGNAL(triggered()), this, SLOT(addInstrument_2A03())); QObject::connect(addvrc6, SIGNAL(triggered()), this, SLOT(addInstrument_VRC6())); QObject::connect(addvrc7, SIGNAL(triggered()), this, SLOT(addInstrument_VRC7())); QObject::connect(addmmc5, SIGNAL(triggered()), this, SLOT(addInstrument_MMC5())); QObject::connect(addfds , SIGNAL(triggered()), this, SLOT(addInstrument_FDS())); m->setDefaultAction(add2a03); addInstrument_button->setMenu(m); } QObject::connect(step, SIGNAL(valueChanged(int)), this, SLOT(changeEditSettings())); QObject::connect(keyRepetition, SIGNAL(stateChanged(int)), this, SLOT(changeEditSettings())); { // recent files int capacity = gui::recentFileCapacity(); m_recentFiles = new QAction*[capacity]; for (int i = 0; i < capacity; i++) { QAction *a = new QAction(this); a->setVisible(false); connect(a, SIGNAL(triggered()), this, SLOT(openRecentFile())); m_recentFiles[i] = a; menuRecent->addAction(a); } // end recent files } reloadRecentFiles(); // the designer doesn't allow adding widgets { octave = new QComboBox; for (int i = 0; i < 8; i++) { octave->addItem(QString("%1").arg(i)); } connect(octave, SIGNAL(currentIndexChanged(int)), this, SLOT(octaveChange())); toolBar->addWidget(new QLabel(tr("Octave"))); toolBar->addWidget(octave); } // temporary style changing (for demonstration) { menu_View->addSeparator(); QMenu *styles = new QMenu(tr("Styles")); QAction *style_default = styles->addAction(tr("Default")); QAction *style_monochrome = styles->addAction(tr("Monochrome")); menu_View->addMenu(styles); connect(style_default, SIGNAL(triggered()), this, SLOT(selectDefaultStyle())); connect(style_monochrome, SIGNAL(triggered()), this, SLOT(selectMonochromeStyle())); } QMenu *m = new QMenu; m->addAction(tr("New 2A03 instrument")); actionAdd_instrument->setMenu(m); setDocInfo(m_app->activeDocInfo()); m_instrumenteditor = new InstrumentEditor(this); blockSignals(true); blockSignals(false); }
void QMenuProto::setDefaultAction(QAction *act) { QMenu *item = qscriptvalue_cast<QMenu*>(thisObject()); if (item) item->setDefaultAction(act); }
void RackWindow::createToolBars() { //main toolbar actions: QAction *fullscreenAct = new QAction(tr("Fullscreen"), this); fullscreenAct->setCheckable(true); QAction *enterSettingsAct = new QAction(tr("Change Widget Layout"), this); QAction *quitAct = new QAction(tr("Quit"), this); //main toolbar menus: QMenu *mainMenu = new QMenu(this); mainMenu->setObjectName("rackMainMenu"); QAction *titleAct = new QAction(tr("R.A.C.K."),this); titleAct->setDisabled(true); mainMenu->addAction(titleAct); mainMenu->setDefaultAction(titleAct); mainMenu->addAction(fullscreenAct); mainMenu->addAction(enterSettingsAct); mainMenu->addAction(quitAct); //main toolbar buttons: RPushButton *settingsButton = new RPushButton(tr("Menu")); settingsButton->setObjectName("rackSettingsButton"); settingsButton->setMenu(mainMenu); RBlinkButton *deleteButton = new RBlinkButton(tr("Delete")); deleteButton->setObjectName("rackDeleteButton"); RBlinkButton *previewButton = new RBlinkButton(tr("Preview")); previewButton->setObjectName("rackPreviewButton"); //main toolbar: QToolBar *mainToolBar = new QToolBar; mainToolBar->setObjectName("rackMainToolBar"); mainToolBar->setMovable(false); mainToolBar->addWidget(settingsButton); mainToolBar->addWidget(deleteButton); mainToolBar->addWidget(previewButton); //delete state: QObject::connect(deleteButton, SIGNAL(clicked()), m_coreImpl, SLOT(toggleDeleteState())); QObject::connect(m_coreImpl, SIGNAL(deleteStateChanged(bool)), deleteButton, SLOT(setBlinking(bool))); //preview state: QObject::connect(previewButton, SIGNAL(clicked()), m_coreImpl, SLOT(togglePreviewState())); QObject::connect(m_coreImpl, SIGNAL(previewStateChanged(bool)), previewButton, SLOT(setBlinking(bool))); //normal state: QObject::connect(this, SIGNAL(enterSettingsMode()), m_coreImpl, SLOT(setNormalState())); //main toolbar signals & slots: QObject::connect(fullscreenAct, SIGNAL(triggered(bool)), this, SLOT(toggleFullscreen())); QObject::connect(enterSettingsAct, SIGNAL(triggered()), SIGNAL(enterSettingsMode())); QObject::connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); QObject::connect(this, SIGNAL(enterSettingsMode()), mainToolBar, SLOT(hide())); QObject::connect(this, SIGNAL(leaveSettingsMode()), mainToolBar, SLOT(show())); /////////////////////////save tests QAction *saveAct = new QAction(tr("Save"), this); mainMenu->addAction(saveAct); QObject::connect(saveAct, SIGNAL(triggered()), this, SLOT(savePluginHosts())); //////////////////////////// /////////////////////////style sheet load QAction *styleAct = new QAction(tr("Load Style Sheet"), this); mainMenu->addAction(styleAct); QObject::connect(styleAct, SIGNAL(triggered()), this, SLOT(openStyleSheet())); //////////////////////////// /////////////////////////style sheet reload QAction *restyleAct = new QAction(tr("Reload Style Sheet"), this); mainMenu->addAction(restyleAct); QObject::connect(restyleAct, SIGNAL(triggered()), this, SLOT(loadStyleSheet())); //////////////////////////// //settings toolbar buttons: RPushButton *settingsOKButton = new RPushButton(tr("OK")); settingsOKButton->setObjectName("rackSettingsOKButton"); RPushButton *settingsCancelButton = new RPushButton(tr("Cancel")); settingsCancelButton->setObjectName("rackSettingsCancelButton"); //settings toolbar: QToolBar *settingsToolBar = new QToolBar; settingsToolBar->setObjectName("rackSettingsToolBar"); settingsToolBar->setMovable(false); settingsToolBar->addWidget(settingsOKButton); settingsToolBar->addWidget(settingsCancelButton); //settings toolbar signals & slots: QObject::connect(settingsOKButton, SIGNAL(clicked()), SIGNAL(leaveSettingsMode())); QObject::connect(this, SIGNAL(enterSettingsMode()), settingsToolBar, SLOT(show())); QObject::connect(this, SIGNAL(leaveSettingsMode()), settingsToolBar, SLOT(hide())); //add toolbars to mainwindow: addToolBar(Qt::BottomToolBarArea, mainToolBar); addToolBar(Qt::BottomToolBarArea, settingsToolBar); }
/** * 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(); }