void MainWindow::showContextMenu( QTableWidgetItem * item,bool itemClicked ) { QMenu m ; m.setFont( this->font() ) ; int row = item->row() ; QString mt = m_ui->tableWidget->item( row,1 )->text() ; QString device = m_ui->tableWidget->item( row,0 )->text() ; if( mt == "Nil" ){ connect( m.addAction( tr( "Mount" ) ),SIGNAL( triggered() ),this,SLOT( slotMount() ) ) ; }else{ QString mp = QString( "/run/media/private/%1/" ).arg( utility::userName() ) ; QString mp_1 = QString( "/home/%1/" ).arg( utility::userName() ) ; if( mt.startsWith( mp ) || mt.startsWith( mp_1 ) ){ connect( m.addAction( tr( "Unmount" ) ),SIGNAL( triggered() ),this,SLOT( pbUmount() ) ) ; m.addSeparator() ; QString fs = m_ui->tableWidget->item( row,2 )->text() ; if( fs != "encfs" ){ connect( m.addAction( tr( "Properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ; m.addSeparator() ; } m_sharedFolderPath = utility::sharedMountPointPath( mt ) ; if( m_sharedFolderPath.isEmpty() ){ connect( m.addAction( tr( "Open Folder" ) ),SIGNAL( triggered() ), this,SLOT( slotOpenFolder() ) ) ; }else{ connect( m.addAction( tr( "Open Private Folder" ) ),SIGNAL( triggered() ), this,SLOT( slotOpenFolder() ) ) ; connect( m.addAction( tr( "Open Shared Folder" ) ),SIGNAL( triggered() ), this,SLOT( slotOpenSharedFolder() ) ) ; } }else{ m_sharedFolderPath = utility::sharedMountPointPath( mt ) ; if( m_sharedFolderPath.isEmpty() ){ if( utility::pathIsReadable( mt ) ){ connect( m.addAction( tr( "Properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ; m.addSeparator() ; connect( m.addAction( tr( "Open Folder" ) ),SIGNAL( triggered() ), this,SLOT( slotOpenFolder() ) ) ; }else{ connect( m.addAction( tr( "Properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ; } }else{ connect( m.addAction( tr( "Properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ; m.addSeparator() ; connect( m.addAction( tr( "Open Shared Folder" ) ),SIGNAL( triggered() ), this,SLOT( slotOpenSharedFolder() ) ) ; } } } m.addSeparator() ; m.addAction( tr( "Close Menu" ) ) ; if( itemClicked ){ m.exec( QCursor::pos() ) ; }else{ QPoint p = this->pos() ; int x = p.x() + 100 + m_ui->tableWidget->columnWidth( 0 ) ; int y = p.y() + 50 + m_ui->tableWidget->rowHeight( 0 ) * item->row() ; p.setX( x ) ; p.setY( y ) ; m.exec( p ) ; } }
BlockingClient::BlockingClient(QWidget *parent) : QWidget(parent) { hostLabel = new QLabel(tr("&Server name:")); portLabel = new QLabel(tr("S&erver port:")); // find out which IP to connect to QString ipAddress; QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); break; } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); hostLineEdit = new QLineEdit(ipAddress); portLineEdit = new QLineEdit; portLineEdit->setValidator(new QIntValidator(1, 65535, this)); #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) Qt::InputMethodHint hints = Qt::ImhDigitsOnly; portLineEdit->setInputMethodHints(hints); #endif hostLabel->setBuddy(hostLineEdit); portLabel->setBuddy(portLineEdit); statusLabel = new QLabel(tr("This examples requires that you run the " "Fortune Server example as well.")); statusLabel->setWordWrap(true); #ifdef Q_OS_SYMBIAN QMenu *menu = new QMenu(this); fortuneAction = menu->addAction(tr("Get Fortune")); fortuneAction->setVisible(false); QAction *optionsAction = new QAction(tr("Options"), this); optionsAction->setMenu(menu); optionsAction->setSoftKeyRole(QAction::PositiveSoftKey); addAction(optionsAction); exitAction = new QAction(tr("Exit"), this); exitAction->setSoftKeyRole(QAction::NegativeSoftKey); addAction(exitAction); connect(fortuneAction, SIGNAL(triggered()), this, SLOT(requestNewFortune())); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); #else getFortuneButton = new QPushButton(tr("Get Fortune")); getFortuneButton->setDefault(true); getFortuneButton->setEnabled(false); quitButton = new QPushButton(tr("Quit")); buttonBox = new QDialogButtonBox; buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); connect(getFortuneButton, SIGNAL(clicked()), this, SLOT(requestNewFortune())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); #endif connect(hostLineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableGetFortuneButton())); connect(portLineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableGetFortuneButton())); //! [0] connect(&thread, SIGNAL(newFortune(QString)), this, SLOT(showFortune(QString))); //! [0] //! [1] connect(&thread, SIGNAL(error(int,QString)), this, SLOT(displayError(int,QString))); //! [1] QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(hostLabel, 0, 0); mainLayout->addWidget(hostLineEdit, 0, 1); mainLayout->addWidget(portLabel, 1, 0); mainLayout->addWidget(portLineEdit, 1, 1); mainLayout->addWidget(statusLabel, 2, 0, 1, 2); #ifndef Q_OS_SYMBIAN mainLayout->addWidget(buttonBox, 3, 0, 1, 2); #endif setLayout(mainLayout); setWindowTitle(tr("Blocking Fortune Client")); portLineEdit->setFocus(); }
void BitcoinGUI::createTrayIcon() { QMenu *trayIconMenu; #ifndef Q_OS_MAC trayIcon = new QSystemTrayIcon(this); trayIconMenu = new QMenu(this); trayIcon->setContextMenu(trayIconMenu); trayIcon->setToolTip(tr("GorillaBucks client")); trayIcon->setIcon(QIcon(":/icons/toolbar")); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); trayIcon->show(); #else // Note: On Mac, the dock icon is used to provide the tray's functionality. MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); dockIconHandler->setMainWindow((QMainWindow *)this); trayIconMenu = dockIconHandler->dockMenu(); #endif // Configuration of the tray icon (or dock icon) icon menu trayIconMenu->addAction(toggleHideAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(receiveCoinsAction); trayIconMenu->addAction(sendCoinsAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(signMessageAction); trayIconMenu->addAction(verifyMessageAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(optionsAction); trayIconMenu->addAction(openRPCConsoleAction); #ifndef Q_OS_MAC // This is built-in on Mac trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); #endif notificator = new Notificator(qApp->applicationName(), trayIcon); }
MailEditorMainWindow::MailEditorMainWindow(ATopLevelWindowsContainer* parent, AddressBookModel& abModel, IMailProcessor& mailProcessor, bool editMode) : ATopLevelWindow(parent), ui(new Ui::MailEditorWindow()), ABModel(abModel), MailProcessor(mailProcessor), FontCombo(nullptr), EditMode(editMode) { ui->setupUi(this); /** Disable these toolbars by default. They should be showed up on demand, when given action will be trigerred. */ ui->fileAttachementToolBar->hide(); ui->moneyAttachementToolBar->hide(); ui->editToolBar->hide(); ui->adjustToolbar->hide(); ui->formatToolBar->hide(); MoneyAttachement = new TMoneyAttachementWidget(ui->moneyAttachementToolBar); ui->moneyAttachementToolBar->addWidget(MoneyAttachement); FileAttachment = new TFileAttachmentWidget(ui->fileAttachementToolBar, editMode); ui->fileAttachementToolBar->addWidget(FileAttachment); MailFields = new MailFieldsWidget(*this, *ui->actionSend, abModel, editMode); /// Initially only basic mail fields (To: and Subject:) should be visible MailFields->showCcControls(false); MailFields->showBccControls(false); ui->mailFieldsToolBar->addWidget(MailFields); connect(MailFields, SIGNAL(subjectChanged(QString)), this, SLOT(onSubjectChanged(QString))); connect(MailFields, SIGNAL(recipientListChanged()), this, SLOT(onRecipientListChanged())); connect(FileAttachment, SIGNAL(attachmentListChanged()), this, SLOT(onAttachmentListChanged())); if(editMode) { /** Supplement definition of mailFieldSelectorToolbar since Qt Creator doesn't support putting into its context dedicated controls (like preconfigured toolbutton). Setup local menu for 'actionMailFields' toolButton (used to enable/disable additional mail field selection). */ QMenu* mailFieldsMenu = new QMenu(this); mailFieldsMenu->addAction(ui->actionFrom); mailFieldsMenu->addAction(ui->actionCC); mailFieldsMenu->addAction(ui->actionBCC); /// Update state of sub-menu commands. ui->actionBCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::BCC_FIELDS)); ui->actionCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::CC_FIELD)); ui->actionFrom->setChecked(MailFields->isFieldVisible(MailFieldsWidget::FROM_FIELD)); ui->actionMailFields->setMenu(mailFieldsMenu); ui->mainToolBar->insertAction(ui->actionShowFormatOptions, ui->actionMailFields); } setupEditorCommands(); ui->messageEdit->setFocus(); fontChanged(ui->messageEdit->font()); colorChanged(ui->messageEdit->textColor()); alignmentChanged(ui->messageEdit->alignment()); QString subject = MailFields->getSubject(); onSubjectChanged(subject); /// Clear modified flag ui->messageEdit->document()->setModified(false); setWindowModified(ui->messageEdit->document()->isModified()); ui->actionSave->setEnabled(ui->messageEdit->document()->isModified()); ui->actionUndo->setEnabled(ui->messageEdit->document()->isUndoAvailable()); ui->actionRedo->setEnabled(ui->messageEdit->document()->isRedoAvailable()); /// Setup command update ui related to 'save' option activity control and window modify marker. connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), ui->actionSave, SLOT(setEnabled(bool))); connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(ui->messageEdit, SIGNAL(addAttachments(QStringList)), this, SLOT(onAddAttachments(QStringList))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(onClipboardDataChanged())); #endif toggleReadOnlyMode(); }
void MainWindow::createMenus() { QMenu *menu; QAction *action; menu = getStandardMenu(FileMenu); menu->addAction(standardAction(New)); menu->addAction(standardAction(Print)); menu->addSeparator(); menu->addAction(standardAction(Exit)); menu = getStandardMenu(EditMenu); menu->addAction(standardAction(Undo)); menu->addAction(standardAction(Redo)); menu->addSeparator(); menu->addAction(standardAction(Cut)); menu->addAction(standardAction(Copy)); menu->addAction(standardAction(Paste)); menu->addSeparator(); menu->addAction(standardAction(Delete)); addStandardMenu(HelpMenu); }
void MainWindow::createMenus() { QMenuBar *bar = this->menuBar(); QMenu *fileMenu = new QMenu(tr("&File"), bar); fileMenu->addAction(newPostAct); fileMenu->addAction(openPostAct); fileMenu->addAction(closePostAct); fileMenu->addSeparator(); fileMenu->addAction(savePostAct); fileMenu->addAction(saveAsPostAct); fileMenu->addSeparator(); fileMenu->addAction(exitAct); bar->addMenu(fileMenu); QMenu *editMenu = new QMenu(tr("&Edit"), bar); editMenu->addAction(undoAct); editMenu->addAction(redoAct); editMenu->addSeparator(); editMenu->addAction(cutAct); editMenu->addAction(copyAct); editMenu->addAction(pasteAct); bar->addMenu(editMenu); QMenu *formatMenu = new QMenu(tr("F&ormat"), bar); formatMenu->addAction(textFontAct); formatMenu->addAction(textColorAct); formatMenu->addAction(textBackgroundColorAct); formatMenu->addSeparator(); QMenu *alignMenu = new QMenu(tr("Alignment"), formatMenu); if(QApplication::isLeftToRight()) { alignMenu->addAction(alignLeftAct); alignMenu->addAction(alignCenterAct); alignMenu->addAction(alignRightAct); } else { alignMenu->addAction(alignRightAct); alignMenu->addAction(alignCenterAct); alignMenu->addAction(alignLeftAct); } alignMenu->addAction(alignJustifyAct); formatMenu->addMenu(alignMenu); bar->addMenu(formatMenu); QMenu *insertMenu = new QMenu(tr("&Insert"), bar); QMenu *listMenu = new QMenu(tr("List"), insertMenu); listMenu->addAction(bulletListAct); listMenu->addAction(numberedListAct); listMenu->addSeparator(); listMenu->addAction(indentMoreAct); listMenu->addAction(indentLessAct); insertMenu->addMenu(listMenu); QMenu *tableMenu = createTableMenu(insertMenu); insertMenu->addMenu(tableMenu); bar->addMenu(insertMenu); QMenu *toolMenu = new QMenu(tr("&Tools"), bar); toolMenu->addAction(pluginAct); bar->addMenu(toolMenu); bar->addSeparator(); QMenu *helpMenu = new QMenu(tr("Help"), bar); helpMenu->addAction(helpAct); helpMenu->addAction(aboutAct); bar->addMenu(helpMenu); }
QgsCategorizedSymbolRendererV2Widget::QgsCategorizedSymbolRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer ) : QgsRendererV2Widget( layer, style ) , mRenderer( nullptr ) , mModel( nullptr ) { // try to recognize the previous renderer // (null renderer means "no previous renderer") if ( renderer ) { mRenderer = QgsCategorizedSymbolRendererV2::convertFromRenderer( renderer ); } if ( !mRenderer ) { mRenderer = new QgsCategorizedSymbolRendererV2( "", QgsCategoryList() ); } QString attrName = mRenderer->classAttribute(); mOldClassificationAttribute = attrName; // setup user interface setupUi( this ); mExpressionWidget->setLayer( mLayer ); cboCategorizedColorRamp->populate( mStyle ); int randomIndex = cboCategorizedColorRamp->findText( tr( "Random colors" ) ); if ( randomIndex != -1 ) { cboCategorizedColorRamp->setCurrentIndex( randomIndex ); } // set project default color ramp QString defaultColorRamp = QgsProject::instance()->readEntry( "DefaultStyles", "/ColorRamp", "" ); if ( defaultColorRamp != "" ) { int index = cboCategorizedColorRamp->findText( defaultColorRamp, Qt::MatchCaseSensitive ); if ( index >= 0 ) cboCategorizedColorRamp->setCurrentIndex( index ); } mCategorizedSymbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() ); mModel = new QgsCategorizedSymbolRendererV2Model( this ); mModel->setRenderer( mRenderer ); // update GUI from renderer updateUiFromRenderer(); viewCategories->setModel( mModel ); viewCategories->resizeColumnToContents( 0 ); viewCategories->resizeColumnToContents( 1 ); viewCategories->resizeColumnToContents( 2 ); viewCategories->setStyle( new QgsCategorizedSymbolRendererV2ViewStyle( viewCategories->style() ) ); connect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) ); connect( mExpressionWidget, SIGNAL( fieldChanged( QString ) ), this, SLOT( categoryColumnChanged( QString ) ) ); connect( viewCategories, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( categoriesDoubleClicked( const QModelIndex & ) ) ); connect( viewCategories, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) ); connect( btnChangeCategorizedSymbol, SIGNAL( clicked() ), this, SLOT( changeCategorizedSymbol() ) ); connect( btnAddCategories, SIGNAL( clicked() ), this, SLOT( addCategories() ) ); connect( btnDeleteCategories, SIGNAL( clicked() ), this, SLOT( deleteCategories() ) ); connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) ); connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) ); connect( cbxInvertedColorRamp, SIGNAL( toggled( bool ) ), this, SLOT( applyColorRamp() ) ); connect( cboCategorizedColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) ); connect( cboCategorizedColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) ); connect( mButtonEditRamp, SIGNAL( clicked() ), cboCategorizedColorRamp, SLOT( editSourceRamp() ) ); // menus for data-defined rotation/size QMenu* advMenu = new QMenu; advMenu->addAction( tr( "Match to saved symbols" ), this, SLOT( matchToSymbolsFromLibrary() ) ); advMenu->addAction( tr( "Match to symbols from file..." ), this, SLOT( matchToSymbolsFromXml() ) ); advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) ); btnAdvanced->setMenu( advMenu ); mExpressionWidget->registerGetExpressionContextCallback( &_getExpressionContext, this ); }
void MainWindow::createMenuBar() { QMenu *game = menuBar()->addMenu("&Game"); QMenu *gnew = game->addMenu("&New"); QMenu *help = menuBar()->addMenu("&Help"); gnew->addAction("&Easy", this, SLOT(newGameEasy())); gnew->addAction("&Normal", this, SLOT(newGameNormal())); gnew->addAction("&Hard", this, SLOT(newGameHard())); gnew->addAction("E&xpert", this, SLOT(newGameExpert())); game->addSeparator(); game->addAction("E&xit", qApp, SLOT(quit())); help->addAction("&About", qApp, SLOT(aboutQt())); }
Dialog::Dialog(QWidget *parent) : QDialog(parent, Qt::Tool | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint), ui(new Ui::Dialog), mSettings(new LxQt::Settings("lxqt-runner", this)), mGlobalShortcut(0), mLockCascadeChanges(false), mConfigureDialog(0) { ui->setupUi(this); setWindowTitle("LXQt Runner"); setAttribute(Qt::WA_TranslucentBackground); connect(LxQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(update())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(mSettings, SIGNAL(settingsChanged()), this, SLOT(applySettings())); ui->commandEd->installEventFilter(this); connect(ui->commandEd, SIGNAL(textChanged(QString)), this, SLOT(setFilter(QString))); connect(ui->commandEd, SIGNAL(returnPressed()), this, SLOT(runCommand())); mCommandItemModel = new CommandItemModel(this); ui->commandList->installEventFilter(this); ui->commandList->setModel(mCommandItemModel); ui->commandList->setEditTriggers(QAbstractItemView::NoEditTriggers); connect(ui->commandList, SIGNAL(clicked(QModelIndex)), this, SLOT(runCommand())); setFilter(""); dataChanged(); ui->commandList->setItemDelegate(new LxQt::HtmlDelegate(QSize(32, 32), ui->commandList)); // Popup menu ............................... QAction *a = new QAction(XdgIcon::fromTheme("configure"), tr("Configure"), this); connect(a, SIGNAL(triggered()), this, SLOT(showConfigDialog())); addAction(a); a = new QAction(XdgIcon::fromTheme("edit-clear-history"), tr("Clear History"), this); connect(a, SIGNAL(triggered()), mCommandItemModel, SLOT(clearHistory())); addAction(a); mPowerManager = new LxQt::PowerManager(this); addActions(mPowerManager->availableActions()); mScreenSaver = new LxQt::ScreenSaver(this); addActions(mScreenSaver->availableActions()); setContextMenuPolicy(Qt::ActionsContextMenu); QMenu *menu = new QMenu(this); menu->addActions(actions()); ui->actionButton->setMenu(menu); ui->actionButton->setIcon(XdgIcon::fromTheme("configure")); // End of popup menu ........................ applySettings(); connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(realign())); connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(realign())); connect(mGlobalShortcut, SIGNAL(activated()), this, SLOT(showHide())); connect(mGlobalShortcut, SIGNAL(shortcutChanged(QString,QString)), this, SLOT(shortcutChanged(QString,QString))); resize(mSettings->value("dialog/width", 400).toInt(), size().height()); // TEST connect(mCommandItemModel, SIGNAL(layoutChanged()), this, SLOT(dataChanged())); }
MainWindow::MainWindow() : QMainWindow() , m_view(new SvgView) { QMenu *fileMenu = new QMenu(tr("&File"), this); QAction *openAction = fileMenu->addAction(tr("&Open...")); openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); QAction *quitAction = fileMenu->addAction(tr("E&xit")); quitAction->setShortcuts(QKeySequence::Quit); menuBar()->addMenu(fileMenu); QMenu *viewMenu = new QMenu(tr("&View"), this); m_backgroundAction = viewMenu->addAction(tr("&Background")); m_backgroundAction->setEnabled(false); m_backgroundAction->setCheckable(true); m_backgroundAction->setChecked(false); connect(m_backgroundAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewBackground(bool))); m_outlineAction = viewMenu->addAction(tr("&Outline")); m_outlineAction->setEnabled(false); m_outlineAction->setCheckable(true); m_outlineAction->setChecked(true); connect(m_outlineAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewOutline(bool))); menuBar()->addMenu(viewMenu); QMenu *rendererMenu = new QMenu(tr("&Renderer"), this); m_nativeAction = rendererMenu->addAction(tr("&Native")); m_nativeAction->setCheckable(true); m_nativeAction->setChecked(true); #ifndef QT_NO_OPENGL m_glAction = rendererMenu->addAction(tr("&OpenGL")); m_glAction->setCheckable(true); #endif m_imageAction = rendererMenu->addAction(tr("&Image")); m_imageAction->setCheckable(true); #ifndef QT_NO_OPENGL rendererMenu->addSeparator(); m_highQualityAntialiasingAction = rendererMenu->addAction(tr("&High Quality Antialiasing")); m_highQualityAntialiasingAction->setEnabled(false); m_highQualityAntialiasingAction->setCheckable(true); m_highQualityAntialiasingAction->setChecked(false); connect(m_highQualityAntialiasingAction, SIGNAL(toggled(bool)), m_view, SLOT(setHighQualityAntialiasing(bool))); #endif QActionGroup *rendererGroup = new QActionGroup(this); rendererGroup->addAction(m_nativeAction); #ifndef QT_NO_OPENGL rendererGroup->addAction(m_glAction); #endif rendererGroup->addAction(m_imageAction); menuBar()->addMenu(rendererMenu); connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(rendererGroup, SIGNAL(triggered(QAction*)), this, SLOT(setRenderer(QAction*))); setCentralWidget(m_view); setWindowTitle(tr("SVG Viewer")); }
void MainWindow::on_treeView_customContextMenuRequested(const QPoint &pt) { QPoint globalPt = ui->treeView->mapToGlobal(pt); QModelIndex index = ui->treeView->indexAt(pt); QMenu menu; if (index.isValid()) { on_treeView_clicked(index); ProjectItem* item = (ProjectItem*) Workspace::Instance.GetProjectsModel()->itemFromIndex(index); switchToAct->setEnabled(!item->IsSelected()); menu.addAction(switchToAct); if(!item->IsDocument()) { menu.addAction(addImageAct); menu.addSeparator(); menu.addAction(saveProjctAct); menu.addAction(closeProjectAct); menu.addSeparator(); } else { menu.addAction(removeImageAct); menu.addSeparator(); } } menu.addAction(newProjectAct); menu.addAction(openProjectAct); menu.addSeparator(); menu.addAction(saveAllAct); menu.addAction(closeAllAct); menu.exec(globalPt); }
// ---------------------------------------------------------------------------- bool qMRMLTreeViewEventTranslator::translateEvent(QObject *Object, QEvent *Event, int EventType, bool &Error) { Q_UNUSED(Error); qMRMLTreeView* treeView = NULL; for(QObject* test = Object; treeView == NULL && test != NULL; test = test->parent()) { treeView = qobject_cast<qMRMLTreeView*>(test); } // qMRMLTreeView* treeView = qobject_cast<qMRMLTreeView*>(Object); if(!treeView) { return false; } // For the custom action when we have a right click QMenu* menu = NULL; for(QObject* test = Object; menu == NULL && test != NULL ; test = test->parent()) { menu = qobject_cast<QMenu*>(test); } if (menu) { if(Event->type() == QEvent::KeyPress) { QKeyEvent* e = static_cast<QKeyEvent*>(Event); if(e->key() == Qt::Key_Enter) { QAction* action = menu->activeAction(); if(action) { QString which = action->objectName(); if(which == QString::null) { which = action->text(); } if (which != "Rename" && which != "Delete" ) { emit recordEvent(menu, "activate", which); } } } } if(Event->type() == QEvent::MouseButtonRelease) { QMouseEvent* e = static_cast<QMouseEvent*>(Event); if(e->button() == Qt::LeftButton) { QAction* action = menu->actionAt(e->pos()); if (action && !action->menu()) { QString which = action->objectName(); if(which == QString::null) { which = action->text(); } if (which != "Rename" && which != "Delete" ) { emit recordEvent(menu, "activate", which); } } } } return true; } // We want to stop the action on the QDialog when we are renaming // and let passed the action for the "set_current". QInputDialog* dialog = NULL; for(QObject* test = Object; dialog == NULL && test != NULL; test = test->parent()) { dialog = qobject_cast<QInputDialog*>(test); if(dialog) { // block actions on the QInputDialog return true; } } if(Event->type() == QEvent::Enter && Object == treeView) { if(this->CurrentObject != Object) { if(this->CurrentObject) { disconnect(this->CurrentObject, 0, this, 0); } this->CurrentObject = Object; connect(treeView, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*))); connect(treeView, SIGNAL(currentNodeRenamed(QString)), this, SLOT(onCurrentNodeRenamed(QString))); // Can be better to do it on the model to recover the QModelIndex connect(treeView, SIGNAL(currentNodeDeleted(const QModelIndex&)), this, SLOT(onCurrentNodeDeleted(const QModelIndex&))); connect(treeView, SIGNAL(decorationClicked(QModelIndex)), this, SLOT(onDecorationClicked(QModelIndex))); connect(treeView->sceneModel(), SIGNAL(aboutToReparentByDragAndDrop(vtkMRMLNode*,vtkMRMLNode*)), this, SLOT(onAboutToReparentByDnD(vtkMRMLNode*,vtkMRMLNode*))); } return this->Superclass::translateEvent(Object, Event, EventType, Error); } return this->Superclass::translateEvent(Object, Event, EventType, Error); }
void CQTOpenGLLuaMainWindow::CreateEditActions() { QIcon cEditUndoIcon; cEditUndoIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/undo.png")); m_pcEditUndoAction = new QAction(cEditUndoIcon, tr("&Undo"), this); m_pcEditUndoAction->setToolTip(tr("Undo last operation")); m_pcEditUndoAction->setStatusTip(tr("Undo last operation")); m_pcEditUndoAction->setShortcut(QKeySequence::Undo); connect(m_pcEditUndoAction, SIGNAL(triggered()), m_pcCodeEditor, SLOT(undo())); QIcon cEditRedoIcon; cEditRedoIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/redo.png")); m_pcEditRedoAction = new QAction(cEditRedoIcon, tr("&Redo"), this); m_pcEditRedoAction->setToolTip(tr("Redo last operation")); m_pcEditRedoAction->setStatusTip(tr("Redo last operation")); m_pcEditRedoAction->setShortcut(QKeySequence::Redo); connect(m_pcEditRedoAction, SIGNAL(triggered()), m_pcCodeEditor, SLOT(redo())); QIcon cEditCopyIcon; cEditCopyIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/copy.png")); m_pcEditCopyAction = new QAction(cEditCopyIcon, tr("&Copy"), this); m_pcEditCopyAction->setToolTip(tr("Copy selected text into clipboard")); m_pcEditCopyAction->setStatusTip(tr("Copy selected text into clipboard")); m_pcEditCopyAction->setShortcut(QKeySequence::Copy); connect(m_pcEditCopyAction, SIGNAL(triggered()), m_pcCodeEditor, SLOT(copy())); QIcon cEditCutIcon; cEditCutIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/cut.png")); m_pcEditCutAction = new QAction(cEditCutIcon, tr("&Cut"), this); m_pcEditCutAction->setToolTip(tr("Move selected text into clipboard")); m_pcEditCutAction->setStatusTip(tr("Move selected text into clipboard")); m_pcEditCutAction->setShortcut(QKeySequence::Cut); connect(m_pcEditCutAction, SIGNAL(triggered()), m_pcCodeEditor, SLOT(cut())); QIcon cEditPasteIcon; cEditPasteIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/paste.png")); m_pcEditPasteAction = new QAction(cEditPasteIcon, tr("&Paste"), this); m_pcEditPasteAction->setToolTip(tr("Paste text from clipboard")); m_pcEditPasteAction->setStatusTip(tr("Paste text from clipboard")); m_pcEditPasteAction->setShortcut(QKeySequence::Paste); connect(m_pcEditPasteAction, SIGNAL(triggered()), m_pcCodeEditor, SLOT(paste())); // QIcon cEditFindIcon; // cEditFindIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/find.png")); // m_pcEditFindAction = new QAction(cEditFindIcon, tr("&Find/Replace"), this); // m_pcEditFindAction->setToolTip(tr("Find/replace text")); // m_pcEditFindAction->setStatusTip(tr("Find/replace text")); // m_pcEditFindAction->setShortcut(QKeySequence::Find); // connect(m_pcEditFindAction, SIGNAL(triggered()), // this, SLOT(Find())); QMenu* pcMenu = menuBar()->addMenu(tr("&Edit")); pcMenu->addAction(m_pcEditUndoAction); pcMenu->addAction(m_pcEditRedoAction); pcMenu->addSeparator(); pcMenu->addAction(m_pcEditCopyAction); pcMenu->addAction(m_pcEditCutAction); pcMenu->addAction(m_pcEditPasteAction); // pcMenu->addSeparator(); // pcMenu->addAction(m_pcEditFindAction); QToolBar* pcToolBar = addToolBar(tr("Edit")); pcToolBar->setObjectName("EditToolBar"); pcToolBar->setIconSize(QSize(32,32)); pcToolBar->addAction(m_pcEditUndoAction); pcToolBar->addAction(m_pcEditRedoAction); pcToolBar->addSeparator(); pcToolBar->addAction(m_pcEditCopyAction); pcToolBar->addAction(m_pcEditCutAction); pcToolBar->addAction(m_pcEditPasteAction); // pcToolBar->addAction(m_pcEditFindAction); }
void PathologyViewer::initializeGUIComponents(unsigned int level) { // Initialize the minimap std::vector<unsigned long long> overviewDimensions = _img->getLevelDimensions(level); unsigned int size = overviewDimensions[0] * overviewDimensions[1] * _img->getSamplesPerPixel(); unsigned char* overview = new unsigned char[size]; _img->getRawRegion<unsigned char>(0, 0, overviewDimensions[0], overviewDimensions[1], level, overview); QImage ovImg; if (_img->getColorType() == pathology::ARGB) { ovImg = QImage(overview, overviewDimensions[0], overviewDimensions[1], overviewDimensions[0] * 4, QImage::Format_ARGB32).convertToFormat(QImage::Format_RGB888); } else if (_img->getColorType() == pathology::RGB) { ovImg = QImage(overview, overviewDimensions[0], overviewDimensions[1], overviewDimensions[0] * 3, QImage::Format_RGB888); } QPixmap ovPixMap = QPixmap(QPixmap::fromImage(ovImg)); delete[] overview; if (_map) { _map->deleteLater(); _map = NULL; } _map = new MiniMap(ovPixMap, this); if (_scaleBar) { _scaleBar->deleteLater(); _scaleBar = NULL; } std::vector<double> spacing = _img->getSpacing(); if (!spacing.empty()) { _scaleBar = new ScaleBar(spacing[0], this); } else { _scaleBar = new ScaleBar(-1, this); } if (this->layout()) { delete this->layout(); } QHBoxLayout * Hlayout = new QHBoxLayout(this); QVBoxLayout * Vlayout = new QVBoxLayout(); QVBoxLayout * Vlayout2 = new QVBoxLayout(); Vlayout2->addStretch(4); Hlayout->addLayout(Vlayout2); Hlayout->addStretch(4); Hlayout->setContentsMargins(30, 30, 30, 30); Hlayout->addLayout(Vlayout, 1); Vlayout->addStretch(4); if (_map) { Vlayout->addWidget(_map, 1); } if (_scaleBar) { Vlayout2->addWidget(_scaleBar); } _map->setTileManager(_manager); QObject::connect(this, SIGNAL(updateBBox(const QRectF&)), _map, SLOT(updateFieldOfView(const QRectF&))); QObject::connect(_manager, SIGNAL(coverageUpdated()), _map, SLOT(onCoverageUpdated())); QObject::connect(_map, SIGNAL(positionClicked(QPointF)), this, SLOT(moveTo(const QPointF&))); QObject::connect(this, SIGNAL(fieldOfViewChanged(const QRectF&, const unsigned int)), _scaleBar, SLOT(updateForFieldOfView(const QRectF&))); if (this->window()) { _settings->beginGroup("ASAP"); QMenu* viewMenu = this->window()->findChild<QMenu*>("menuView"); if (viewMenu) { QList<QAction*> actions = viewMenu->actions(); for (QList<QAction*>::iterator it = actions.begin(); it != actions.end(); ++it) { if ((*it)->text() == "Toggle scale bar" && _scaleBar) { QObject::connect((*it), SIGNAL(toggled(bool)), _scaleBar, SLOT(setVisible(bool))); bool showComponent = _settings->value("scaleBarToggled", true).toBool(); (*it)->setChecked(showComponent); _scaleBar->setVisible(showComponent); } else if ((*it)->text() == "Toggle mini-map" && _map) { QObject::connect((*it), SIGNAL(toggled(bool)), _map, SLOT(setVisible(bool))); bool showComponent = _settings->value("miniMapToggled", true).toBool(); (*it)->setChecked(showComponent); _map->setVisible(showComponent); }
QgsVectorLayerProperties::QgsVectorLayerProperties( QgsVectorLayer *lyr, QWidget * parent, Qt::WindowFlags fl ) : QgsOptionsDialogBase( "VectorLayerProperties", parent, fl ) , layer( lyr ) , mMetadataFilled( false ) , mOriginalSubsetSQL( lyr->subsetString() ) , mSaveAsMenu( nullptr ) , mLoadStyleMenu( nullptr ) , mRendererDialog( nullptr ) , labelingDialog( nullptr ) , labelDialog( nullptr ) , actionDialog( nullptr ) , diagramPropertiesDialog( nullptr ) , mFieldsPropertiesDialog( nullptr ) { setupUi( this ); // QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states, // switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left), // and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots initOptionsBase( false ); QPushButton* b = new QPushButton( tr( "Style" ) ); QMenu* m = new QMenu( this ); mActionLoadStyle = m->addAction( tr( "Load Style" ), this, SLOT( loadStyle_clicked() ) ); mActionSaveStyleAs = m->addAction( tr( "Save Style" ), this, SLOT( saveStyleAs_clicked() ) ); m->addSeparator(); m->addAction( tr( "Save as Default" ), this, SLOT( saveDefaultStyle_clicked() ) ); m->addAction( tr( "Restore Default" ), this, SLOT( loadDefaultStyle_clicked() ) ); b->setMenu( m ); connect( m, SIGNAL( aboutToShow() ), this, SLOT( aboutToShowStyleMenu() ) ); buttonBox->addButton( b, QDialogButtonBox::ResetRole ); connect( lyr->styleManager(), SIGNAL( currentStyleChanged( QString ) ), this, SLOT( syncToLayer() ) ); connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) ); connect( this, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); connect( mOptionsStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( mOptionsStackedWidget_CurrentChanged( int ) ) ); fieldComboBox->setLayer( lyr ); displayFieldComboBox->setLayer( lyr ); connect( insertFieldButton, SIGNAL( clicked() ), this, SLOT( insertField() ) ); connect( insertExpressionButton, SIGNAL( clicked() ), this, SLOT( insertExpression() ) ); // connections for Map Tip display connect( htmlRadio, SIGNAL( toggled( bool ) ), htmlMapTip, SLOT( setEnabled( bool ) ) ); connect( htmlRadio, SIGNAL( toggled( bool ) ), insertFieldButton, SLOT( setEnabled( bool ) ) ); connect( htmlRadio, SIGNAL( toggled( bool ) ), fieldComboBox, SLOT( setEnabled( bool ) ) ); connect( htmlRadio, SIGNAL( toggled( bool ) ), insertExpressionButton, SLOT( setEnabled( bool ) ) ); connect( fieldComboRadio, SIGNAL( toggled( bool ) ), displayFieldComboBox, SLOT( setEnabled( bool ) ) ); if ( !layer ) return; QVBoxLayout *layout; if ( layer->hasGeometryType() ) { // Create the Labeling dialog tab layout = new QVBoxLayout( labelingFrame ); layout->setMargin( 0 ); labelingDialog = new QgsLabelingWidget( layer, QgisApp::instance()->mapCanvas(), labelingFrame ); labelingDialog->layout()->setContentsMargins( -1, 0, -1, 0 ); layout->addWidget( labelingDialog ); labelingFrame->setLayout( layout ); // Create the Labeling (deprecated) dialog tab layout = new QVBoxLayout( labelOptionsFrame ); layout->setMargin( 0 ); labelDialog = new QgsLabelDialog( layer->label(), labelOptionsFrame ); labelDialog->layout()->setMargin( 0 ); layout->addWidget( labelDialog ); labelOptionsFrame->setLayout( layout ); connect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) ); } else { labelingDialog = nullptr; labelDialog = nullptr; mOptsPage_Labels->setEnabled( false ); // disable labeling item mOptsPage_LabelsOld->setEnabled( false ); // disable labeling (deprecated) item } // Create the Actions dialog tab QVBoxLayout *actionLayout = new QVBoxLayout( actionOptionsFrame ); actionLayout->setMargin( 0 ); const QgsFields &fields = layer->fields(); actionDialog = new QgsAttributeActionDialog( layer->actions(), fields, actionOptionsFrame ); actionDialog->layout()->setMargin( 0 ); actionLayout->addWidget( actionDialog ); // Create the menu for the save style button to choose the output format mSaveAsMenu = new QMenu( this ); mSaveAsMenu->addAction( tr( "QGIS Layer Style File..." ) ); mSaveAsMenu->addAction( tr( "SLD File..." ) ); //Only if the provider support loading & saving styles to db add new choices if ( layer->dataProvider()->isSaveAndLoadStyleToDBSupported() ) { //for loading mLoadStyleMenu = new QMenu( this ); mLoadStyleMenu->addAction( tr( "Load from file..." ) ); mLoadStyleMenu->addAction( tr( "Load from database" ) ); //mActionLoadStyle->setContextMenuPolicy( Qt::PreventContextMenu ); mActionLoadStyle->setMenu( mLoadStyleMenu ); QObject::connect( mLoadStyleMenu, SIGNAL( triggered( QAction * ) ), this, SLOT( loadStyleMenuTriggered( QAction * ) ) ); //for saving mSaveAsMenu->addAction( tr( "Save in database (%1)" ).arg( layer->providerType() ) ); }
void CreateBlogMsg::setupFileActions() { QMenu *menu = new QMenu(tr("&File"), this); menuBar()->addMenu(menu); QAction *a; a = new QAction(QIcon(":/images/textedit/filenew.png"), tr("&New"), this); a->setShortcut(QKeySequence::New); connect(a, SIGNAL(triggered()), this, SLOT(fileNew())); menu->addAction(a); a = new QAction(QIcon(":/images/textedit/fileopen.png"), tr("&Open..."), this); a->setShortcut(QKeySequence::Open); connect(a, SIGNAL(triggered()), this, SLOT(fileOpen())); menu->addAction(a); menu->addSeparator(); actionSave = a = new QAction(QIcon(":/images/textedit/filesave.png"), tr("&Save"), this); a->setShortcut(QKeySequence::Save); connect(a, SIGNAL(triggered()), this, SLOT(fileSave())); a->setEnabled(false); menu->addAction(a); a = new QAction(tr("Save &As..."), this); connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs())); menu->addAction(a); menu->addSeparator(); a = new QAction(QIcon(":/images/textedit/fileprint.png"), tr("&Print..."), this); a->setShortcut(QKeySequence::Print); connect(a, SIGNAL(triggered()), this, SLOT(filePrint())); menu->addAction(a); a = new QAction(QIcon(":/images/textedit/fileprint.png"), tr("Print Preview..."), this); connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview())); menu->addAction(a); a = new QAction(QIcon(":/images/textedit/exportpdf.png"), tr("&Export PDF..."), this); a->setShortcut(Qt::CTRL + Qt::Key_D); connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf())); menu->addAction(a); menu->addSeparator(); a = new QAction(tr("&Quit"), this); a->setShortcut(Qt::CTRL + Qt::Key_Q); connect(a, SIGNAL(triggered()), this, SLOT(cancelMsg())); menu->addAction(a); }
QAction* Graphical_UI::createSaveMenu() {//octomap Menu QMenu* sm = menuBar()->addMenu(tr("&Save")); newMenuItem(sm, "&Save", SLOT(quickSaveAll()), "Save all stored point clouds with common coordinate frame to a pcd file", QKeySequence::Save, QIcon::fromTheme("document-save")); newMenuItem(sm, "Save &Feature Map...", SLOT(saveFeatures()), "Save all feature positions and descriptions in a common coordinate frame to a yaml or xml file", "Ctrl+F", QIcon::fromTheme("document-save")); QAction* oa = newMenuItem(sm, "Save Octomap...", SLOT(saveOctomap()), "Save computed OctoMap", "", QIcon::fromTheme("document-save-as")); newMenuItem(sm, "&Save as Point Cloud ...", SLOT(saveAll()), "Save all stored point clouds with common coordinate frame", QKeySequence::SaveAs, QIcon::fromTheme("document-save-as")); newMenuItem(sm, "&Save Point Cloud Node-Wise...", SLOT(saveIndividual()), "Save stored point clouds in individual files", "Ctrl+N", QIcon::fromTheme("document-save-all")); newMenuItem(sm, "Save &G2O Graph...", SLOT(saveG2OGraphDialog()), "Save G2O graph (e.g. for use with the g2o viewer or external optimization)", "", QIcon::fromTheme("document-save")); newMenuItem(sm, "Save Clouds to &Bag...", SLOT(saveBagDialog()), "Save clouds and transforms to bagfile", "Ctrl+Shift+B"); newMenuItem(sm, "Save Trajectory &Estimate...", SLOT(saveTrajectoryDialog()), "Save trajectory estimate (and ground truth trajectory if available) for external evaluation.", "Ctrl+E"); sm->addSeparator(); newMenuItem(sm, "&Send Model", SLOT(sendAll()), "Send out all stored point clouds with corrected transform", "Ctrl+M", QIcon::fromTheme("document-send")); sm->addSeparator(); newMenuItem(sm, "Save &3D as PDF File...", SLOT(saveVectorGraphic()), "Write 3D Scene to a PDF File. Warning: Meant for Pose Graphs not for the clouds or octomaps!", "", QIcon::fromTheme("application-pdf")); newMenuItem(sm, "Save Input &Images to Files...", SLOT(saveAllImages()), "Write All images shown in the gui to appropriate files", "", QIcon::fromTheme("image-x-generic")); newMenuItem(sm, "Capture Screencast...", this, SLOT(toggleScreencast(bool)), "Dump Screen as Video", !ParameterServer::instance()->get<std::string>("screencast_path_prefix").empty()); return oa; }
void CreateBlogMsg::setupTextActions() { QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon(":/images/textedit/textbold.png"),tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); //actionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); ui.toolBar_2->addAction(actionTextBold); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon(":/images/textedit/textitalic.png"),tr("&Italic"), this); //actionTextItalic->setPriority(QAction::LowPriority); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); ui.toolBar_2->addAction(actionTextItalic); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon(":/images/textedit/textunder.png"),tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); //actionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); ui.toolBar_2->addAction(actionTextUnderline); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"),tr("&Left"), grp); actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon(":/images/textedit/textjustify.png"), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); //actionAlignLeft->setPriority(QAction::LowPriority); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); //actionAlignCenter->setPriority(QAction::LowPriority); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); //actionAlignRight->setPriority(QAction::LowPriority); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); //actionAlignJustify->setPriority(QAction::LowPriority); ui.toolBar_2->addActions(grp->actions()); menu->addActions(grp->actions()); menu->addSeparator(); QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Text Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); ui.toolBar_2->addAction(actionTextColor); menu->addAction(actionTextColor); menu->addAction(ui.actionOrderedlist); menu->addAction(ui.actionUnorderedlist); menu->addAction(ui.actionBlockquoute); /*comboStyle = new QComboBox(ui.toolBar_2); ui.toolBar_2->addWidget(comboStyle); comboStyle->addItem("Paragraph"); comboStyle->addItem("Heading 1"); comboStyle->addItem("Heading 2"); comboStyle->addItem("Heading 3"); comboStyle->addItem("Heading 4"); comboStyle->addItem("Heading 5"); comboStyle->addItem("Heading 6"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(changeFormatType(int)));*/ comboFont = new QFontComboBox(ui.toolBar_2); ui.toolBar_2->addWidget(comboFont); connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString))); comboSize = new QComboBox(ui.toolBar_2); comboSize->setObjectName("comboSize"); ui.toolBar_2->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); }
QMenu* MainWindow::createTableMenu(QWidget *parent /* = 0 */) { QMenu *tableMenu = new QMenu(tr("Table"), parent); tableMenu->addAction(tableInsertAct); tableMenu->addSeparator(); tableMenu->addAction(tablePropAct); tableMenu->addAction(tableRowPropAct); tableMenu->addAction(tableColPropAct); tableMenu->addAction(tableCellPropAct); tableMenu->addAction(tableCellPropAct); tableMenu->addSeparator(); tableMenu->addAction(tableInsertRowUpAct); tableMenu->addAction(tableInsertRowDownAct); tableMenu->addAction(tableRowUpAct); tableMenu->addAction(tableRowDownAct); tableMenu->addSeparator(); tableMenu->addAction(tableInsertColLeftAct); tableMenu->addAction(tableInsertColRightAct); tableMenu->addAction(tableColLeftAct); tableMenu->addAction(tableColRightAct); tableMenu->addSeparator(); tableMenu->addAction(tableDelAct); tableMenu->addAction(tableDelRowAct); tableMenu->addAction(tableDelColAct); tableMenu->addSeparator(); tableMenu->addAction(tableCellClearAct); return tableMenu; }
// ??? Break this stuff off into an InstrumentPopup class. This class is too // big. void TrackButtons::populateInstrumentPopup(Instrument *thisTrackInstr, QMenu* instrumentPopup) { // pixmaps for icons to show connection states as variously colored boxes // ??? Factor out the icon-related stuff to make this routine clearer. // getIcon(Instrument *) would be ideal, but might not be easy. // getIcon(Device *) would also be needed. static QPixmap connectedPixmap, unconnectedPixmap, connectedUsedPixmap, unconnectedUsedPixmap, connectedSelectedPixmap, unconnectedSelectedPixmap; static bool havePixmaps = false; if (!havePixmaps) { IconLoader il; connectedPixmap = il.loadPixmap("connected"); connectedUsedPixmap = il.loadPixmap("connected-used"); connectedSelectedPixmap = il.loadPixmap("connected-selected"); unconnectedPixmap = il.loadPixmap("unconnected"); unconnectedUsedPixmap = il.loadPixmap("unconnected-used"); unconnectedSelectedPixmap = il.loadPixmap("unconnected-selected"); havePixmaps = true; } Composition &comp = m_doc->getComposition(); // clear the popup instrumentPopup->clear(); QMenu *currentSubMenu = 0; // position index int count = 0; int currentDevId = -1; // Get the list Studio &studio = m_doc->getStudio(); InstrumentList list = studio.getPresentationInstruments(); // For each instrument for (InstrumentList::iterator it = list.begin(); it != list.end(); ++it) { if (!(*it)) continue; // sanity check // get the Localized instrument name, with the string hackery performed // in Instrument QString iname((*it)->getLocalizedPresentationName()); // translate the program name // // Note we are converting the string from std to Q back to std then to // C. This is obviously ridiculous, but the fact that we have programName // here at all makes me think it exists as some kind of necessary hack // to coax tr() into behaving nicely. I decided to change it as little // as possible to get it to compile, and not refactor this down to the // simplest way to call tr() on a C string. QString programName(strtoqstr((*it)->getProgramName())); programName = QObject::tr(programName.toStdString().c_str()); Device *device = (*it)->getDevice(); DeviceId devId = device->getId(); bool connectedIcon = false; // Determine the proper program name and whether it is connected if ((*it)->getType() == Instrument::SoftSynth) { programName = ""; AudioPluginInstance *plugin = (*it)->getPlugin(Instrument::SYNTH_PLUGIN_POSITION); if (plugin) { // we don't translate any plugin program names or other texts programName = strtoqstr(plugin->getDisplayName()); connectedIcon = (plugin->getIdentifier() != ""); } } else if ((*it)->getType() == Instrument::Audio) { connectedIcon = true; } else { QString conn = RosegardenSequencer::getInstance()-> getConnection(devId); connectedIcon = (conn != ""); } // These two are for selecting the correct icon to display. bool instrUsedByMe = false; bool instrUsedByAnyone = false; if (thisTrackInstr && thisTrackInstr->getId() == (*it)->getId()) { instrUsedByMe = true; instrUsedByAnyone = true; } // If we have switched to a new device, we'll create a new submenu if (devId != (DeviceId)(currentDevId)) { currentDevId = int(devId); // For selecting the correct icon to display. bool deviceUsedByAnyone = false; if (instrUsedByMe) deviceUsedByAnyone = true; else { for (Composition::trackcontainer::iterator tit = comp.getTracks().begin(); tit != comp.getTracks().end(); ++tit) { if (tit->second->getInstrument() == (*it)->getId()) { instrUsedByAnyone = true; deviceUsedByAnyone = true; break; } Instrument *instr = studio.getInstrumentById(tit->second->getInstrument()); if (instr && (instr->getDevice()->getId() == devId)) { deviceUsedByAnyone = true; } } } QIcon icon (connectedIcon ? (deviceUsedByAnyone ? connectedUsedPixmap : connectedPixmap) : (deviceUsedByAnyone ? unconnectedUsedPixmap : unconnectedPixmap)); // Create a submenu for this device QMenu *subMenu = new QMenu(instrumentPopup); subMenu->setMouseTracking(true); subMenu->setIcon(icon); // Not needed so long as AA_DontShowIconsInMenus is false. //subMenu->menuAction()->setIconVisibleInMenu(true); // Menu title QString deviceName = QObject::tr(device->getName().c_str()); subMenu->setTitle(deviceName); // QObject name subMenu->setObjectName(deviceName); // Add the submenu to the popup menu instrumentPopup->addMenu(subMenu); // Connect the submenu to slotInstrumentSelected() connect(subMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotInstrumentSelected(QAction*))); currentSubMenu = subMenu; } else if (!instrUsedByMe) {
void BitcoinGUI::createMenuBar() { #ifdef Q_OS_MAC // Create a decoupled menu bar on Mac which stays even if the window is closed appMenuBar = new QMenuBar(); #else // Get the main window's menu bar on other platforms appMenuBar = menuBar(); #endif // Configure the menus QMenu *file = appMenuBar->addMenu(tr("&File")); file->addAction(backupWalletAction); file->addAction(exportAction); file->addAction(signMessageAction); file->addAction(verifyMessageAction); file->addSeparator(); file->addAction(quitAction); QMenu *settings = appMenuBar->addMenu(tr("&Settings")); settings->addAction(encryptWalletAction); settings->addAction(changePassphraseAction); settings->addAction(unlockWalletAction); settings->addAction(lockWalletAction); settings->addSeparator(); settings->addAction(optionsAction); QMenu *help = appMenuBar->addMenu(tr("&Help")); help->addAction(openRPCConsoleAction); help->addSeparator(); help->addAction(aboutAction); help->addAction(aboutQtAction); }
void CameraMainWindow::delayedInit() { settingsDialog = new QDialog( this ); settingsDialog->setModal( true ); settings = new Ui::CameraSettings(); settings->setupUi( settingsDialog ); settingsDialog->setObjectName( "settings" ); // To pick up correct help. connect( settings->photo_quality, SIGNAL(valueChanged(int)), settings->photo_quality_n, SLOT(setNum(int)) ); QFileSystemFilter *fsf = new QFileSystemFilter; fsf->documents = QFileSystemFilter::Set; settings->location->setFilter(fsf); // load settings from config QSettings cfg("Trolltech","Camera"); cfg.beginGroup("General"); QString l = cfg.value("location").toString(); if ( !l.isEmpty() ) settings->location->setLocation(l); else settings->location->setLocation(QFileSystem::documentsFileSystem().documentsPath()); storagepath = settings->location->documentPath(); cfg.endGroup(); cfg.beginGroup("Photo"); int w; w = cfg.value("width",camera->videocaptureview->recommendedPhotoSize().width()).toInt(); for (psize=0; psize<(int)photo_size.count()-1 && photo_size[psize].width() > w;) psize++; pquality = cfg.value("quality",settings->photo_quality->value()).toInt(); cfg.endGroup(); cfg.beginGroup("Video"); w = cfg.value("width",camera->videocaptureview->recommendedVideoSize().width()).toInt(); for (vsize=0; vsize<(int)video_size.count()-1 && video_size[vsize].width() > w;) vsize++; vquality = cfg.value("quality",settings->video_quality->value()).toInt(); vframerate = cfg.value("framerate",settings->video_framerate->value()).toInt(); for (int i=0; i<(int)photo_size.count(); i++) { settings->photo_size->addItem(tr("%1 x %2","picture size e.g. 640 x 480").arg(photo_size[i].width()).arg(photo_size[i].height())); } for (int i=0; i<(int)video_size.count(); i++) { settings->video_size->addItem(tr("%1 x %2","picture size e.g. 640 x 480").arg(video_size[i].width()).arg(video_size[i].height())); } QMimeType m( QLatin1String( "image/jpeg" )); QContent a = m.application(); QIcon picViewIcon = a.icon(); if ( picViewIcon.isNull() ) picViewIcon = QIcon( QLatin1String( ":icon/view" )); if ( video_supported ) { // If video_supported is ever not a constant false then ensure // an application is available to handle it if ( a.isValid() ) { a_vview = new QAction( QIcon(":image/"+a.iconName()), QString("%1...").arg(a.name()), this ); connect( a_vview, SIGNAL(triggered()), this, SLOT(viewVideos()) ); } } else { a_vview = 0; } a_pview = new QAction( QIcon(), tr( "View pictures" ), this ); a_pview->setIcon(picViewIcon); connect( a_pview, SIGNAL(triggered()), this, SLOT(viewPictures()) ); a_timer = new QAction( QIcon( ":icon/wait" ) , tr("Timer"), this ); connect( a_timer, SIGNAL(triggered()), this, SLOT(takePhotoTimer()) ); if(camera->videocaptureview->available()) { a_settings = new QAction( QIcon( ":icon/settings" ) , tr("Settings..."), this ); connect( a_settings, SIGNAL(triggered()), this, SLOT(doSettings()) ); } a_th_edit = new QAction( QIcon(":icon/edit"), tr("Edit"), this ); connect( a_th_edit, SIGNAL(triggered()), this, SLOT(editThumb()) ); a_th_del = new QAction( QIcon(":icon/trash"), tr("Delete"), this ); connect( a_th_del, SIGNAL(triggered()), this, SLOT(delThumb()) ); a_th_add = new QAction( QIcon(":image/addressbook/AddressBook"), tr("Save to Contact..."), this ); connect( a_th_add, SIGNAL(triggered()), this, SLOT(moveToContact()) ); a_send = new QAction( QIcon( ":icon/beam" ), tr("Send to Contact..."), this ); connect( a_send, SIGNAL(triggered()), this, SLOT(sendFile()) ); a_zoom = new QAction( QIcon( ), tr("Zoom"), this); connect(a_zoom, SIGNAL(triggered()), this, SLOT(showZoom())); m_zoom = new QSlider(this); m_zoom->setSliderPosition(50); m_zoom->setOrientation(Qt::Horizontal); m_zoom->setRange(camera->videocaptureview->minZoom(),camera->videocaptureview->maxZoom()); m_zoom->setValue(0); m_zoom->setGeometry(width()*1/5, height()*2/3, 60*width()/100, 40*height()/100); m_zoom->hide(); connect(m_zoom, SIGNAL(valueChanged(int)), this, SLOT(zoomChanged(int))); QMenu *contextMenu = QSoftMenuBar::menuFor(this); if(camera->videocaptureview->available()) { contextMenu->addAction( a_pview ); if ( video_supported ) contextMenu->addAction( a_vview ); contextMenu->addAction( a_th_edit ); contextMenu->addAction( a_th_del ); contextMenu->addAction( a_th_add ); contextMenu->addAction( a_timer ); contextMenu->addAction( a_send ); contextMenu->addAction( a_settings ); contextMenu->addAction( a_zoom ); } connect(contextMenu, SIGNAL(aboutToHide()), this, SLOT(contextMenuAboutToHide())); connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(contextMenuAboutToShow())); QSignalMapper* sm = new QSignalMapper(this); for (int i=0; i<nthumb; i++) { sm->setMapping(thumb[i],i); connect(thumb[i],SIGNAL(clicked()),sm,SLOT(map())); thumb[i]->installEventFilter(this); } connect(sm,SIGNAL(mapped(int)),this,SLOT(thumbClicked(int))); installEventFilter(camera->photo); installEventFilter(camera->video); camera->photo->installEventFilter(this); camera->video->installEventFilter(this); loadThumbs(); preview(); }
void MainWindow::context_menu(const QPoint& pos) { // for most widgets QPoint globalPos = ui->tableView->mapToGlobal(pos); //myWidget->mapToGlobal(pos); // for QAbstractScrollArea and derived classes you would use: // QPoint globalPos = myWidget->viewport()->mapToGlobal(pos); QMenu myMenu; myMenu.setFocusPolicy(Qt::NoFocus); myMenu.addAction(trUtf8("Συνέχιση εργασίας")); myMenu.addAction(trUtf8("Kλήση πελάτη")); // ... QAction* selectedItem = myMenu.exec(globalPos); if (selectedItem) { QSqlQuery query(db1); QString t_id=tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),0)).toString(); query.exec("select t.cusid,t.placeid,t.projectid,t.comment from tasks t where id="+t_id); query.next(); this->cusid=query.value(0).toString(); QString t_cusid=cusid=query.value(0).toString(); if(selectedItem->text()==trUtf8("Συνέχιση εργασίας")) { refresh_places(); refresh_projects(); ui->label_customer->setText(tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),1)).toString()); ui->textEdit->setPlainText(query.value(3).toString()); for (int i=0;i<ui->comboplace->count();++i) { ui->comboplace->setCurrentIndex(i); if (places_model->data(places_model->index(ui->comboplace->currentIndex(),0))==query.value(1).toInt()) break; } for (int i=0;i<ui->comboproject->count();++i) { ui->comboproject->setCurrentIndex(i); if (project_model->data(project_model->index(ui->comboproject->currentIndex(),0))==query.value(2).toInt()) break; } ui->pushHour->setEnabled(TRUE); } else { query.exec("select phone from customers where id="+t_cusid); query.next(); QString phone=query.value(0).toString(); dial(phone); } } return; }
void QgsLegendLayer::addToPopupMenu( QMenu& theMenu ) { QgsMapLayer *lyr = layer(); QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing(); // zoom to layer extent theMenu.addAction( QgsApplication::getThemeIcon( "/mActionZoomToLayer.png" ), tr( "&Zoom to Layer Extent" ), legend(), SLOT( legendLayerZoom() ) ); if ( lyr->type() == QgsMapLayer::RasterLayer ) { theMenu.addAction( tr( "&Zoom to Best Scale (100%)" ), legend(), SLOT( legendLayerZoomNative() ) ); QgsRasterLayer *rasterLayer = qobject_cast<QgsRasterLayer *>( lyr ); if ( rasterLayer && rasterLayer->rasterType() != QgsRasterLayer::Palette ) { theMenu.addAction( tr( "&Stretch Using Current Extent" ), legend(), SLOT( legendLayerStretchUsingCurrentExtent() ) ); } } // show in overview QAction* showInOverviewAction = theMenu.addAction( tr( "&Show in Overview" ), this, SLOT( showInOverview() ) ); showInOverviewAction->setCheckable( true ); showInOverviewAction->blockSignals( true ); showInOverviewAction->setChecked( mLyr.isInOverview() ); showInOverviewAction->blockSignals( false ); // remove from canvas theMenu.addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.png" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) ); // duplicate layer QAction* duplicateLayersAction = theMenu.addAction( QgsApplication::getThemeIcon( "/mActionAddMap.png" ), tr( "&Duplicate" ), QgisApp::instance(), SLOT( duplicateLayers() ) ); // set layer crs theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) ); // assign layer crs to project theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &Project CRS from Layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) ); theMenu.addSeparator(); if ( lyr->type() == QgsMapLayer::VectorLayer ) { QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( lyr ); // attribute table theMenu.addAction( QgsApplication::getThemeIcon( "/mActionOpenTable.png" ), tr( "&Open Attribute Table" ), QgisApp::instance(), SLOT( attributeTable() ) ); // allow editing int cap = vlayer->dataProvider()->capabilities(); if ( cap & QgsVectorDataProvider::EditingCapabilities ) { if ( toggleEditingAction ) { theMenu.addAction( toggleEditingAction ); toggleEditingAction->setChecked( vlayer->isEditable() ); } } // disable duplication of memory layers if ( vlayer->storageType() == "Memory storage" && legend()->selectedLayers().count() == 1 ) { duplicateLayersAction->setEnabled( false ); } // save as vector file theMenu.addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) ); // save selection as vector file QAction* saveSelectionAsAction = theMenu.addAction( tr( "Save Selection As..." ), QgisApp::instance(), SLOT( saveSelectionAsVectorFile() ) ); if ( vlayer->selectedFeatureCount() == 0 ) { saveSelectionAsAction->setEnabled( false ); } if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() && vlayer->vectorJoins().isEmpty() ) theMenu.addAction( tr( "&Query..." ), QgisApp::instance(), SLOT( layerSubsetString() ) ); //show number of features in legend if requested QAction* showNFeaturesAction = new QAction( tr( "Show Feature Count" ), &theMenu ); showNFeaturesAction->setCheckable( true ); showNFeaturesAction->setChecked( mShowFeatureCount ); QObject::connect( showNFeaturesAction, SIGNAL( toggled( bool ) ), this, SLOT( setShowFeatureCount( bool ) ) ); theMenu.addAction( showNFeaturesAction ); theMenu.addSeparator(); }
QMenuBar *TeamBuilder::createMenuBar(MainEngine *w) { QMenuBar *menuBar = new QMenuBar(); menuBar->setObjectName("TeamBuilder"); QMenu *fileMenu = menuBar->addMenu(tr("&File")); fileMenu->addAction(tr("&New"),this,SLOT(newTeam()),tr("Ctrl+N", "New")); fileMenu->addAction(tr("&Save all"),this,SLOT(saveAll()),tr("Ctrl+S", "Save all")); fileMenu->addAction(tr("&Load all"),this,SLOT(openLoadWindow()),tr("Ctrl+L", "Load all")); fileMenu->addSeparator(); fileMenu->addAction(tr("&Quit"),qApp,SLOT(quit()),tr("Ctrl+Q", "Quit")); QMenu *teamMenu = menuBar->addMenu(tr("&Team")); if (currentWidget() && currentWidget() == this->teamMenu) { teamMenu->addAction(tr("Choose pokemon"), this->teamMenu, SLOT(choosePokemon()), tr("Alt+E", "Choose Pokemon")); } teamMenu->addAction(tr("Trainer Menu"), this, SLOT(switchToTrainer()), tr("Ctrl+B", "Trainer Menu")); teamMenu->addSeparator(); teamMenu->addAction(tr("&Add team"), this, SLOT(addTeam()), tr("Ctrl+A", "Add team")); teamMenu->addAction(tr("&Load team"), this, SLOT(openTeam()), tr("Ctrl+Shift+L", "Load team")); teamMenu->addAction(tr("&Save team"), this, SLOT(saveTeam()), tr("Ctrl+Shift+S", "Save team")); teamMenu->addAction(tr("&Import team"), this, SLOT(importTeam()), tr("Ctrl+I", "Import team")); teamMenu->addAction(tr("&Export team"), this, SLOT(exportTeam()), tr("Ctrl+E", "Export team")); teamMenu->addSeparator(); teamMenu->addAction(tr("Import from Android"), this, SLOT(importAndroid()), tr("Ctrl+Shift+I", "Import from Android")); teamMenu->addAction(tr("Export to Android"), this, SLOT(exportAndroid()), tr("Ctrl+Shift+E", "Export to Android")); currentWidget()->addMenus(menuBar); /* Loading mod menu */ QMenu *menuMods = menuBar->addMenu(tr("&Mods")); QActionGroup *group = new QActionGroup(menuMods); QString currentMod = PokemonInfoConfig::currentMod(); // No mod option. QAction *noMod = menuMods->addAction(tr("&No mod"), this, SLOT(setNoMod())); noMod->setCheckable(true); noMod->setChecked(currentMod.length()==0); group->addAction(noMod); menuMods->addSeparator(); QStringList mods = PokemonInfoConfig::availableMods(); foreach(QString smod, mods) { QAction *mod = menuMods->addAction(smod, this, SLOT(changeMod())); mod->setProperty("name", smod); mod->setCheckable(true); mod->setChecked(currentMod == smod); group->addAction(mod); }
void MainWindow::setupMenu() { QMenu* fileMenu = new QMenu(tr("&File"), this); menuBar()->addMenu(fileMenu); fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()), QKeySequence(tr("Ctrl+O", "File|Open"))); fileMenu->addAction(tr("&Save ASM..."), this, SLOT(saveFile()), QKeySequence(tr("Ctrl+S", "File|Save ASM"))); fileMenu->addAction(tr("E&xit"), qApp, SLOT(quit()), QKeySequence(tr("Ctrl+Q", "File|Exit"))); QMenu* disassmMenu = new QMenu(tr("&Disassm"), this); menuBar()->addMenu(disassmMenu); disassmMenu->addAction(tr("&Code"), _disassembler_widget, SLOT(makeCodeUnderCursor()), QKeySequence(tr("C", "Disassm|Code"))); disassmMenu->addSeparator(); disassmMenu->addAction(tr("Comment command..."), _disassembler_widget, SLOT(commentCommandUnderCursor()), QKeySequence(tr(";", "Disassm|Comment command"))); disassmMenu->addAction(tr("change &Name..."), _disassembler_widget, SLOT(changeNameUnderCursor()), QKeySequence(tr("N", "Disassm|change Name"))); QMenu* toolsMenu = new QMenu(tr("&Tools"), this); menuBar()->addMenu(toolsMenu); toolsMenu->addAction(tr("&Load guesses..."), this, SLOT(loadGuesses()), QKeySequence(tr("Ctrl+L", "File|Load"))); }
void BitcoinGUI::createMenuBar() { #ifdef Q_OS_MAC appMenuBar = new QMenuBar(); #else appMenuBar = menuBar(); #endif // Configure the menus QMenu *file = appMenuBar->addMenu(tr("&File")); file->addAction(backupWalletAction); file->addAction(exportAction); file->addAction(signMessageAction); file->addAction(verifyMessageAction); file->addSeparator(); file->addAction(quitAction); QMenu *settings = appMenuBar->addMenu(tr("&Settings")); settings->addAction(encryptWalletAction); settings->addAction(changePassphraseAction); settings->addAction(unlockWalletAction); settings->addAction(lockWalletAction); settings->addSeparator(); settings->addAction(optionsAction); QMenu *help = appMenuBar->addMenu(tr("&Help")); help->addAction(openRPCConsoleAction); help->addSeparator(); help->addAction(aboutAction); help->addAction(aboutQtAction); }
void BitcoinGUI::createTrayIconMenu() { QMenu *trayIconMenu; #ifndef Q_OS_MAC // return if trayIcon is unset (only on non-Mac OSes) if (!trayIcon) return; trayIconMenu = new QMenu(this); trayIcon->setContextMenu(trayIconMenu); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); #else // Note: On Mac, the dock icon is used to provide the tray's functionality. MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); dockIconHandler->setMainWindow((QMainWindow *)this); trayIconMenu = dockIconHandler->dockMenu(); #endif // Configuration of the tray icon (or dock icon) icon menu trayIconMenu->addAction(toggleHideAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(sendCoinsAction); trayIconMenu->addAction(receiveCoinsAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(signMessageAction); trayIconMenu->addAction(verifyMessageAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(optionsAction); trayIconMenu->addAction(openRPCConsoleAction); #ifndef Q_OS_MAC // This is built-in on Mac trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); #endif }
/** * 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_name = account.accountInfo.name.isEmpty() ? account.username : account.accountInfo.name; QString text = text_name + " (" + 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(); }
void ProgramWindow::setup(const QList<LinkedFile *> & linkedFiles, const QString & alternativePath) { resize(500,700); setAttribute(Qt::WA_DeleteOnClose, true); QFrame * mainFrame = new QFrame(this); QFrame * headerFrame = createHeader(); QFrame * centerFrame = createCenter(); layout()->setMargin(0); layout()->setSpacing(0); QGridLayout *layout = new QGridLayout(mainFrame); layout->setMargin(0); layout->setSpacing(0); layout->addWidget(headerFrame,0,0); layout->addWidget(centerFrame,1,0); setCentralWidget(mainFrame); setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); QSettings settings; if (!settings.value("programwindow/state").isNull()) { restoreState(settings.value("programwindow/state").toByteArray()); } if (!settings.value("programwindow/geometry").isNull()) { restoreGeometry(settings.value("programwindow/geometry").toByteArray()); } installEventFilter(this); // Setup new menu bar for the programming window QMenuBar *menubar = menuBar(); QMenu *currentMenu = menubar->addMenu(tr("&File")); QAction *currentAction = new QAction(tr("New"), this); currentAction->setShortcut(tr("Ctrl+N")); currentAction->setStatusTip(tr("Create a new program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(addTab())); currentMenu->addAction(currentAction); currentAction = new QAction(tr("&Open..."), this); currentAction->setShortcut(tr("Ctrl+O")); currentAction->setStatusTip(tr("Open a program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(loadProgramFile())); currentMenu->addAction(currentAction); currentMenu->addSeparator(); m_saveAction = new QAction(tr("&Save"), this); m_saveAction->setShortcut(tr("Ctrl+S")); m_saveAction->setStatusTip(tr("Save the current program")); connect(m_saveAction, SIGNAL(triggered()), this, SLOT(save())); currentMenu->addAction(m_saveAction); currentAction = new QAction(tr("Rename"), this); currentAction->setStatusTip(tr("Rename the current program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(rename())); currentMenu->addAction(currentAction); currentAction = new QAction(tr("Duplicate tab"), this); currentAction->setStatusTip(tr("Copies the current program into a new tab")); connect(currentAction, SIGNAL(triggered()), this, SLOT(duplicateTab())); currentMenu->addAction(currentAction); currentMenu->addSeparator(); currentAction = new QAction(tr("Remove tab"), this); currentAction->setShortcut(tr("Ctrl+W")); currentAction->setStatusTip(tr("Remove the current program from the sketch")); connect(currentAction, SIGNAL(triggered()), this, SLOT(closeCurrentTab())); currentMenu->addAction(currentAction); currentMenu->addSeparator(); m_printAction = new QAction(tr("&Print..."), this); m_printAction->setShortcut(tr("Ctrl+P")); m_printAction->setStatusTip(tr("Print the current program")); connect(m_printAction, SIGNAL(triggered()), this, SLOT(print())); currentMenu->addAction(m_printAction); currentMenu->addSeparator(); currentAction = new QAction(tr("&Quit"), this); currentAction->setShortcut(tr("Ctrl+Q")); currentAction->setStatusTip(tr("Quit the application")); currentAction->setMenuRole(QAction::QuitRole); connect(currentAction, SIGNAL(triggered()), qApp, SLOT(closeAllWindows2())); currentMenu->addAction(currentAction); currentMenu = menubar->addMenu(tr("&Edit")); m_undoAction = new QAction(tr("Undo"), this); m_undoAction->setShortcuts(QKeySequence::Undo); m_undoAction->setEnabled(false); connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo())); currentMenu->addAction(m_undoAction); m_redoAction = new QAction(tr("Redo"), this); m_redoAction->setShortcuts(QKeySequence::Redo); m_redoAction->setEnabled(false); connect(m_redoAction, SIGNAL(triggered()), this, SLOT(redo())); currentMenu->addAction(m_redoAction); currentMenu->addSeparator(); m_cutAction = new QAction(tr("&Cut"), this); m_cutAction->setShortcut(tr("Ctrl+X")); m_cutAction->setStatusTip(tr("Cut selection")); m_cutAction->setEnabled(false); connect(m_cutAction, SIGNAL(triggered()), this, SLOT(cut())); currentMenu->addAction(m_cutAction); m_copyAction = new QAction(tr("&Copy"), this); m_copyAction->setShortcut(tr("Ctrl+C")); m_copyAction->setStatusTip(tr("Copy selection")); m_copyAction->setEnabled(false); connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copy())); currentMenu->addAction(m_copyAction); currentAction = new QAction(tr("&Paste"), this); currentAction->setShortcut(tr("Ctrl+V")); currentAction->setStatusTip(tr("Paste clipboard contents")); // TODO: Check clipboard status and disable appropriately here connect(currentAction, SIGNAL(triggered()), this, SLOT(paste())); currentMenu->addAction(currentAction); currentMenu->addSeparator(); currentAction = new QAction(tr("&Select All"), this); currentAction->setShortcut(tr("Ctrl+A")); currentAction->setStatusTip(tr("Select all text")); connect(currentAction, SIGNAL(triggered()), this, SLOT(selectAll())); currentMenu->addAction(currentAction); currentMenu = menuBar()->addMenu(tr("&Program")); QMenu *languageMenu = new QMenu(tr("Select language"), this); currentMenu->addMenu(languageMenu); QString currentLanguage = settings.value("programwindow/language", "").toString(); QStringList languages = getAvailableLanguages(); QActionGroup *languageActionGroup = new QActionGroup(this); foreach (QString language, languages) { currentAction = new QAction(language, this); currentAction->setCheckable(true); m_languageActions.insert(language, currentAction); languageActionGroup->addAction(currentAction); languageMenu->addAction(currentAction); if (!currentLanguage.isEmpty()) { if (language.compare(currentLanguage) == 0) { currentAction->setChecked(true); } } }