QMenuBar* ActionCollection::createMenuBar( QWidget *parent ) { QMenuBar* menuBar = new QMenuBar( parent ); menuBar->setFont( TomahawkUtils::systemFont() ); QMenu* controlsMenu = new QMenu( tr( "&Controls" ), menuBar ); controlsMenu->setFont( TomahawkUtils::systemFont() ); controlsMenu->addAction( m_actionCollection[ "playPause" ] ); controlsMenu->addAction( m_actionCollection[ "previousTrack" ] ); controlsMenu->addAction( m_actionCollection[ "nextTrack" ] ); controlsMenu->addSeparator(); controlsMenu->addAction( m_actionCollection[ "togglePrivacy" ] ); controlsMenu->addAction( m_actionCollection[ "showOfflineSources" ] ); controlsMenu->addSeparator(); controlsMenu->addAction( m_actionCollection[ "importPlaylist" ] ); controlsMenu->addAction( m_actionCollection[ "updateCollection" ] ); controlsMenu->addAction( m_actionCollection[ "rescanCollection" ] ); controlsMenu->addSeparator(); controlsMenu->addAction( m_actionCollection[ "quit" ] ); QMenu* settingsMenu = new QMenu( tr( "&Settings" ), menuBar ); settingsMenu->setFont( TomahawkUtils::systemFont() ); #ifndef Q_OS_MAC settingsMenu->addAction( m_actionCollection[ "toggleMenuBar" ] ); #endif settingsMenu->addAction( m_actionCollection[ "preferences" ] ); QMenu* helpMenu = new QMenu( tr( "&Help" ), menuBar ); helpMenu->setFont( TomahawkUtils::systemFont() ); helpMenu->addAction( m_actionCollection[ "diagnostics" ] ); helpMenu->addAction( m_actionCollection[ "openLogfile" ] ); helpMenu->addAction( m_actionCollection[ "legalInfo" ] ); helpMenu->addAction( m_actionCollection["getSupport"] ); helpMenu->addAction( m_actionCollection["reportBug"] ); helpMenu->addAction( m_actionCollection["helpTranslate"] ); helpMenu->addSeparator(); QMenu* whatsNew = helpMenu->addMenu( ImageRegistry::instance()->icon( RESPATH "images/whatsnew.svg" ), tr( "What's New in ..." ) ); whatsNew->setFont( TomahawkUtils::systemFont() ); whatsNew->addAction( m_actionCollection[ "whatsnew_0_8" ] ); helpMenu->addAction( m_actionCollection[ "aboutTomahawk" ] ); // Setup update check #ifndef Q_OS_MAC helpMenu->insertSeparator( m_actionCollection[ "legalInfo" ] ); #endif #if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE ) helpMenu->addAction( m_actionCollection[ "checkForUpdates" ] ); #elif defined( Q_OS_WIN ) helpMenu->addSeparator(); helpMenu->addAction( m_actionCollection[ "checkForUpdates" ] ); #endif if ( qApp->arguments().contains( "--debug" ) ) { helpMenu->addSeparator(); helpMenu->addAction( m_actionCollection[ "crashNow" ] ); } menuBar->addMenu( controlsMenu ); menuBar->addMenu( settingsMenu ); #if defined( Q_OS_MAC ) QMenu* windowMenu = new QMenu( tr( "&Window" ), menuBar ); windowMenu->setFont( TomahawkUtils::systemFont() ); windowMenu->addAction( m_actionCollection[ "minimize" ] ); windowMenu->addAction( m_actionCollection[ "zoom" ] ); windowMenu->addAction( m_actionCollection[ "fullscreen" ] ); menuBar->addMenu( windowMenu ); #endif menuBar->addMenu( helpMenu ); return menuBar; }
dspAROpenItems::dspAROpenItems(QWidget* parent, const char*, Qt::WFlags fl) : display(parent, "dspAROpenItems", fl) { setupUi(optionsWidget()); setWindowTitle(tr("Open Receivables")); setListLabel(tr("Receivables")); setReportName("AROpenItems"); setMetaSQLOptions("arOpenItems", "detail"); setUseAltId(true); setNewVisible(true); connect(_customerSelector, SIGNAL(updated()), list(), SLOT(clear())); connect(_customerSelector, SIGNAL(updated()), this, SLOT(sHandlePrintGroup())); connect(_closed, SIGNAL(toggled(bool)), this, SLOT(sClosedToggled(bool))); _dates->setStartNull(tr("Earliest"), omfgThis->startOfTime(), TRUE); _dates->setEndNull(tr("Latest"), omfgThis->endOfTime(), TRUE); QString baseBalanceTitle(tr("Balance")); QString baseAmountTitle(tr("Amount")); QString basePaidTitle(tr("Paid")); if (! omfgThis->singleCurrency()) { baseBalanceTitle = tr("Balance (in %1)").arg(CurrDisplay::baseCurrAbbr()); baseAmountTitle = tr("Amount (in %1)").arg(CurrDisplay::baseCurrAbbr()); basePaidTitle = tr("Paid (in %1)").arg(CurrDisplay::baseCurrAbbr()); } list()->setRootIsDecorated(true); list()->addColumn(tr("Doc. Type"), -1, Qt::AlignLeft, true, "doctype"); list()->addColumn(tr("Posted"), _ynColumn, Qt::AlignCenter, true, "posted"); list()->addColumn(tr("Recurring"), _ynColumn, Qt::AlignCenter, false, "recurring"); list()->addColumn(tr("Open"), _ynColumn, Qt::AlignCenter, false, "open"); list()->addColumn(tr("Doc. #"), _orderColumn, Qt::AlignLeft, true, "docnumber"); list()->addColumn(tr("Cust./Assign To"),_itemColumn, Qt::AlignLeft, false, "cust_number"); list()->addColumn(tr("Name/Desc."), -1, Qt::AlignLeft, true, "cust_name"); list()->addColumn(tr("Order/Incident"),_itemColumn, Qt::AlignRight, false, "ordernumber"); list()->addColumn(tr("Doc. Date"), _dateColumn, Qt::AlignCenter, true, "docdate"); list()->addColumn(tr("Due Date"), _dateColumn, Qt::AlignCenter, true, "aropen_duedate"); list()->addColumn(tr("Amount"), _moneyColumn, Qt::AlignRight, true, "amount"); list()->addColumn(baseAmountTitle, _moneyColumn, Qt::AlignRight, false, "base_amount"); list()->addColumn(tr("Paid"), _moneyColumn, Qt::AlignRight, true, "paid"); list()->addColumn(basePaidTitle, _moneyColumn, Qt::AlignRight, false, "base_paid"); list()->addColumn(tr("Balance"), _moneyColumn, Qt::AlignRight, true, "balance"); list()->addColumn(tr("Currency"), _currencyColumn, Qt::AlignLeft, true, "currAbbr"); list()->addColumn(baseBalanceTitle, _moneyColumn, Qt::AlignRight, true, "base_balance"); list()->addColumn(tr("Credit Card"), -1, Qt::AlignLeft, false, "ccard_number"); list()->addColumn(tr("Notes"), -1, Qt::AlignLeft, false, "notes"); connect(omfgThis, SIGNAL(creditMemosUpdated()), this, SLOT(sFillList())); connect(omfgThis, SIGNAL(invoicesUpdated(int, bool)), this, SLOT(sFillList())); if (omfgThis->singleCurrency()) { list()->hideColumn("currAbbr"); list()->hideColumn("balance"); } disconnect(newAction(), SIGNAL(triggered()), this, SLOT(sNew())); connect(newAction(), SIGNAL(triggered()), this, SLOT(sCreateInvoice())); QToolButton * newBtn = (QToolButton*)toolBar()->widgetForAction(newAction()); newBtn->setPopupMode(QToolButton::MenuButtonPopup); QAction *menuItem; QMenu * newMenu = new QMenu; menuItem = newMenu->addAction(tr("Invoice"), this, SLOT(sCreateInvoice())); menuItem->setEnabled(_privileges->check("MaintainMiscInvoices")); menuItem = newMenu->addAction(tr("Misc. Debit Memo"), this, SLOT(sEnterMiscArDebitMemo())); menuItem->setEnabled(_privileges->check("MaintainARMemos")); newMenu->addSeparator(); menuItem = newMenu->addAction(tr("Credit Memo"), this, SLOT(sNewCreditMemo())); menuItem->setEnabled(_privileges->check("MaintainCreditMemos")); menuItem = newMenu->addAction(tr("Misc. Credit Memo"), this, SLOT(sEnterMiscArCreditMemo())); menuItem->setEnabled(_privileges->check("MaintainARMemos")); newBtn->setMenu(newMenu); _asOf->setDate(omfgThis->dbDate(), true); _closed->hide(); }
void RenderView3D::TriggerContextMenu( QMouseEvent* event ) { QMenu* menu = new QMenu(this); bool bShowBar = this->GetShowScalarBar(); MainWindow* mainwnd = MainWindow::GetMainWindow(); QList<Layer*> layers = mainwnd->GetLayers("Surface"); layers << mainwnd->GetLayers("MRI"); layers << mainwnd->GetLayers("PointSet"); QMenu* submenu = menu->addMenu("Reset View"); QAction* act = new QAction("Right", this); connect(act, SIGNAL(triggered()), this, SLOT(ResetViewRight())); submenu->addAction(act); act = new QAction("Left", this); connect(act, SIGNAL(triggered()), this, SLOT(ResetViewLeft())); submenu->addAction(act); act = new QAction("Anterior", this); connect(act, SIGNAL(triggered()), this, SLOT(ResetViewAnterior())); submenu->addAction(act); act = new QAction("Posterior", this); connect(act, SIGNAL(triggered()), this, SLOT(ResetViewPosterior())); submenu->addAction(act); act = new QAction("Superior", this); connect(act, SIGNAL(triggered()), this, SLOT(ResetViewSuperior())); submenu->addAction(act); act = new QAction("Inferior", this); connect(act, SIGNAL(triggered()), this, SLOT(ResetViewInferior())); submenu->addAction(act); menu->addSeparator(); act = new QAction("Show All Slices", this); act->setData(3); menu->addAction(act); connect(act, SIGNAL(triggered()), this, SLOT(OnShowSlice())); act = new QAction("Hide All Slices", this); act->setData(-1); menu->addAction(act); connect(act, SIGNAL(triggered()), this, SLOT(OnShowSlice())); menu->addSeparator(); QStringList slice_names; slice_names << "Show Sagittal Slice" << "Show Coronal Slice" << "Show Axial Slice"; for (int i = 0; i < 3; i++) { act = new QAction(slice_names[i], this); act->setData(i); act->setCheckable(true); act->setChecked(m_bSliceVisibility[i]); menu->addAction(act); connect(act, SIGNAL(toggled(bool)), this, SLOT(OnShowSlice(bool))); } menu->addSeparator(); if (!mainwnd->GetLayers("MRI").isEmpty()) { menu->addAction(MainWindow::GetMainWindow()->ui->actionShowSliceFrames); } if (!layers.isEmpty()) { QMenu* menu2 = menu->addMenu("Show Color Bar"); QActionGroup* ag = new QActionGroup(this); ag->setExclusive(false); foreach (Layer* layer, layers) { QAction* act = new QAction(layer->GetName(), this); act->setCheckable(true); act->setChecked(bShowBar && layer == m_layerScalarBar); act->setData(QVariant::fromValue((QObject*)layer)); menu2->addAction(act); ag->addAction(act); }
void QScriptEdit::extraAreaMouseEvent(QMouseEvent *e) { QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y())); #ifndef QT_NO_SYNTAXHIGHLIGHTER cursor.setPosition(cursor.block().position()); #endif QFontMetrics fm(font()); int markWidth = fm.lineSpacing(); if (e->type() == QEvent::MouseMove && e->buttons() == 0) { // mouse tracking bool hand = (e->pos().x() <= markWidth); int lineNumber = cursor.blockNumber() + m_baseLineNumber; hand = hand && isExecutableLine(lineNumber); #ifndef QT_NO_CURSOR if (hand != (m_extraArea->cursor().shape() == Qt::PointingHandCursor)) m_extraArea->setCursor(hand ? Qt::PointingHandCursor : Qt::ArrowCursor); #endif } if (e->type() == QEvent::MouseButtonPress) { if (e->button() == Qt::LeftButton) { int lineNumber = cursor.blockNumber() + m_baseLineNumber; bool executable = isExecutableLine(lineNumber); if ((e->pos().x() <= markWidth) && executable) m_extraAreaToggleBlockNumber = cursor.blockNumber(); else m_extraAreaToggleBlockNumber = -1; } } else if (e->type() == QEvent::MouseButtonRelease) { if (e->button() == Qt::LeftButton) { if ((m_extraAreaToggleBlockNumber != -1) && (e->pos().x() <= markWidth)) { int lineNumber = m_extraAreaToggleBlockNumber + m_baseLineNumber; bool on = !m_breakpoints.contains(lineNumber); emit breakpointToggleRequest(lineNumber, on); } } else if (e->button() == Qt::RightButton) { int lineNumber = cursor.blockNumber() + m_baseLineNumber; if (!isExecutableLine(lineNumber)) return; bool has = m_breakpoints.contains(lineNumber); QMenu *popup = new QMenu(); QAction *toggleAct = new QAction(tr("Toggle Breakpoint"), popup); popup->addAction(toggleAct); QAction *disableAct = new QAction(tr("Disable Breakpoint"), popup); QAction *enableAct = new QAction(tr("Enable Breakpoint"), popup); QWidget *conditionWidget = new QWidget(); { QHBoxLayout *hbox = new QHBoxLayout(conditionWidget); hbox->addWidget(new QLabel(tr("Breakpoint Condition:"))); hbox->addWidget(new QLineEdit()); } // QWidgetAction *conditionAct = new QWidgetAction(popup); // conditionAct->setDefaultWidget(conditionWidget); if (has) { popup->addSeparator(); popup->addAction(m_breakpoints[lineNumber].enabled ? disableAct : enableAct); // popup->addAction(conditionAct); } QAction *ret = popup->exec(e->globalPos()); if (ret) { if (ret == toggleAct) { emit breakpointToggleRequest(lineNumber, !has); } else if (ret == disableAct) { emit breakpointEnableRequest(lineNumber, false); } else if (ret == enableAct) { emit breakpointEnableRequest(lineNumber, true); }// else if (ret == conditionAct) { //} } popup->deleteLater(); } } }
void OverlayEditorScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QGraphicsScene::contextMenuEvent(event); if (event->isAccepted()) return; if (! event->widget()) return; QGraphicsPixmapItem *item = childAt(event->scenePos()); QMenu qm(event->widget()); QMenu *qmLayout = qm.addMenu(tr("Layout preset")); QAction *qaLayoutLargeAvatar = qmLayout->addAction(tr("Large square avatar")); QAction *qaLayoutText = qmLayout->addAction(tr("Avatar and Name")); QMenu *qmTrans = qm.addMenu(tr("User Opacity")); QActionGroup *qagUser = new QActionGroup(&qm); QAction *userOpacity[8]; for (int i=0;i<8;++i) { qreal o = (i + 1) / 8.0f; userOpacity[i] = new QAction(tr("%1%").arg(o * 100.0f, 0, 'f', 1), qagUser); userOpacity[i]->setCheckable(true); userOpacity[i]->setData(o); if (qFuzzyCompare(qgiGroup->opacity(), o)) userOpacity[i]->setChecked(true); qmTrans->addAction(userOpacity[i]); } QAction *color = NULL; QAction *font = NULL; QAction *objectOpacity[8]; for (int i=0;i<8;++i) objectOpacity[i] = NULL; QAction *boxpen[4] = { NULL, NULL, NULL, NULL}; QAction *boxpad[4] = { NULL, NULL, NULL, NULL}; QAction *boxpencolor = NULL; QAction *boxfillcolor = NULL; QAction *align[6]; for (int i=0;i<6;++i) align[i] = NULL; if (item) { qm.addSeparator(); QMenu *qmObjTrans = qm.addMenu(tr("Object Opacity")); QActionGroup *qagObject = new QActionGroup(&qm); for (int i=0;i<8;++i) { qreal o = (i + 1) / 8.0f; objectOpacity[i] = new QAction(tr("%1%").arg(o * 100.0f, 0, 'f', 1), qagObject); objectOpacity[i]->setCheckable(true); objectOpacity[i]->setData(o); if (qFuzzyCompare(item->opacity(), o)) objectOpacity[i]->setChecked(true); qmObjTrans->addAction(objectOpacity[i]); } QMenu *qmObjAlign = qm.addMenu(tr("Alignment")); Qt::Alignment a; if (item == qgpiAvatar) a = os.qaAvatar; else if (item == qgpiChannel) a = os.qaChannel; else if (item == qgpiMuted) a = os.qaMutedDeafened; else a = os.qaUserName; align[0] = qmObjAlign->addAction(tr("Left")); align[0]->setCheckable(true); align[0]->setData(Qt::AlignLeft); if (a & Qt::AlignLeft) align[0]->setChecked(true); align[1] = qmObjAlign->addAction(tr("Center")); align[1]->setCheckable(true); align[1]->setData(Qt::AlignHCenter); if (a & Qt::AlignHCenter) align[1]->setChecked(true); align[2] = qmObjAlign->addAction(tr("Right")); align[2]->setCheckable(true); align[2]->setData(Qt::AlignRight); if (a & Qt::AlignRight) align[2]->setChecked(true); qmObjAlign->addSeparator(); align[3] = qmObjAlign->addAction(tr("Top")); align[3]->setCheckable(true); align[3]->setData(Qt::AlignTop); if (a & Qt::AlignTop) align[3]->setChecked(true); align[4] = qmObjAlign->addAction(tr("Center")); align[4]->setCheckable(true); align[4]->setData(Qt::AlignVCenter); if (a & Qt::AlignVCenter) align[4]->setChecked(true); align[5] = qmObjAlign->addAction(tr("Bottom")); align[5]->setCheckable(true); align[5]->setData(Qt::AlignBottom); if (a & Qt::AlignBottom) align[5]->setChecked(true); if ((item != qgpiAvatar) && (item != qgpiMuted)) { color = qm.addAction(tr("Color...")); font = qm.addAction(tr("Font...")); } } if (qgpiBox->isVisible()) { qm.addSeparator(); QMenu *qmBox = qm.addMenu(tr("Bounding box")); QMenu *qmPen = qmBox->addMenu(tr("Pen width")); QMenu *qmPad = qmBox->addMenu(tr("Padding")); boxpencolor = qmBox->addAction(tr("Pen color")); boxfillcolor = qmBox->addAction(tr("Fill color")); QActionGroup *qagPen = new QActionGroup(qmPen); QActionGroup *qagPad = new QActionGroup(qmPad); for (int i=0;i<4;++i) { qreal v = (i) ? powf(2.0f, -10 + i) : 0.0f; boxpen[i] = new QAction(QString::number(i), qagPen); boxpen[i]->setData(v); boxpen[i]->setCheckable(true); if (qFuzzyCompare(os.fBoxPenWidth, v)) boxpen[i]->setChecked(true); qmPen->addAction(boxpen[i]); boxpad[i] = new QAction(QString::number(i), qagPad); boxpad[i]->setData(v); boxpad[i]->setCheckable(true); if (qFuzzyCompare(os.fBoxPad, v)) boxpad[i]->setChecked(true); qmPad->addAction(boxpad[i]); } } QAction *act = qm.exec(event->screenPos()); if (! act) return; for (int i=0;i<8;++i) { if (userOpacity[i] == act) { float o = act->data().toReal(); os.fUser[tsColor] = o; qgiGroup->setOpacity(o); } } for (int i=0;i<8;++i) { if (objectOpacity[i] == act) { qreal o = act->data().toReal(); if (item == qgpiMuted) os.fMutedDeafened = o; else if (item == qgpiAvatar) os.fAvatar = o; else if (item == qgpiChannel) os.fChannel = o; else if (item == qgpiName) os.fUserName = o; item->setOpacity(o); } } for (int i=0;i<4;++i) { if (boxpen[i] == act) { os.fBoxPenWidth = act->data().toReal(); moveBox(); } else if (boxpad[i] == act) { os.fBoxPad = act->data().toReal(); moveBox(); } } for (int i=0;i<6;++i) { if (align[i] == act) { Qt::Alignment *aptr; if (item == qgpiAvatar) aptr = & os.qaAvatar; else if (item == qgpiChannel) aptr = & os.qaChannel; else if (item == qgpiMuted) aptr = & os.qaMutedDeafened; else aptr = & os.qaUserName; Qt::Alignment a = static_cast<Qt::Alignment>(act->data().toInt()); if (a & Qt::AlignHorizontal_Mask) { *aptr = (*aptr & ~Qt::AlignHorizontal_Mask) | a; } else { *aptr = (*aptr & ~Qt::AlignVertical_Mask) | a; } updateSelected(); } } if (act == boxpencolor) { QColor qc = QColorDialog::getColor(os.qcBoxPen, event->widget(), tr("Pick pen color"), QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel); if (! qc.isValid()) return; os.qcBoxPen = qc; moveBox(); } else if (act == boxfillcolor) { QColor qc = QColorDialog::getColor(os.qcBoxFill, event->widget(), tr("Pick fill color"), QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel); if (! qc.isValid()) return; os.qcBoxFill = qc; moveBox(); } else if (act == color) { QColor *col = NULL; if (item == qgpiChannel) col = & os.qcChannel; else if (item == qgpiName) col = & os.qcUserName[tsColor]; if (! col) return; QColor qc = QColorDialog::getColor(*col, event->widget(), tr("Pick color"), QColorDialog::DontUseNativeDialog); if (! qc.isValid()) return; qc.setAlpha(255); if (qc == *col) return; *col = qc; updateSelected(); } else if (act == font) { QFont *fontptr = (item == qgpiChannel) ? &os.qfChannel : &os.qfUserName; qgpiSelected = NULL; qgriSelected->hide(); // QFontDialog doesn't really like graphics view. At all. QFontDialog qfd; qfd.setOptions(QFontDialog::DontUseNativeDialog); qfd.setCurrentFont(*fontptr); qfd.setWindowTitle(tr("Pick font")); int ret; if (g.ocIntercept) { QGraphicsProxyWidget *qgpw = new QGraphicsProxyWidget(NULL, Qt::Window); qgpw->setWidget(&qfd); addItem(qgpw); qgpw->setZValue(3.0f); #if QT_VERSION >= 0x040600 qgpw->setPanelModality(QGraphicsItem::PanelModal); #endif qgpw->setPos(- qgpw->boundingRect().width() / 2.0f, - qgpw->boundingRect().height() / 2.0f); qgpw->show(); ret = qfd.exec(); qgpw->hide(); qgpw->setWidget(NULL); delete qgpw; } else { Qt::WindowFlags wf = g.mw->windowFlags(); if (wf.testFlag(Qt::WindowStaysOnTopHint)) qfd.setWindowFlags(qfd.windowFlags() | Qt::WindowStaysOnTopHint); ret = qfd.exec(); } if (! ret) return; *fontptr = qfd.selectedFont(); resync(); } else if (act == qaLayoutLargeAvatar) { os.setPreset(OverlaySettings::LargeSquareAvatar); resync(); } else if (act == qaLayoutText) { os.setPreset(OverlaySettings::AvatarAndName); resync(); } }
void MainWindow::Start() { _ModuleManager = new ModuleManager(this); NeedRestart = false; BrowserFactory = 0; AlreadyShowsMessage = false; TranslateEngine.SetDirectory(":/engine/translate"); TranslateFastExecuteScript.SetDirectory(":/fastexecutescript/translate"); qDebug()<<"Start 020"; bool DataBaseConnectorPreserved = _DataBaseConnector; qDebug()<<"Start 021"; if(!DataBaseConnectorPreserved) { qDebug()<<"Start 022"; _DataBaseConnector = new MongoDatabaseConnector(this); qDebug()<<"Start 023"; _CsvHelper = new CsvHelper(_DataBaseConnector); qDebug()<<"Start 024"; _DataBaseConnector->SetCsvHelper(_CsvHelper); qDebug()<<"Start 025"; _DataBaseState = new DatabaseState(this); qDebug()<<"Start 026"; _DataBaseConnector2 = new MongoDatabaseConnector(_DataBaseState); qDebug()<<"Start 027"; _DataBaseState->SetDatabaseConnector(_DataBaseConnector2); qDebug()<<"Start 028"; connect(_DataBaseConnector,SIGNAL(GroupManipulated()),_DataBaseState,SLOT(Reload())); qDebug()<<"Start 029"; _DataBaseConnector3 = new MongoDatabaseConnector(this); qDebug()<<"Start 030"; } qDebug()<<"Start 031"; LangModel = new LanguageModel(this); TrayNotifier = new SystemTrayNotifier(this); TrayNotifier->Init(); qDebug()<<"Start 032"; Settings = new QSettings("settings.ini",QSettings::IniFormat,this); LogLocation = Settings->value("LogLocation","../../logs").toString(); qDebug()<<"Start 033"; SkinController * skin = new SkinController(); skin->ApplyTheme(Settings->value("Theme","DarkFusion").toString()); skin->deleteLater(); qDebug()<<"Start 034"; Language = Settings->value("DefaultLanguageScript","").toString().toLower(); qDebug()<<"Start 035"; if(Language.isEmpty()) { ScriptLanguageChooserDialog LangDialog; LangDialog.SetLanguageModel(LangModel); if(!LangDialog.exec()) { QTimer::singleShot(50,this,SLOT(Close())); return; } Language = LangDialog.GetLang(); Settings->setValue("DefaultLanguageScript",Language); } qDebug()<<"Start 036"; if(!DataBaseConnectorPreserved) { qDebug()<<"Start 037"; _DataBaseConnector->Init(Language); if(!_DataBaseConnector->Start()) { QEventLoop loop; connect(_DataBaseConnector, SIGNAL(Started()), &loop, SLOT(quit())); loop.exec(); } qDebug()<<"Start 038"; if(_DataBaseConnector->HasDatabase()) { qDebug()<<"Start 039"; if(_DataBaseConnector->WasError()) { QMessageBox::information(0, tr("Database Error"), _DataBaseConnector->GetError()); QTimer::singleShot(50,this,SLOT(Close())); return; } qDebug()<<"Start 040"; if(!_DataBaseConnector2->Start()) { QEventLoop loop; connect(_DataBaseConnector2, SIGNAL(Started()), &loop, SLOT(quit())); loop.exec(); } qDebug()<<"Start 041"; if(_DataBaseConnector2->WasError()) { QMessageBox::information(0, tr("Database Error"), _DataBaseConnector2->GetError()); QTimer::singleShot(50,this,SLOT(Close())); return; } qDebug()<<"Start 042"; if(!_DataBaseConnector3->Start()) { QEventLoop loop; connect(_DataBaseConnector3, SIGNAL(Started()), &loop, SLOT(quit())); loop.exec(); } qDebug()<<"Start 043"; if(_DataBaseConnector3->WasError()) { QMessageBox::information(0, tr("Database Error"), _DataBaseConnector3->GetError()); QTimer::singleShot(50,this,SLOT(Close())); return; } qDebug()<<"Start 044"; _DataBaseState->Reload(); }else { qDebug()<<"Start 045"; ui->actionData->setVisible(false); } }else { qDebug()<<"Start 046"; if(!_DataBaseConnector->HasDatabase()) { ui->actionData->setVisible(false); } } qDebug()<<"Start 047"; TranslateEngine.Translate(Language); TranslateFastExecuteScript.Translate(Language); LangModel->SetScriptAvailableLanguagesString(Language); qDebug()<<"Start 048"; LabelAllLog = new QPushButton(tr("Show all log"),ui->tab_2); TopRightPositioner * AllButtonPositioner = new TopRightPositioner(this); AllButtonPositioner->SetChild(LabelAllLog); AllButtonPositioner->SetParent(ui->tab_2); AllButtonPositioner->Start(); connect(LabelAllLog,SIGNAL(clicked()),this,SLOT(LabelAllLog_Click())); qDebug()<<"Start 049"; movie = new QMovie(":/fastexecutescript/images/loading.gif"); movie->setParent(this); ui->LabelGif->setMovie(movie); movie->start(); qDebug()<<"Start 050"; InitRecources(); qDebug()<<"Start 051"; InitWidgets(); qDebug()<<"Start 052"; IPreprocessor * _Preprocessor = new Preprocessor(this); _Preprocessor->SetEncryptor(new NoneEncryptor(_Preprocessor)); qDebug()<<"Start 053"; XmlResourceController loader; //Load from file loader.SetFileName("project.xml"); qDebug()<<"Start 063"; //Find actual and default files location QDir dir(QCoreApplication::applicationDirPath()); QString ActualFilePath = dir.absoluteFilePath(QString("./Actual") + QString(".xml")); QString DefaultFilePath = ActualFilePath + ".default.xml"; qDebug()<<"Start 065"; //Delete actual if defaults not exists if(!QFile::exists(DefaultFilePath) && QFile::exists(ActualFilePath)) { QFile(ActualFilePath).remove(); } qDebug()<<"Start 066"; Res->FromViewToModel(&loader); this->setWindowTitle(QString("%1(%2)").arg(loader.GetScriptName()).arg(loader.GetScriptVersion())); bool NeedToUseAdditionalSettings = Settings->value("RenderMethodVisible","false").toString().toLower() == "true"; qDebug()<<"Start 067"; AdditionalSettingsWidgets AdditionalSettingsStatic; AdditionalSettings = &AdditionalSettingsStatic; qDebug()<<"Start 068"; if(NeedToUseAdditionalSettings) AdditionalSettings->SetDefault(Settings->value("DefaultWorker").toString()); qDebug()<<"Start 069"; XmlResourceController XmlActualStatic; XmlResourceController *XmlActual = &XmlActualStatic; qDebug()<<"Start 070"; //Load From File XmlActual->SetFileName(ActualFilePath); qDebug()<<"Start 071"; if(true/*Res->NeedToFillByUser()*/) { //Create dialog AskUserForResourcesDialog ask; Ask = &ask; if(Settings->value("HideLanguageChooser",false).toBool()) { Ask->RemoveLanguageChooser(); } Ask->setWindowTitle(QString("%1(%2)").arg(loader.GetScriptName()).arg(loader.GetScriptVersion())); ask.setModal(true); //Update with actual settings { Resources ResActual; ResActual.FromViewToModel(XmlActual); Resources ResDefault; XmlResourceController XmlDefaults; XmlDefaults.SetFileName(DefaultFilePath); ResDefault.FromViewToModel(&XmlDefaults); CopyResourceController Copy; Copy.SetResources(&ResActual); Copy.SetDefaults(&ResDefault); Res->FromViewToModel(&Copy); } ShowData(); connect(Ask,SIGNAL(Default()),this,SLOT(SetDefault())); connect(Ask,SIGNAL(Save(QString)),this,SLOT(SaveActual(QString))); connect(Ask,SIGNAL(Load(QString)),this,SLOT(LoadActual(QString))); connect(Ask,SIGNAL(Reset()),this,SLOT(Restart())); connect(Ask,SIGNAL(ShowLanguage()),this,SLOT(ChooseLanguage())); connect(Ask,SIGNAL(ShowLogLocation()),this,SLOT(ChooseLogLocation())); connect(Ask,SIGNAL(ShowDatabase()),this,SLOT(ShowDatabase())); if(!_DataBaseConnector->HasDatabase()) { Ask->HideDatabaseButton(); } //Ask user for input if(!IsSilent && !ask.exec()) { QTimer::singleShot(50,this,SLOT(Close())); delete UserWidgetControllerPointer; UserWidgetControllerPointer = 0; return; } //Save defaults { Resources ResDefaults; ResDefaults.FromViewToModel(&loader); XmlResourceController XmlDefaults; XmlDefaults.SetFileName(DefaultFilePath); ResDefaults.FromModelToView(&XmlDefaults); } if(NeedToUseAdditionalSettings) { Settings->setValue("DefaultWorker",AdditionalSettings->ParseWidget()); InitBrowserList(AdditionalSettings->ParseWidget()); }else { InitBrowserList(Settings->value("DefaultWorker", "MultiProcessQt5").toString()); } //Load data to new model and then to engine resources Resources UserRes; UserRes.FromViewToModel(UserWidgetControllerPointer); UserRes.FromModelToView(XmlActual); UserRes.FromModelToView(EngineResController); //Clean memory delete UserWidgetControllerPointer; UserWidgetControllerPointer = 0; Ask = 0; } //Prepare Worker ScriptMultiWorker* worker = new ScriptMultiWorker(this); worker->SetModuleManager(_ModuleManager); worker->SetAdditionEngineScripts(_ModuleManager->GetModuleEngineCode()); worker->SetPreprocessor(_Preprocessor); worker->SetBrowserFactory(BrowserFactory); Output->Clear(); Output->disconnect(); ReportData = new ScriptMultiWorkerReportData(this); ResVisualizer = new ResourcesVisualizer(this); connect(ResVisualizer,SIGNAL(ChangedState(bool)),this,SLOT(ResourcesReportStateChanged(bool))); ResVisualizer->SetReportData(EngineResController->GetWatcherList()); DataVisualizer = new ReportDataVisualizer(this); DataVisualizer->SetReportData(ReportData); connect(ui->actionShow_Report,SIGNAL(triggered()),DataVisualizer,SLOT(ShowReport())); connect(FactorySolver,SIGNAL(UsedSolver(QString)),ReportData,SLOT(CaptchaUsed(QString))); connect(FactorySolver,SIGNAL(FailedSolver(QString)),ReportData,SLOT(CaptchaFailed(QString))); connect(ui->actionShow,SIGNAL(triggered()),this,SLOT(show())); connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(Close())); connect(ui->actionRestart,SIGNAL(triggered()),this,SLOT(Restart())); connect(ui->actionRestart,SIGNAL(triggered()),this,SLOT(Close())); connect(ui->actionData,SIGNAL(triggered()),this,SLOT(ShowDatabase())); connect(TrayNotifier,SIGNAL(Show()),this,SLOT(show())); QMenu *Menu = new QMenu(this); Menu->addAction(ui->actionShow); Menu->addSeparator(); Menu->addAction(ui->actionExit); TrayNotifier->SetContextmenu(Menu); connect(worker,SIGNAL(Success()),Output,SLOT(Success())); connect(worker,SIGNAL(Failed()),Output,SLOT(Failed())); connect(worker,SIGNAL(ProgressMaximum(int)),Output,SLOT(ProgressMaximum(int))); connect(worker,SIGNAL(ProgressValue(int)),Output,SLOT(ProgressValue(int))); connect(worker,SIGNAL(Finished()),Output,SLOT(Finished())); //Set Loggers QDateTime CurrentDateTime = QDateTime::currentDateTime(); QString datestringfile = CurrentDateTime.toString("yyyy.MM.dd.hh.mm.ss"); Output->SetOutputTitle1(loader.GetOutputTitle1()); Output->SetOutputTitle2(loader.GetOutputTitle2()); Output->SetOutputTitle3(loader.GetOutputTitle3()); Output->SetOutputTitle4(loader.GetOutputTitle4()); Output->SetOutputTitle5(loader.GetOutputTitle5()); Output->SetOutputTitle6(loader.GetOutputTitle6()); Output->SetOutputTitle7(loader.GetOutputTitle7()); Output->SetOutputTitle8(loader.GetOutputTitle8()); Output->SetOutputTitle9(loader.GetOutputTitle9()); ComplexLogger *ComplexLoggerResults1 = new ComplexLogger(worker); FileLogger *FileLoggerResults1 = new FileLogger(ComplexLoggerResults1); QString FileName1 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle1().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName1(FileName1); FileLoggerResults1->SetFileName(FileName1); PlainTextLogger * PlainTextLoggerResults1 = new PlainTextLogger(ComplexLoggerResults1); PlainTextLoggerResults1->SetPlainTextElement(Output->GetOutput(0)); ComplexLoggerResults1->AddLogger(FileLoggerResults1); ComplexLoggerResults1->AddLogger(PlainTextLoggerResults1); connect(ComplexLoggerResults1, SIGNAL(NewLine()), this, SLOT(AddedOutput1())); ComplexLogger *ComplexLoggerResults2 = new ComplexLogger(worker); FileLogger *FileLoggerResults2 = new FileLogger(ComplexLoggerResults2); QString FileName2 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle2().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName2(FileName2); FileLoggerResults2->SetFileName(FileName2); PlainTextLogger * PlainTextLoggerResults2 = new PlainTextLogger(ComplexLoggerResults2); PlainTextLoggerResults2->SetPlainTextElement(Output->GetOutput(1)); ComplexLoggerResults2->AddLogger(FileLoggerResults2); ComplexLoggerResults2->AddLogger(PlainTextLoggerResults2); connect(ComplexLoggerResults2, SIGNAL(NewLine()), this, SLOT(AddedOutput2())); ComplexLogger *ComplexLoggerResults3 = new ComplexLogger(worker); FileLogger *FileLoggerResults3 = new FileLogger(ComplexLoggerResults3); QString FileName3 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle3().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName3(FileName3); FileLoggerResults3->SetFileName(FileName3); PlainTextLogger * PlainTextLoggerResults3 = new PlainTextLogger(ComplexLoggerResults3); PlainTextLoggerResults3->SetPlainTextElement(Output->GetOutput(2)); ComplexLoggerResults3->AddLogger(FileLoggerResults3); ComplexLoggerResults3->AddLogger(PlainTextLoggerResults3); connect(ComplexLoggerResults3, SIGNAL(NewLine()), this, SLOT(AddedOutput3())); ComplexLogger *ComplexLoggerResults4 = new ComplexLogger(worker); FileLogger *FileLoggerResults4 = new FileLogger(ComplexLoggerResults4); QString FileName4 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle4().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName4(FileName4); FileLoggerResults4->SetFileName(FileName4); PlainTextLogger * PlainTextLoggerResults4 = new PlainTextLogger(ComplexLoggerResults4); PlainTextLoggerResults4->SetPlainTextElement(Output->GetOutput(3)); ComplexLoggerResults4->AddLogger(FileLoggerResults4); ComplexLoggerResults4->AddLogger(PlainTextLoggerResults4); connect(ComplexLoggerResults4, SIGNAL(NewLine()), this, SLOT(AddedOutput4())); ComplexLogger *ComplexLoggerResults5 = new ComplexLogger(worker); FileLogger *FileLoggerResults5 = new FileLogger(ComplexLoggerResults5); QString FileName5 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle5().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName5(FileName5); FileLoggerResults5->SetFileName(FileName5); PlainTextLogger * PlainTextLoggerResults5 = new PlainTextLogger(ComplexLoggerResults5); PlainTextLoggerResults5->SetPlainTextElement(Output->GetOutput(4)); ComplexLoggerResults5->AddLogger(FileLoggerResults5); ComplexLoggerResults5->AddLogger(PlainTextLoggerResults5); connect(ComplexLoggerResults5, SIGNAL(NewLine()), this, SLOT(AddedOutput5())); ComplexLogger *ComplexLoggerResults6 = new ComplexLogger(worker); FileLogger *FileLoggerResults6 = new FileLogger(ComplexLoggerResults6); QString FileName6 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle6().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName6(FileName6); FileLoggerResults6->SetFileName(FileName6); PlainTextLogger * PlainTextLoggerResults6 = new PlainTextLogger(ComplexLoggerResults6); PlainTextLoggerResults6->SetPlainTextElement(Output->GetOutput(5)); ComplexLoggerResults6->AddLogger(FileLoggerResults6); ComplexLoggerResults6->AddLogger(PlainTextLoggerResults6); connect(ComplexLoggerResults6, SIGNAL(NewLine()), this, SLOT(AddedOutput6())); ComplexLogger *ComplexLoggerResults7 = new ComplexLogger(worker); FileLogger *FileLoggerResults7 = new FileLogger(ComplexLoggerResults7); QString FileName7 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle7().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName7(FileName7); FileLoggerResults7->SetFileName(FileName7); PlainTextLogger * PlainTextLoggerResults7 = new PlainTextLogger(ComplexLoggerResults7); PlainTextLoggerResults7->SetPlainTextElement(Output->GetOutput(6)); ComplexLoggerResults7->AddLogger(FileLoggerResults7); ComplexLoggerResults7->AddLogger(PlainTextLoggerResults7); connect(ComplexLoggerResults7, SIGNAL(NewLine()), this, SLOT(AddedOutput7())); ComplexLogger *ComplexLoggerResults8 = new ComplexLogger(worker); FileLogger *FileLoggerResults8 = new FileLogger(ComplexLoggerResults8); QString FileName8 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle8().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName8(FileName8); FileLoggerResults8->SetFileName(FileName8); PlainTextLogger * PlainTextLoggerResults8 = new PlainTextLogger(ComplexLoggerResults8); PlainTextLoggerResults8->SetPlainTextElement(Output->GetOutput(7)); ComplexLoggerResults8->AddLogger(FileLoggerResults8); ComplexLoggerResults8->AddLogger(PlainTextLoggerResults8); connect(ComplexLoggerResults8, SIGNAL(NewLine()), this, SLOT(AddedOutput8())); ComplexLogger *ComplexLoggerResults9 = new ComplexLogger(worker); FileLogger *FileLoggerResults9 = new FileLogger(ComplexLoggerResults9); QString FileName9 = QDir::cleanPath(LogLocation + QDir::separator() + QString("%2/%1.txt").arg(datestringfile).arg(Output->GetOutputTitle9().GetTranslation("en").replace(QRegExp("\\s"),".").replace(QRegExp("[^a-zA-Z1-9]"),""))); Output->SetFileName9(FileName9); FileLoggerResults9->SetFileName(FileName9); PlainTextLogger * PlainTextLoggerResults9 = new PlainTextLogger(ComplexLoggerResults9); PlainTextLoggerResults9->SetPlainTextElement(Output->GetOutput(8)); ComplexLoggerResults9->AddLogger(FileLoggerResults9); ComplexLoggerResults9->AddLogger(PlainTextLoggerResults9); connect(ComplexLoggerResults9, SIGNAL(NewLine()), this, SLOT(AddedOutput9())); Output->SetOutputVisible1(loader.GetOutputVisible1()); Output->SetOutputVisible2(loader.GetOutputVisible2()); Output->SetOutputVisible3(loader.GetOutputVisible3()); Output->SetOutputVisible4(loader.GetOutputVisible4()); Output->SetOutputVisible5(loader.GetOutputVisible5()); Output->SetOutputVisible6(loader.GetOutputVisible6()); Output->SetOutputVisible7(loader.GetOutputVisible7()); Output->SetOutputVisible8(loader.GetOutputVisible8()); Output->SetOutputVisible9(loader.GetOutputVisible9()); Output->SetConfiguratorVisible(false); worker->SetResults1(ComplexLoggerResults1); worker->SetResults2(ComplexLoggerResults2); worker->SetResults3(ComplexLoggerResults3); worker->SetResults4(ComplexLoggerResults4); worker->SetResults5(ComplexLoggerResults5); worker->SetResults6(ComplexLoggerResults6); worker->SetResults7(ComplexLoggerResults7); worker->SetResults8(ComplexLoggerResults8); worker->SetResults9(ComplexLoggerResults9); ui->Results->clear(); ComplexLogger *ComplexLoggerLog = new ComplexLogger(worker); FileLogger *FileLoggerLog = new FileLogger(ComplexLoggerLog); LogFileName = QDir::cleanPath(LogLocation + QDir::separator() + QString("log/%1.txt").arg(datestringfile)); FileLoggerLog->SetFileName(LogFileName); PlainTextLogger * PlainTextLoggerLog = new PlainTextLogger(ComplexLoggerLog); PlainTextLoggerLog->SetPlainTextElement(ui->Results); ComplexLoggerLog->AddLogger(FileLoggerLog); ComplexLoggerLog->AddLogger(PlainTextLoggerLog); worker->SetLogger(ComplexLoggerLog); worker->SetScript(_Preprocessor->Preprocess(loader.GetScript(),0)); worker->SetScriptResources(ScriptResources); TimeoutWaiterFactory *WaiterFactory = new TimeoutWaiterFactory(worker); WaiterFactory->SetMultiWorker(_MultiTimer); worker->SetWaiterFactory(WaiterFactory); worker->SetSolverFactory(FactorySolver); worker->SetEngineResources(EngineRes); worker->SetResourceHandlersFactory(new ResourceHandlersFactory(worker)); worker->SetHttpClientFactory(_HttpClientFactory); worker->SetPop3ClientFactory(_Pop3ClientFactory); worker->SetImapClientFactory(_ImapClientFactory); worker->SetCsvHelper(_CsvHelper); worker->SetDatabaseConnector(_DataBaseConnector3); worker->SetScriptSuspender(new ScriptSuspender(worker)); worker->SetWorkerFactory(new ScriptWorkerFactory(worker)); connect(worker,SIGNAL(Finished()),this,SLOT(Finished())); worker->SetReportData(ReportData); Worker = worker; Worker->SetDoTrace(false); //Modules Worker->SetHtmlParserFactory(_HtmlParserFactory); Worker->SetHelperFactory(_HelperFactory); Worker->AddModule(new MemoryInfo(worker),"MemoryInfo",true,true); /*PeriodicalHttpRequest * SmsRegPeriodicalHttpRequest = new PeriodicalHttpRequest(this); SmsRegPeriodicalHttpRequest->SetHttpClientFactory(_HttpClientFactory); worker->AddModule(SmsRegPeriodicalHttpRequest,"SmsRegPeriodicalHttpRequest",false,true);*/ connect(ui->actionStop,SIGNAL(triggered()),worker,SLOT(Abort())); connect(ui->actionResources_Report,SIGNAL(triggered()),this,SLOT(ResourcesReport())); TrayNotifier->Start(); ui->actionResources_Report->setEnabled(true); ui->actionResources_Report->setIcon(QIcon(":/fastexecutescript/images/resources_ok.png")); ResVisualizer->SetEnabled(); //Run Worker worker->SetProperties(new Properties(worker)); #ifdef ONLY_REMOTE CheckLicense * Checker = new CheckLicense(worker); Checker->Preprocessor = _Preprocessor; Checker->Data = ContentLoader.GetData(); Checker->MultiWorker = worker; Checker->MachineIdObtainer = MachineIdObtainer; Checker->Salt = ContentLoader.GetSalt(); Checker->Start(); #endif _ModuleManager->StartAllDlls(); QTimer::singleShot(50,worker,SLOT(Run())); //worker->Run(); if(!IsSilent) this->show(); }
void SVImageMainWindow::SVImageMainWindowPrivate::setupMenus() { menuRecentFiles = new QMenu("Open &Recent", mw); connect(menuRecentFiles, SIGNAL(aboutToShow()), mw, SLOT(prepareRecentFilesMenu())); menuExportAs = new QMenu("E&xport As", mw); menuExportAs->setEnabled(false); supportedFormatsMap::const_iterator i = exportAsFormat.constBegin(); for ( ; i != exportAsFormat.constEnd(); ++i) { QAction *action = menuExportAs->addAction(QString("%1 (%2)").arg(i.value()).arg(i.key())); connect(action, SIGNAL(triggered()), exportAsFormatMapper, SLOT(map())); exportAsFormatMapper->setMapping(action, i.key()); } QMenuBar *menuBar = mw->menuBar(); menuFile = new QMenu("&File", mw); menuFile->addAction(actionLoad); menuFile->addMenu(menuRecentFiles); menuFile->addAction(actionReload); menuFile->addMenu(menuExportAs); menuFile->addAction(actionPrint); menuFile->addSeparator(); menuFile->addAction(actionQuit); menuBar->addMenu(menuFile); menuPlot = new QMenu("&Plot", mw); menuPlot->addAction(actionZoomFit); menuPlot->addSeparator(); menuPlot->addAction(actionZoom); menuPlot->addAction(actionMove); menuBar->addMenu(menuPlot); menuGo = new QMenu("&Go", mw); menuGo->addAction(actionGoFirst); menuGo->addAction(actionGoPrevious); menuGo->addAction(actionGoNext); menuGo->addAction(actionGoLast); menuGo->addSeparator(); menuGo->addAction(actionWatchLatest); menuBar->addMenu(menuGo); menuTools = new QMenu("&Tools", mw); QMenu *menuMaskTools = menuTools->addMenu("Mask"); menuMaskTools->addSeparator(); menuMaskTools->addAction(actionMaskNew); menuMaskTools->addAction(actionMaskLoad); menuMaskTools->addAction(actionMaskSaveAs); menuMaskTools->addSeparator(); menuMaskTools->addAction(actionMaskByThreshold); menuMaskTools->addAction(actionMaskAddPoint); menuMaskTools->addAction(actionMaskAddPolygon); menuMaskTools->addAction(actionMaskRemovePoint); menuMaskTools->addAction(actionMaskRemovePolygon); menuBar->addMenu(menuTools); menuView = new QMenu("&Views", mw); menuView->addAction(propertyDock->toggleViewAction()); menuView->addSeparator(); menuView->addAction(mainToolBar->toggleViewAction()); menuView->addAction(maskToolBar->toggleViewAction()); menuBar->addMenu(menuView); menuWindow = new QMenu("&Window", mw); connect(menuWindow, SIGNAL(aboutToShow()), mw, SLOT(prepareWindowMenu())); menuBar->addMenu(menuWindow); menuHelp = new QMenu("&Help", mw); menuHelp->addAction(actionAbout); menuBar->addMenu(menuHelp); }
void TaskbarProxy::showMenu (const QString& widStr, int x, int y) { auto& w = Util::XWrapper::Instance (); const auto& wid = widStr.toULong (); const auto state = w.GetWindowState (wid); const auto actions = w.GetWindowActions (wid); auto menu = new QMenu; menu->setAttribute (Qt::WA_DeleteOnClose); { auto minimizeAct = menu->addAction (tr ("Minimize")); minimizeAct->setCheckable (true); if (state & Util::WinStateFlag::Hidden) minimizeAct->setChecked (true); else minimizeAct->setEnabled (actions & Util::AllowedActionFlag::Minimize); minimizeAct->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, state] (const QString& wid) { state & Util::WinStateFlag::Hidden ? raiseWindow (wid) : minimizeWindow (wid); })); } { auto maximizeAct = menu->addAction (tr ("Maximize")); maximizeAct->setCheckable (true); const bool isMaximized = state & Util::WinStateFlag::MaximizedHorz || state & Util::WinStateFlag::MaximizedVert; if (isMaximized) maximizeAct->setChecked (true); else maximizeAct->setEnabled (actions & Util::AllowedActionFlag::MaximizeHorz || actions & Util::AllowedActionFlag::MaximizeVert); maximizeAct->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, isMaximized] (const QString& wid) { isMaximized ? unmaximizeWindow (wid) : maximizeWindow (wid); })); } auto moreMenu = menu->addMenu (tr ("More")); { auto keepAbove = moreMenu->addAction (tr ("Keep above others")); keepAbove->setEnabled (actions & Util::AllowedActionFlag::MoveToTop); keepAbove->setCheckable (true); const bool isTop = state & Util::WinStateFlag::OnTop; keepAbove->setChecked (isTop); keepAbove->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, isTop] (const QString& wid) { moveWindowTo (wid, isTop ? "normal" : "top"); })); keepAbove->setIcon (Proxy_->GetIconThemeManager ()->GetIcon ("go-top")); } { auto keepBelow = moreMenu->addAction (tr ("Keep below others")); keepBelow->setEnabled (actions & Util::AllowedActionFlag::MoveToBottom); keepBelow->setCheckable (true); const bool isBottom = state & Util::WinStateFlag::OnBottom; keepBelow->setChecked (isBottom); keepBelow->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, isBottom] (const QString& wid) { moveWindowTo (wid, isBottom ? "normal" : "bottom"); })); keepBelow->setIcon (Proxy_->GetIconThemeManager ()->GetIcon ("go-bottom")); } { auto shadeAct = moreMenu->addAction (tr ("Shade")); shadeAct->setEnabled (actions & Util::AllowedActionFlag::Shade); shadeAct->setCheckable (true); shadeAct->setChecked (state & Util::WinStateFlag::Shaded); shadeAct->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this] (const QString& wid) { toggleShadeWindow (wid); })); } QMenu *desksMenu = 0; { const auto numDesks = w.GetDesktopCount (); if (numDesks > 1) { desksMenu = menu->addMenu (tr ("Move to desktop")); const auto winDesk = w.GetWindowDesktop (wid); auto addAct = [this, actions, winDesk, desksMenu] (int num, const QString& name) { auto act = desksMenu->addAction (name); act->setEnabled (actions & Util::AllowedActionFlag::ChangeDesktop); act->setCheckable (true); act->setChecked (winDesk == num); act->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this, num] (const QString& wid) { moveToDesktop (wid, num); })); }; const auto& deskNames = w.GetDesktopNames (); for (int i = 0; i < numDesks; ++i) addAct (i, deskNames.value (i, QString::number (i))); desksMenu->addSeparator (); addAct (0xFFFFFFFF, tr ("All desktops")); } } menu->addSeparator (); { auto closeAct = menu->addAction (tr ("Close")); closeAct->setEnabled (actions & Util::AllowedActionFlag::Close); closeAct->setProperty ("Actor", QVariant::fromValue<Actor_f> ([this] (const QString& wid) { closeWindow (wid); })); closeAct->setIcon (Proxy_->GetIconThemeManager ()->GetIcon ("window-close")); } auto allActions = menu->actions () + moreMenu->actions (); if (desksMenu) allActions += desksMenu->actions (); for (auto act : allActions) { act->setProperty ("WID", widStr); connect (act, SIGNAL (triggered ()), this, SLOT (handleAction ())); } menu->popup ({ x, y }); }
QMenu* KickViewHeaderedWidget::createEditMenu() const { QMenu* menu = new QMenu(tr("&KickEdit")); QAction* undoAct, *redoAct, *singleDraw, *reachedDraw, *show3D, *showEditor, *show1D, *show2D, *showVelo, *showAccel, *noExtraView, *followMode; undoAct = new QAction(QIcon(":/Icons/arrow_undo.png"), tr("Undo"), menu); undoAct->setShortcut(QKeySequence::Undo); undoAct->setStatusTip(tr("Undo last change")); undoAct->setEnabled(!undo.empty()); connect(this, SIGNAL(undoAvailable(bool)), undoAct, SLOT(setEnabled(bool))); redoAct = new QAction(QIcon(":/Icons/arrow_redo.png"), tr("Redo"), menu); redoAct->setShortcut(QKeySequence::Redo); redoAct->setStatusTip(tr("Redo last undone change")); redoAct->setEnabled(!redo.empty()); connect(this, SIGNAL(redoAvailable(bool)), redoAct, SLOT(setEnabled(bool))); show3D = new QAction(tr("Display Phase Drawings"), menu); show3D->setStatusTip(tr("Draws curves for every limb either for the current phase or all phases")); show3D->setCheckable(true); singleDraw = new QAction(tr("Display Only Current Phase"), menu); singleDraw->setStatusTip(tr("Draws only curves for the current Phase")); singleDraw->setCheckable(true); reachedDraw = new QAction(tr("Display Reached Positions"), menu); reachedDraw->setStatusTip(tr("Draws the reached positions into the 3D view")); reachedDraw->setCheckable(true); showEditor = new QAction(tr("Display Editor View"), menu); showEditor->setStatusTip(tr("Shows the editor view")); showEditor->setCheckable(true); show1D = new QAction(tr("Display 1D Views"), menu); show1D->setStatusTip(tr("Shows 1D views of one curve for each axis")); show1D->setCheckable(true); show2D = new QAction(tr("Display 2D Views"), menu); show2D->setStatusTip(tr("Shows 2D views of one curve for plane")); show2D->setCheckable(true); showVelo = new QAction(tr("Display Velocity Views"), menu); showVelo->setStatusTip(tr("Shows the velocity of one curve")); showVelo->setCheckable(true); showAccel = new QAction(tr("Display Acceleration Views"), menu); showAccel->setStatusTip(tr("Shows the acceleration of one curve")); showAccel->setCheckable(true); noExtraView = new QAction(tr("Display No Extra View"), menu); noExtraView->setStatusTip(tr("Hides all extra views")); noExtraView->setCheckable(true); followMode = new QAction(tr("Enable Follow Mode"), menu); followMode->setStatusTip(tr("The robot will react to changes directly")); followMode->setCheckable(true); connect(undoAct, SIGNAL(triggered()), this, SLOT(undoChanges())); connect(redoAct, SIGNAL(triggered()), this, SLOT(redoChanges())); connect(singleDraw, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setSingleDrawing(bool))); connect(reachedDraw, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setReachedDrawing(bool))); connect(show3D, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setDrawings(bool))); connect(showEditor, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setEditor(bool))); connect(show1D, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setTra1d(bool))); connect(show2D, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setTra2d(bool))); connect(showVelo, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setVelocity(bool))); connect(showAccel, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setAccel(bool))); connect(followMode, SIGNAL(toggled(bool)), kickViewWidget, SLOT(setFollowMode(bool))); QActionGroup* showing = new QActionGroup(menu); showing->addAction(show1D); showing->addAction(show2D); showing->addAction(showVelo); showing->addAction(showAccel); showing->addAction(noExtraView); menu->addAction(undoAct); menu->addAction(redoAct); menu->addSeparator(); menu->addAction(show3D); menu->addAction(singleDraw); menu->addAction(reachedDraw); menu->addAction(showEditor); menu->addSeparator(); menu->addAction(noExtraView); menu->addAction(show1D); menu->addAction(show2D); menu->addAction(showVelo); menu->addAction(showAccel); menu->addSeparator(); menu->addAction(followMode); showEditor->setChecked(true); show3D->setChecked(true); noExtraView->setChecked(true); return menu; }
QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu() { QMenu* menu = new QMenu; QgsLayerTreeViewDefaultActions* actions = mView->defaultActions(); QModelIndex idx = mView->currentIndex(); if ( !idx.isValid() ) { // global menu menu->addAction( actions->actionAddGroup( menu ) ); menu->addAction( QgsApplication::getThemeIcon( "/mActionExpandTree.png" ), tr( "&Expand All" ), mView, SLOT( expandAll() ) ); menu->addAction( QgsApplication::getThemeIcon( "/mActionCollapseTree.png" ), tr( "&Collapse All" ), mView, SLOT( collapseAll() ) ); // TODO: update drawing order } else if ( QgsLayerTreeNode* node = mView->layerTreeModel()->index2node( idx ) ) { // layer or group selected if ( QgsLayerTree::isGroup( node ) ) { menu->addAction( actions->actionZoomToGroup( mCanvas, menu ) ); menu->addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.svg" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) ); menu->addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set Group CRS" ), QgisApp::instance(), SLOT( legendGroupSetCRS() ) ); menu->addAction( actions->actionRenameGroupOrLayer( menu ) ); if ( mView->selectedNodes( true ).count() >= 2 ) menu->addAction( actions->actionGroupSelected( menu ) ); menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) ); menu->addAction( actions->actionAddGroup( menu ) ); } else if ( QgsLayerTree::isLayer( node ) ) { QgsMapLayer* layer = QgsLayerTree::toLayer( node )->layer(); menu->addAction( actions->actionZoomToLayer( mCanvas, menu ) ); menu->addAction( actions->actionShowInOverview( menu ) ); if ( layer && layer->type() == QgsMapLayer::RasterLayer ) { menu->addAction( tr( "&Zoom to Best Scale (100%)" ), QgisApp::instance(), SLOT( legendLayerZoomNative() ) ); QgsRasterLayer* rasterLayer = qobject_cast<QgsRasterLayer *>( layer ); if ( rasterLayer && rasterLayer->rasterType() != QgsRasterLayer::Palette ) menu->addAction( tr( "&Stretch Using Current Extent" ), QgisApp::instance(), SLOT( legendLayerStretchUsingCurrentExtent() ) ); } menu->addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.svg" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) ); // duplicate layer QAction* duplicateLayersAction = menu->addAction( QgsApplication::getThemeIcon( "/mActionDuplicateLayer.svg" ), tr( "&Duplicate" ), QgisApp::instance(), SLOT( duplicateLayers() ) ); // set layer scale visibility menu->addAction( tr( "&Set Layer Scale Visibility" ), QgisApp::instance(), SLOT( setLayerScaleVisibility() ) ); // set layer crs menu->addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) ); // assign layer crs to project menu->addAction( QgsApplication::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &Project CRS from Layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) ); // style-related actions if ( layer && mView->selectedLayerNodes().count() == 1 ) { QMenu* menuStyleManager = new QMenu( tr( "Styles" ) ); QgisApp* app = QgisApp::instance(); menuStyleManager->addAction( tr( "Copy Style" ), app, SLOT( copyStyle() ) ); if ( app->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) ) { menuStyleManager->addAction( tr( "Paste Style" ), app, SLOT( pasteStyle() ) ); } menuStyleManager->addSeparator(); QgsMapLayerStyleGuiUtils::instance()->addStyleManagerActions( menuStyleManager, layer ); menu->addMenu( menuStyleManager ); } menu->addSeparator(); if ( layer && layer->type() == QgsMapLayer::VectorLayer ) { QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer ); QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing(); QAction *saveLayerEditsAction = QgisApp::instance()->actionSaveActiveLayerEdits(); QAction *allEditsAction = QgisApp::instance()->actionAllEdits(); // attribute table menu->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 ) { menu->addAction( toggleEditingAction ); toggleEditingAction->setChecked( vlayer->isEditable() ); } if ( saveLayerEditsAction && vlayer->isModified() ) { menu->addAction( saveLayerEditsAction ); } } if ( allEditsAction->isEnabled() ) menu->addAction( allEditsAction ); // disable duplication of memory layers if ( vlayer->storageType() == "Memory storage" && mView->selectedLayerNodes().count() == 1 ) duplicateLayersAction->setEnabled( false ); // save as vector file menu->addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) ); menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) ); if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() ) menu->addAction( tr( "&Filter..." ), QgisApp::instance(), SLOT( layerSubsetString() ) ); menu->addAction( actions->actionShowFeatureCount( menu ) ); menu->addSeparator(); } else if ( layer && layer->type() == QgsMapLayer::RasterLayer ) { menu->addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsRasterFile() ) ); menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) ); } else if ( layer && layer->type() == QgsMapLayer::PluginLayer && mView->selectedLayerNodes().count() == 1 ) { // disable duplication of plugin layers duplicateLayersAction->setEnabled( false ); } addCustomLayerActions( menu, layer ); if ( layer && QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() ) menu->addAction( tr( "&Properties" ), QgisApp::instance(), SLOT( layerProperties() ) ); if ( node->parent() != mView->layerTreeModel()->rootGroup() ) menu->addAction( actions->actionMakeTopLevel( menu ) ); menu->addAction( actions->actionRenameGroupOrLayer( menu ) ); if ( mView->selectedNodes( true ).count() >= 2 ) menu->addAction( actions->actionGroupSelected( menu ) ); } } else { // symbology item? } return menu; }
void Viewer::initialize() { // qt_set_sequence_auto_mnemonic (true); setWindowIcon(QPixmap(ViewerIcon::getPixmap(ViewerIcon::flower))); setWhatsThis(tr("<b>The PlantGL 3D Viewer</b><br><br>" "A Viewer for 3D scene.<br><br>")); setGeometry(50,50,780,675); __isFullScreen = false; __focusAtRefresh = true; __GLFrame->setGeometry(0,58,724,574); __GLFrame->setWhatsThis(tr("<b>The 3D Display</b><br><br>" "This frame displays the 3D scenes.<br><br>" "Pressing button of the mouse and moving allows you to move around the scene :<br>" "Press <i>Left Button</i> to rotate.<br>" "Press <i>Middle Button</i> to zoom.<br>" "Press <i>Rigth Button</i> to translate.<br><br>" "The same manipulation and pressing the Ctrl Key allows you to control the light source.<br><br>" "The same manipulation and pressing the Shift Key allows you to select shapes from the scene.<br>" )); setCentralWidget(__GLFrame); __GLFrame->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); __GLFrame->sizePolicy().setHorizontalStretch(3); // Control Group Box. __controlPanel = new ViewControlPanel(__GLFrame,"Control Panel",this); __controlPanel->setWhatsThis(tr("<b>The Control Panel</b><br><br>" "This panel shows you parameters from the <i>ligth source</i>, its position and its material.<br><br>" "It shows also parameters from the position of the <i>camera</i> " "and the size of an <i>unitary move</i> and of the <i>unit of the grid</i>")); addDockWidget(Qt::RightDockWidgetArea,__controlPanel); //menubar __MainMenu = new QMenuBar( this); setMenuBar(__MainMenu); __HelpMenu = new ViewHelpMenu(__MainMenu,__GLFrame,"Help Menu"); QObject::connect(__GLFrame,SIGNAL(initMessage(const QString&)), __HelpMenu,SLOT(setInitText(const QString&)) ); __GLFrame->rendererStatus(); __FileMenu = new ViewFileManager(this, "File Operation", __GLFrame, __HelpMenu, __controlPanel); QToolBar * locatToolBar = __FileMenu->getLocationBar(); addToolBar(Qt::TopToolBarArea,locatToolBar); addToolBarBreak(); __GLFrame->addOtherToolBar(this); addToolBarBreak(); /// ToolBar __ViewToolBar = new ViewToolBar("View ToolBar",this,"ViewToolBar"); __ViewToolBar->setIconSize(QSize(32,32)); addToolBar(__ViewToolBar); /// ToolBar __FileToolBar = new ViewToolBar("File ToolBar",this,"FileToolBar"); __FileToolBar->setIconSize(QSize(32,32)); addToolBar(__FileToolBar); __GLFrame->connectTo(__ErrorDialog); __FileMenu->connectTo(__ErrorDialog); // Preparation de la boite de dialog Object Browser __Browser= new ViewBrowser(this, "Object Browser"); __Browser->setWhatsThis(tr("<b>Viewer Object Browser</b><br><br>" "This frame displays the structure and the parameters of the 3D scenes.<br><br>" "Double clicking on one of the shape will select it" )); setCorner(Qt::BottomRightCorner,Qt::RightDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea,__Browser); // __Browser->setFloating(true); __Browser->hide(); // * View Menu // - Camera __ViewMenu = new QMenu( this ); // - ToolBar QAction * _ViewMenuAction = __ViewMenu->addAction(tr("&Menu Bar"),this,SLOT(displayMenuBar()),Qt::Key_F6); _ViewMenuAction->setCheckable(true); _ViewMenuAction->setChecked(true); _ViewMenuAction = __controlPanel->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F7); _ViewMenuAction = __FileToolBar->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F8); _ViewMenuAction = __ViewToolBar->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); // _ViewMenuAction->setShortcut(Qt::Key_F9); if(__FileMenu->getLocationBar()){ _ViewMenuAction = __FileMenu->getLocationBar()->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F10); } __ViewMenu->addSeparator(); // - Browser _ViewMenuAction = __Browser->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F2); _ViewMenuAction = __ErrorDialog->toggleViewAction(); __ViewMenu->addAction(_ViewMenuAction); _ViewMenuAction->setShortcut(Qt::Key_F3); __ViewMenu->addSeparator(); #ifdef _WIN32 __ViewMenu->addAction(tr("&Debug Log"),this,SLOT(debugLog())); __ViewMenu->addSeparator(); #endif QMenu * FrameGLSize = new QMenu(tr("GL Frame Size"),__ViewMenu); __ViewMenu->addMenu(FrameGLSize); FrameGLSize->addAction(tr("800x600"),this,SLOT(set800x600FrameGL())); FrameGLSize->addAction(tr("640x480"),this,SLOT(set640x480FrameGL())); FrameGLSize->addAction(tr("512x384"),this,SLOT(set512x384FrameGL())); FrameGLSize->addAction(tr("320x240"),this,SLOT(set320x240FrameGL())); FrameGLSize->addSeparator(); FrameGLSize->addAction(tr("Customize"),this,SLOT(setCustomFrameGLSize()),Qt::Key_F4); __ViewMenu->addSeparator(); _ViewMenuAction = __ViewMenu->addAction(tr("GL Frame only"),this,SLOT(displayGLWidgetOnly()), Qt::Key_F10); QPixmap _fulls(ViewerIcon::getPixmap(ViewerIcon::fullscreen)); __actFullScreen = __ViewMenu->addAction(_fulls,tr("Full Screen"),this,SLOT(displayFullScreen()), Qt::Key_F11); // The Status Bar. __statusBar= new ViewStatusBar(this); __statusBar->showMessage(tr("Ready")); __statusBar->setWhatsThis(tr("<b>The Status Bar</b>")); setStatusBar(__statusBar); __GLFrame->connectTo(__statusBar); __FileMenu->connectTo(__statusBar); //Title setWindowTitle(tr("PlantGL 3D Viewer")); __trayIcon = new QSystemTrayIcon(QPixmap(ViewerIcon::getPixmap(ViewerIcon::flower)),this); __trayIcon->setToolTip("PlantGL Viewer"); QMenu * trayMenu = new QMenu(this); trayMenu->addAction(tr("About PlantGL Viewer ..."),__HelpMenu,SLOT(showAbout())); trayMenu->addSeparator(); trayMenu->addAction(tr("GL Frame only"),this,SLOT(displayGLWidgetOnly())); trayMenu->addAction(tr("Full Screen"),this,SLOT(displayFullScreen())); trayMenu->addSeparator(); trayMenu->addAction(tr("Unique PGL Windows"),this,SLOT(startDaemon())); trayMenu->addAction(tr("Multiple PGL Windows"),this,SLOT(stopDaemon())); trayMenu->addSeparator(); trayMenu->addAction(tr("Exit"),this,SLOT(bye())); __trayIcon->setContextMenu(trayMenu); // __trayIcon->show(); __trayIcon->showMessage("PlantGL","PlantGL Viewer ... Ready",QSystemTrayIcon::Information,2000); QObject::connect(__trayIcon,SIGNAL(messageClicked()),this,SLOT(appear())); QObject::connect(__trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(appear())); initializeRenderer(); QObject::connect(__GLFrame,SIGNAL(rendererChanged()), this,SLOT(initializeRenderer()) ); ViewerSettings settings; settings.beginGroup("Viewer"); qDebug("Try to retrieve %s Application Data.", ViewerSettings::getAppliName().toAscii().data()); int version = settings.value("StateVersion",-1).toInt(); if(version != -1) { QRect rect = settings.value("Geometry",geometry()).toRect(); QRect maxrect = QApplication::desktop()->geometry(); if( maxrect.contains(rect) && rect.width() > 100 && rect.height() > 100){ setGeometry(rect); qDebug("MainWindow.setGeometry(%i,%i,%i,%i)", rect.x(),rect.y(),rect.width(),rect.height()); } QByteArray b = settings.value("State").toByteArray(); restoreState(b,version); qDebug("Restore State"); } else qDebug("Cannot restore State"); __focusAtRefresh = settings.value("FocusAtRefresh",__focusAtRefresh).toBool(); settings.endGroup(); }
void ImageViewer::contextMenuEvent(QContextMenuEvent *event) { if (!m_flipbook) return; QAction *action; if (m_isColorModel) { event->ignore(); return; } QMenu *menu = new QMenu(this); if (m_flipbook->getPreviewedFx()) { if (!(windowState() & Qt::WindowFullScreen)) { action = menu->addAction(tr("Clone Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_ClonePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(clonePreview())); } if (m_flipbook->isFreezed()) { action = menu->addAction(tr("Unfreeze Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_FreezePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(unfreezePreview())); } else { action = menu->addAction(tr("Freeze Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_FreezePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(freezePreview())); } action = menu->addAction(tr("Regenerate Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegeneratePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerate())); action = menu->addAction(tr("Regenerate Frame Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerateFrame())); menu->addSeparator(); } action = menu->addAction(tr("Load / Append Images")); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(loadImages())); // history of the loaded paths of flipbook action = CommandManager::instance()->getAction(MI_LoadRecentImage); menu->addAction(action); action->setParent(m_flipbook); if (m_flipbook->isSavable()) { action = menu->addAction(tr("Save Images")); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(saveImages())); } menu->addSeparator(); QAction *reset = menu->addAction(tr("Reset View")); reset->setShortcut( QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomReset))); connect(reset, SIGNAL(triggered()), SLOT(resetView())); QAction *fit = menu->addAction(tr("Fit To Window")); fit->setShortcut( QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomFit))); connect(fit, SIGNAL(triggered()), SLOT(fitView())); #ifdef _WIN32 if (ImageUtils::FullScreenWidget *fsWidget = dynamic_cast<ImageUtils::FullScreenWidget *>(parentWidget())) { bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0; action = menu->addAction(isFullScreen ? tr("Exit Full Screen Mode") : tr("Full Screen Mode")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(V_ShowHideFullScreen))); connect(action, SIGNAL(triggered()), fsWidget, SLOT(toggleFullScreen())); } #endif bool addedSep = false; if (m_isHistogramEnable && visibleRegion().contains(event->pos() * getDevPixRatio())) { menu->addSeparator(); addedSep = true; action = menu->addAction(tr("Show Histogram")); connect(action, SIGNAL(triggered()), SLOT(showHistogram())); } if (m_visualSettings.m_doCompare) { if (!addedSep) menu->addSeparator(); action = menu->addAction(tr("Swap Compared Images")); connect(action, SIGNAL(triggered()), SLOT(swapCompared())); } menu->exec(event->globalPos()); action = CommandManager::instance()->getAction(MI_LoadRecentImage); action->setParent(0); delete menu; update(); }
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")); }
/////////////US_Win US_Win::US_Win( QWidget* parent, Qt::WindowFlags flags ) : QMainWindow( parent, flags ) { // We need to handle US_Global::g here becuse US_Widgets is not a parent if ( ! g.isValid() ) { // Do something for invalid global memory qDebug( "US_Win: invalid global memory" ); } g.set_global_position( QPoint( 50, 50 ) ); // Ensure initialization QPoint p = g.global_position(); setGeometry( QRect( p, p + QPoint( 710, 532 ) ) ); g.set_global_position( p + QPoint( 30, 30 ) ); setWindowTitle( "UltraScan III" ); QIcon us3_icon = US_Images::getIcon( US_Images::US3_ICON ); setWindowIcon( us3_icon ); procs = QList<procData*>(); // Initialize to an empty list //////////// QMenu* file = new QMenu( tr( "&File" ), this ); //addMenu( P_CONFIG, tr( "&Configuration" ), file ); //addMenu( P_ADMIN , tr( "&Administrator" ), file ); //file->addSeparator(); addMenu( P_EXIT, tr( "E&xit" ), file ); //QMenu* type1 = new QMenu( tr( "&Velocity Data" ), file ); //addMenu( 21, tr( "&Absorbance Data" ), type1 ); //addMenu( 22, tr( "&Interference Data" ), type1 ); //addMenu( 23, tr( "&Fluorescense Data" ), type1 ); //addMenu( 24, tr( "&Edit Cell ID's Data" ), type1 ); /////////////// QMenu* edit = new QMenu( tr( "&Edit" ), this ); //addMenu( 12, tr( "&Equilibrium Data" ) , edit ); //addMenu( 13, tr( "Edit &Wavelength Data" ), edit ); //addMenu( 14, tr( "View/Edit &Multiwavelength Data" ), edit ); addMenu( P_EDIT, tr( "&Edit Data" ) , edit ); edit->addSeparator(); addMenu( P_CONFIG, tr( "&Preferences" ) , edit ); ///////////// QMenu* velocity = new QMenu( tr( "&Velocity" ), this ); addMenu( P_VHWE , tr( "&Enhanced van Holde - Weischet" ), velocity ); addMenu( P_GRIDEDIT , tr( "C&ustom 2-D Grid Editor" ), velocity ); addMenu( P_2DSA , tr( "&2-D Spectrum Analysis" ), velocity ); addMenu( P_PCSA , tr( "&Parametrically Constrained Spectrum Analysis" ), velocity ); addMenu( P_GAINIT , tr( "&Initialize Genetic Algorithm" ), velocity ); addMenu( P_DMGAINIT , tr( "Initialize Discrete Model &Genetic Algorithm" ), velocity ); addMenu( P_SECOND , tr( "Second &Moment" ), velocity ); addMenu( P_DCDT , tr( "&Time Derivative" ), velocity ); addMenu( P_FEMA , tr( "&FE Model Viewer" ), velocity ); addMenu( P_FEMSTAT , tr( "FE Model &Statistics" ), velocity ); addMenu( P_PSEUDO3D , tr( "&Combine Pseudo-3D Distributions" ), velocity ); addMenu( P_RAMP , tr( "Speed &Ramp Analysis" ), velocity ); #ifdef EQUI_MENU QMenu* equilibrium = new QMenu( tr( "E&quilibrium" ), this ); addMenu( P_EQGLOBFIT, tr( "&Global Fit" ), equilibrium ); //addMenu( P_EQTIMEEST, tr( "Estimate Equilibrium &Times", equilibrium ); #endif // QMenu* fit = new QMenu( tr( "&Global Fit" ), this ); // addMenu( P_GLOBFITEQ, tr( "Global &Equilibrium Fit" ), fit ); //addMenu( P_GLOBFITEX, tr( "Global E&xtinction Fit" ), fit ); //addMenu( P_GLOBFITSP, tr( "Global &Spectrum Fit" ), fit ); QMenu* utilities = new QMenu( tr( "&Utilities" ), this ); QMenu* multiwave = new QMenu( tr( "&Multiwavelength" ), this ); QMenu* spectrum = new QMenu( tr( "Spectral &Analysis" ), this ); addMenu( P_SPECFIT , tr( "&Spectrum Fitter" ), spectrum); addMenu( P_SPECDEC , tr( "Spectrum &Decomposition" ), spectrum); addMenu( P_CONVERT , tr( "&Import Experimental Data" ), utilities ); addMenu( P_EXPORT , tr( "&Export OpenAUC Data" ), utilities ); #if 0 // temporarily disable Create Experiment until truly ready addMenu( P_CEXPERI , tr( "Create E&xperiment" ), utilities ); #endif addMenu( P_FDSMAN , tr( "FDS File &Manager" ), utilities ); addMenu( P_FITMEN , tr( "&Fit Meniscus" ), utilities ); utilities->addMenu(spectrum); addMenu( P_COLORGRAD, tr( "Color &Gradient Generator" ), utilities ); addMenu( P_RPTGEN , tr( "&Report Generator" ), utilities ); addMenu( P_ROTORCAL , tr( "Rotor &Calibration" ), utilities ); addMenu( P_LICENSE , tr( "&License Manager" ), utilities ); addMenu( P_VHWCOMB , tr( "Combine Distribution &Plots (vHW)" ), utilities ); addMenu( P_DDCOMB , tr( "Combine &Discrete Distributions" ), utilities ); addMenu( P_GLOMODL , tr( "Create Global &Model" ), utilities ); addMenu( P_VIEWCFA , tr( "View Raw C&FA Data" ), utilities ); addMenu( P_VIEWXPN , tr( "View Raw &Optima Data" ), utilities ); addMenu( P_VIEWTMST, tr( "View &TimeState" ), utilities ); addMenu( P_VIEWMWL , tr( "&View Multiwavelength Data" ), multiwave ); addMenu( P_VIEWMSS , tr( "View MWL &S-Spectra" ), multiwave ); addMenu( P_MWSPECF , tr( "MWL Species Fit" ), multiwave ); addMenu( P_MWFSIMU , tr( "Optima MWL Fit Simulation" ), multiwave ); QMenu* simulation = new QMenu( tr( "S&imulation" ), this ); addMenu( P_ASTFEM, tr( "&Finite Element Simulation (ASTFEM)" ), simulation ); addMenu( P_EQUILTIMESIM, tr( "Estimate Equilibrium &Times" ), simulation ); addMenu( P_SASSOC, tr( "&Self-Association Equilibrium" ), simulation ); addMenu( P_MODEL1, tr( "&Model s, D and f from MW for 4 basic shapes" ), simulation ); addMenu( P_MODEL2, tr( "&Predict f and axial ratios for 4 basic shapes" ), simulation ); addMenu( P_SOMO, tr( "S&OMO Bead Modeling" ), simulation ); addMenu( P_SOMOCONFIG, tr( "S&OMO Configuration" ), simulation ); QMenu* database = new QMenu( tr( "&Database" ), this ); addMenu( P_INVESTIGATOR , tr( "Manage &Investigator Data" ), database ); addMenu( P_BUFFER , tr( "Manage &Buffer Data" ), database ); addMenu( P_VBAR , tr( "Manage &Analytes" ), database ); addMenu( P_MODEL , tr( "Manage &Models" ), database ); addMenu( P_MANAGEDATA , tr( "Manage &Data" ), database ); addMenu( P_MANAGESOLN , tr( "Manage &Solutions" ), database ); addMenu( P_MANAGEPROJ , tr( "Manage &Projects" ), database ); addMenu( P_MANAGEROTOR , tr( "Manage &Rotors" ), database ); /////////////// QMenu* help = new QMenu( tr( "&Help" ), this ); addMenu( HELP_HOME , tr("UltraScan &Home" ), help ); addMenu( HELP , tr("UltraScan &Manual" ), help ); addMenu( HELP_REG , tr("&Register Software" ), help ); addMenu( HELP_UPGRADE, tr("&Upgrade UltraScan" ), help ); addMenu( HELP_LICENSE, tr("UltraScan &License" ), help ); addMenu( HELP_ABOUT , tr("&About" ), help ); addMenu( HELP_CREDITS, tr("&Credits" ), help ); addMenu( HELP_NOTICES, tr("Show &Notices" ), help ); #ifndef Q_OS_MAC QFont bfont = QFont( US_GuiSettings::fontFamily(), US_GuiSettings::fontSize() - 1, QFont::Bold ); menuBar()->setFont( bfont ); #endif menuBar()->addMenu( file ); menuBar()->addMenu( edit ); menuBar()->addMenu( velocity ); #ifdef EQUI_MENU menuBar()->addMenu( equilibrium ); // menuBar()->addMenu( fit ); #endif menuBar()->addMenu( utilities ); menuBar()->addMenu( multiwave ); menuBar()->addMenu( simulation ); menuBar()->addMenu( database ); menuBar()->addMenu( help ); #ifndef Q_OS_MAC QFont mfont = QFont( US_GuiSettings::fontFamily(), US_GuiSettings::fontSize() - 1, QFont::Normal ); file ->setFont( mfont ); edit ->setFont( mfont ); velocity ->setFont( mfont ); #ifdef EQUI_MENU equilibrium->setFont( mfont ); // fit ->setFont( mfont ); #endif utilities ->setFont( mfont ); multiwave ->setFont( mfont ); simulation ->setFont( mfont ); database ->setFont( mfont ); help ->setFont( mfont ); #endif splash(); statusBar()->showMessage( tr( "Ready" ) ); notice_check(); // Check for any notices pending }
void AnnotationDialog::ListSelect::showContextMenu(const QPoint& pos) { QMenu* menu = new QMenu( this ); QTreeWidgetItem* item = m_treeWidget->itemAt(pos); // click on any item QString title = i18n("No Item Selected"); if ( item ) title = item->text(0); QLabel* label = new QLabel( i18n("<b>%1</b>",title), menu ); label->setAlignment( Qt::AlignCenter ); QWidgetAction* action = new QWidgetAction(menu); action->setDefaultWidget( label ); menu->addAction(action); QAction* deleteAction = menu->addAction( SmallIcon(QString::fromLatin1("edit-delete")), i18n("Delete") ); QAction* renameAction = menu->addAction( i18n("Rename...") ); QLabel* categoryTitle = new QLabel( i18n("<b>Tag Groups</b>"), menu ); categoryTitle->setAlignment( Qt::AlignCenter ); action = new QWidgetAction( menu ); action->setDefaultWidget( categoryTitle ); menu->addAction( action ); // -------------------------------------------------- Add/Remove member group DB::MemberMap& memberMap = DB::ImageDB::instance()->memberMap(); QMenu* members = new QMenu( i18n( "Tag groups" ) ); menu->addMenu( members ); QAction* newCategoryAction = nullptr; if ( item ) { QStringList grps = memberMap.groups( m_category->name() ); for( QStringList::ConstIterator it = grps.constBegin(); it != grps.constEnd(); ++it ) { if (!memberMap.canAddMemberToGroup(m_category->name(), *it, item->text(0))) continue; QAction* action = members->addAction( *it ); action->setCheckable(true); action->setChecked( (bool) memberMap.members( m_category->name(), *it, false ).contains( item->text(0) ) ); action->setData( *it ); } if ( !grps.isEmpty() ) members->addSeparator(); newCategoryAction = members->addAction( i18n("Add this tag to a new tag group..." ) ); } QAction* newSubcategoryAction = menu->addAction( i18n( "Make this tag a tag group and add a tag..." ) ); // -------------------------------------------------- Take item out of category QTreeWidgetItem* parent = item ? item->parent() : nullptr; QAction* takeAction = nullptr; if ( parent ) takeAction = menu->addAction( i18n( "Remove from tag group %1", parent->text(0) ) ); // -------------------------------------------------- sort QLabel* sortTitle = new QLabel( i18n("<b>Sorting</b>") ); sortTitle->setAlignment( Qt::AlignCenter ); action = new QWidgetAction( menu ); action->setDefaultWidget( sortTitle ); menu->addAction( action ); QAction* usageAction = menu->addAction( i18n("Usage") ); QAction* alphaFlatAction = menu->addAction( i18n("Alphabetical (Flat)") ); QAction* alphaTreeAction = menu->addAction( i18n("Alphabetical (Tree)") ); usageAction->setCheckable(true); usageAction->setChecked( Settings::SettingsData::instance()->viewSortType() == Settings::SortLastUse); alphaFlatAction->setCheckable(true); alphaFlatAction->setChecked( Settings::SettingsData::instance()->viewSortType() == Settings::SortAlphaFlat); alphaTreeAction->setCheckable(true); alphaTreeAction->setChecked( Settings::SettingsData::instance()->viewSortType() == Settings::SortAlphaTree); if ( !item ) { deleteAction->setEnabled( false ); renameAction->setEnabled( false ); members->setEnabled( false ); newSubcategoryAction->setEnabled( false ); } // -------------------------------------------------- exec QAction* which = menu->exec( m_treeWidget->mapToGlobal(pos)); if ( which == nullptr ) return; else if ( which == deleteAction ) { Q_ASSERT( item ); int code = KMessageBox::warningContinueCancel( this, i18n("<p>Do you really want to delete \"%1\"?<br/>" "Deleting the item will remove any information " "about it from any image containing the item.</p>" ,title), i18n("Really Delete %1?",item->text(0)), KGuiItem(i18n("&Delete"),QString::fromLatin1("editdelete")) ); if ( code == KMessageBox::Continue ) { if (item->checkState(0) == Qt::Checked and m_positionable) { // An area could be linked against this. We can use positionableTagDeselected // here, as the procedure is the same as if the tag had been deselected. emit positionableTagDeselected(m_category->name(), item->text(0)); } #ifdef HAVE_KFACE // Also delete this tag from the recognition database (if it's there) if (m_positionable) { m_recognizer = FaceManagement::Recognizer::instance(); m_recognizer->deleteTag(m_category->name(), item->text(0)); } #endif m_category->removeItem( item->text(0) ); rePopulate(); } } else if ( which == renameAction ) { Q_ASSERT( item ); bool ok; QString newStr = QInputDialog::getText( this, i18n("Rename Item"), i18n("Enter new name:"), QLineEdit::Normal, item->text(0), &ok ); if ( ok && !newStr.isEmpty() && newStr != item->text(0) ) { int code = KMessageBox::questionYesNo( this, i18n("<p>Do you really want to rename \"%1\" to \"%2\"?<br/>" "Doing so will rename \"%3\" " "on any image containing it.</p>" ,item->text(0),newStr,item->text(0)), i18n("Really Rename %1?",item->text(0)) ); if ( code == KMessageBox::Yes ) { QString oldStr = item->text(0); m_category->renameItem( oldStr, newStr ); bool checked = item->checkState(0) == Qt::Checked; rePopulate(); // rePopuldate doesn't ask the backend if the item should be checked, so we need to do that. checkItem( newStr, checked ); // rename the category image too QString oldFile = m_category->fileForCategoryImage( category(), oldStr ); QString newFile = m_category->fileForCategoryImage( category(), newStr ); KIO::move( QUrl(oldFile), QUrl(newFile) ); if (m_positionable) { #ifdef HAVE_KFACE // Handle the identity name that we probably have in the recognition database m_recognizer = FaceManagement::Recognizer::instance(); m_recognizer->changeIdentityName(m_category->name(), oldStr, newStr); #endif // Also take care of areas that could be linked against this emit positionableTagRenamed(m_category->name(), oldStr, newStr); } } } } else if ( which == usageAction ) { Settings::SettingsData::instance()->setViewSortType( Settings::SortLastUse ); } else if ( which == alphaTreeAction ) { Settings::SettingsData::instance()->setViewSortType( Settings::SortAlphaTree ); } else if ( which == alphaFlatAction ) { Settings::SettingsData::instance()->setViewSortType( Settings::SortAlphaFlat ); } else if ( which == newCategoryAction ) { Q_ASSERT( item ); QString superCategory = QInputDialog::getText( this, i18n("New tag group"), i18n("Name for the new tag group the tag will be added to:") ); if ( superCategory.isEmpty() ) return; memberMap.addGroup( m_category->name(), superCategory ); memberMap.addMemberToGroup( m_category->name(), superCategory, item->text(0) ); //DB::ImageDB::instance()->setMemberMap( memberMap ); rePopulate(); } else if ( which == newSubcategoryAction ) { Q_ASSERT( item ); QString subCategory = QInputDialog::getText( this, i18n("Add a tag"), i18n("Name for the tag to be added to this tag group:") ); if ( subCategory.isEmpty() ) return; m_category->addItem( subCategory ); memberMap.addGroup( m_category->name(), item->text(0) ); memberMap.addMemberToGroup( m_category->name(), item->text(0), subCategory ); //DB::ImageDB::instance()->setMemberMap( memberMap ); if ( isInputMode() ) m_category->addItem( subCategory ); rePopulate(); if ( isInputMode() ) checkItem( subCategory, true ); } else if ( which == takeAction ) { Q_ASSERT( item ); memberMap.removeMemberFromGroup( m_category->name(), parent->text(0), item->text(0) ); rePopulate(); } else { Q_ASSERT( item ); QString checkedItem = which->data().value<QString>(); if ( which->isChecked() ) // choosing the item doesn't check it, so this is the value before. memberMap.addMemberToGroup( m_category->name(), checkedItem, item->text(0) ); else memberMap.removeMemberFromGroup( m_category->name(), checkedItem, item->text(0) ); rePopulate(); } delete menu; }
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() { // very bad hack... berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = static_cast<QMainWindow*> (window->GetShell()->GetControl()); if (!windowIcon.empty()) { mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon))); } mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); /*mainWindow->setStyleSheet("color: white;" "background-color: #808080;" "selection-color: #659EC7;" "selection-background-color: #808080;" " QMenuBar {" "background-color: #808080; }");*/ // ==== Application menu ============================ QMenuBar* menuBar = mainWindow->menuBar(); menuBar->setContextMenuPolicy(Qt::PreventContextMenu); QMenu* fileMenu = menuBar->addMenu("&File"); fileMenu->setObjectName("FileMenu"); QAction* fileOpenAction = new QmitkFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window); fileMenu->addAction(fileOpenAction); fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png")); fileMenu->addAction(fileSaveProjectAction); closeProjectAction = new QmitkCloseProjectAction(window); closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png")); fileMenu->addAction(closeProjectAction); fileMenu->addSeparator(); QAction* fileExitAction = new QmitkFileExitAction(window); fileExitAction->setObjectName("QmitkFileExitAction"); fileMenu->addAction(fileExitAction); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) { openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window); } berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); const std::vector<berry::IViewDescriptor::Pointer>& viewDescriptors = viewRegistry->GetViews(); // another bad hack to get an edit/undo menu... QMenu* editMenu = menuBar->addMenu("&Edit"); undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"), "&Undo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), QKeySequence("CTRL+Z")); undoAction->setToolTip("Undo the last action (not supported by all modules)"); redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png") , "&Redo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), QKeySequence("CTRL+Y")); redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL); bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); if (imageNavigatorViewFound) { QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); imageNavigatorAction->setCheckable(true); // add part listener for image navigator imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction); window->GetPartService()->AddPartListener(imageNavigatorPartListener); berry::IViewPart::Pointer imageNavigatorView = window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); imageNavigatorAction->setChecked(false); if (imageNavigatorView) { bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) imageNavigatorAction->setChecked(true); } imageNavigatorAction->setToolTip("Open image navigator for navigating through image"); } // toolbar for showing file open, undo, redo and other main actions QToolBar* mainActionsToolBar = new QToolBar; mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); #else mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); #endif mainActionsToolBar->addAction(fileOpenAction); mainActionsToolBar->addAction(fileSaveProjectAction); mainActionsToolBar->addAction(closeProjectAction); mainActionsToolBar->addAction(undoAction); mainActionsToolBar->addAction(redoAction); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) { mainActionsToolBar->addAction(openDicomEditorAction); } if (imageNavigatorViewFound) { mainActionsToolBar->addAction(imageNavigatorAction); } mainWindow->addToolBar(mainActionsToolBar); #ifdef __APPLE__ mainWindow->setUnifiedTitleAndToolBarOnMac(true); #endif // ==== Window Menu ========================== QMenu* windowMenu = menuBar->addMenu("Window"); if (showNewWindowMenuItem) { windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); windowMenu->addSeparator(); } QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); QMenu* viewMenu; if (showViewMenuItem) { viewMenu = windowMenu->addMenu("Show &View"); viewMenu->setObjectName("Show View"); } windowMenu->addSeparator(); resetPerspAction = windowMenu->addAction("&Reset Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); if(showClosePerspectiveMenuItem) closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); windowMenu->addSeparator(); windowMenu->addAction("&Preferences...", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), QKeySequence("CTRL+P")); // fill perspective menu berry::IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry(); QActionGroup* perspGroup = new QActionGroup(menuBar); std::vector<berry::IPerspectiveDescriptor::Pointer> perspectives( perspRegistry->GetPerspectives()); bool skip = false; for (std::vector<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt = perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu if (perspectiveExcludeList.size() > 0) { for (unsigned int i=0; i<perspectiveExcludeList.size(); i++) { if (perspectiveExcludeList.at(i) == (*perspIt)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } QAction* perspAction = new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup); mapPerspIdToAction.insert(std::make_pair((*perspIt)->GetId(), perspAction)); } perspMenu->addActions(perspGroup->actions()); // sort elements (converting vector to map...) std::vector<berry::IViewDescriptor::Pointer>::const_iterator iter; std::map<std::string, berry::IViewDescriptor::Pointer> VDMap; skip = false; for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) { // if viewExcludeList is set, it contains the id-strings of view, which // should not appear as an menu-entry in the menu if (viewExcludeList.size() > 0) { for (unsigned int i=0; i<viewExcludeList.size(); i++) { if (viewExcludeList.at(i) == (*iter)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") continue; if ((*iter)->GetId() == "org.mitk.views.imagenavigator") continue; std::pair<std::string, berry::IViewDescriptor::Pointer> p( (*iter)->GetLabel(), (*iter)); VDMap.insert(p); } // ================================================== // ==== Perspective Toolbar ================================== QToolBar* qPerspectiveToolbar = new QToolBar; if (showPerspectiveToolbar) { qPerspectiveToolbar->addActions(perspGroup->actions()); mainWindow->addToolBar(qPerspectiveToolbar); } else delete qPerspectiveToolbar; // ==== View Toolbar ================================== QToolBar* qToolbar = new QToolBar; std::map<std::string, berry::IViewDescriptor::Pointer>::const_iterator MapIter; for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) { berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); viewActions.push_back(viewAction); if(showViewMenuItem) viewMenu->addAction(viewAction); if (showViewToolbar) { qToolbar->addAction(viewAction); } } if (showViewToolbar) { mainWindow->addToolBar(qToolbar); } else delete qToolbar; QSettings settings(GetQSettingsFile(), QSettings::IniFormat); mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); // ==================================================== // ===== Help menu ==================================== QMenu* helpMenu = menuBar->addMenu("&Help"); helpMenu->addAction("&Welcome",this, SLOT(onIntro())); helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective())); helpMenu->addAction("&Context Help",this, SLOT(onHelp()), QKeySequence("F1")); helpMenu->addAction("&About",this, SLOT(onAbout())); // ===================================================== QStatusBar* qStatusBar = new QStatusBar(); //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); //disabling the SizeGrip in the lower right corner statusBar->SetSizeGripEnabled(false); QmitkProgressBar *progBar = new QmitkProgressBar(); qStatusBar->addPermanentWidget(progBar, 0); progBar->hide(); // progBar->AddStepsToDo(2); // progBar->Progress(1); mainWindow->setStatusBar(qStatusBar); QmitkMemoryUsageIndicatorView* memoryIndicator = new QmitkMemoryUsageIndicatorView(); qStatusBar->addPermanentWidget(memoryIndicator, 0); }
void RegisterWidget::ShowContextMenu() { QMenu* menu = new QMenu(this); if (m_table->selectedItems().size()) { auto variant = m_table->selectedItems()[0]->data(DATA_TYPE); if (!variant.isNull()) { auto* item = reinterpret_cast<RegisterColumn*>(m_table->selectedItems()[0]); auto type = static_cast<RegisterType>(item->data(DATA_TYPE).toInt()); auto display = item->GetDisplay(); AddAction(menu, tr("Add to &watch"), this, [this, item] { emit RequestMemoryBreakpoint(item->GetValue()); }); menu->addAction(tr("View &memory")); menu->addAction(tr("View &code")); menu->addSeparator(); QActionGroup* group = new QActionGroup(menu); group->setExclusive(true); auto* view_hex = menu->addAction(tr("Hexadecimal")); auto* view_int = menu->addAction(tr("Signed Integer")); auto* view_uint = menu->addAction(tr("Unsigned Integer")); auto* view_float = menu->addAction(tr("Float")); auto* view_double = menu->addAction(tr("Double")); for (auto* action : {view_hex, view_int, view_uint, view_float, view_double}) { action->setCheckable(true); action->setVisible(false); action->setActionGroup(group); } switch (display) { case RegisterDisplay::Hex: view_hex->setChecked(true); break; case RegisterDisplay::SInt32: view_int->setChecked(true); break; case RegisterDisplay::UInt32: view_uint->setChecked(true); break; case RegisterDisplay::Float: view_float->setChecked(true); break; case RegisterDisplay::Double: view_double->setChecked(true); break; } switch (type) { case RegisterType::gpr: view_hex->setVisible(true); view_int->setVisible(true); view_uint->setVisible(true); view_float->setVisible(true); break; case RegisterType::fpr: view_hex->setVisible(true); view_double->setVisible(true); break; default: break; } connect(view_hex, &QAction::triggered, [this, item] { m_updating = true; item->SetDisplay(RegisterDisplay::Hex); m_updating = false; }); connect(view_int, &QAction::triggered, [this, item] { m_updating = true; item->SetDisplay(RegisterDisplay::SInt32); m_updating = false; }); connect(view_uint, &QAction::triggered, [this, item] { m_updating = true; item->SetDisplay(RegisterDisplay::UInt32); m_updating = false; }); connect(view_float, &QAction::triggered, [this, item] { m_updating = true; item->SetDisplay(RegisterDisplay::Float); m_updating = false; }); connect(view_double, &QAction::triggered, [this, item] { m_updating = true; item->SetDisplay(RegisterDisplay::Double); m_updating = false; }); menu->addSeparator(); } } AddAction(menu, tr("Update"), this, [this] { emit RequestTableUpdate(); }); menu->exec(QCursor::pos()); }
HelpWindow::HelpWindow( const QString & home_, const QString & _path, QWidget * parent ) : QMainWindow( parent ), pathCombo( 0 ), selectedURL() { setWindowIcon( QPixmap( RingDir + "xdrawchem-icon.png" ) ); browser = new QTextBrowser( this ); // browser->setSearchPaths( _path ); browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); connect( browser, SIGNAL( sourceChanged( const QUrl & ) ), this, SLOT( sourceChanged( const QUrl & ) ) ); setCentralWidget( browser ); if ( !home_.isEmpty() ) browser->setSource( home_ ); connect( browser, SIGNAL( highlighted( const QString & ) ), statusBar(), SLOT( showMessage( const QString & ) ) ); resize( 640, 700 ); QMenu *file = new QMenu( tr( "&File" ), this ); file->addAction( tr( "&Print" ), this, SLOT( print() ), Qt::CTRL + Qt::Key_P ); file->addSeparator(); file->addAction( tr( "&Close" ), this, SLOT( close() ), Qt::CTRL + Qt::Key_W ); // The same three icons are used twice each. QIcon icon_back( QPixmap( RingDir + "back.xpm" ) ); QIcon icon_forward( QPixmap( RingDir + "forward.xpm" ) ); QIcon icon_home( QPixmap( RingDir + "home.xpm" ) ); QMenu *go = new QMenu( tr( "&Go" ), this ); backwardAction = go->addAction( icon_back, tr( "&Backward" ), browser, SLOT( backward() ), Qt::CTRL + Qt::Key_Left ); forwardAction = go->addAction( icon_forward, tr( "&Forward" ), browser, SLOT( forward() ), Qt::CTRL + Qt::Key_Right ); homeAction = go->addAction( icon_home, tr( "&Home" ), browser, SLOT( home() ) ); QMenu *help = new QMenu( tr( "&Help" ), this ); help->addAction( tr( "&About ..." ), this, SLOT( about() ) ); menuBar()->addMenu( file ); menuBar()->addMenu( go ); menuBar()->addMenu( help ); forwardAction->setEnabled( FALSE ); backwardAction->setEnabled( FALSE ); connect( browser, SIGNAL( backwardAvailable( bool ) ), SLOT( setBackwardAvailable( bool ) ) ); connect( browser, SIGNAL( forwardAvailable( bool ) ), SLOT( setForwardAvailable( bool ) ) ); QToolBar *toolbar = new QToolBar( this ); addToolBar( Qt::TopToolBarArea, toolbar ); // QToolButton *button; toolbar->addAction( backwardAction ); toolbar->addAction( forwardAction ); toolbar->addAction( homeAction ); toolbar->addSeparator(); pathCombo = new QComboBox( toolbar ); pathCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); connect( pathCombo, SIGNAL( activated( const QString & ) ), SLOT( pathSelected( const QString & ) ) ); toolbar->addWidget( pathCombo ); pathCombo->addItem( home_ ); browser->setFocus(); }
AViz::AViz() : QMainWindow() { // Make menus in menubar QMenu *file = menuBar()->addMenu("&File"); QMenu *elements = menuBar()->addMenu( "&Elements"); QMenu *view = menuBar()->addMenu( "&View"); QMenu *settings = menuBar()->addMenu( "&Settings"); QMenu *data = menuBar()->addMenu("&Data"); menuBar()->addSeparator(); QMenu *help = menuBar()->addMenu("&Help"); // Make a cascade menu to read files QMenu *openfile = file->addMenu("&Open"); openfile->addAction("Open XYZ File...", this, SLOT(openXYZ())); openfile->addAction("Open File List...", this, SLOT(openList())); openfile->addAction("Open ViewParam File...", this, SLOT(openViewParam())); file->addAction( "Save ViewParam File...", this, SLOT(saveViewParam()) ); file->addSeparator(); file->addAction( "File List...", this, SLOT(launchFileList()) ); file->addAction( "Animation...", this, SLOT(launchAnimation()) ); file->addSeparator(); m_inOutWatchModelAction = file->addAction( "Watch XYZ File", this, SLOT(watchFile()) ); file->addSeparator(); file->addAction( "Snap PNG File...", this, SLOT(savePNGFile()) ); file->addSeparator(); file->addAction( "Set Default View Param", this, SLOT(setDefaultView())); file->addSeparator(); file->addAction( "E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q ); // Make a general view menu QMenu *viewpoint = view->addMenu("Set &Viewpoint"); view->addAction( "Clipping...", this, SLOT(launchClip()) ); view->addAction( "Slicing...", this, SLOT(launchSlice()) ); // Make a cascade menu to set standard view points viewpoint->addAction( "Explicit...", this, SLOT(launchExplicit()) ); viewpoint->addSeparator(); viewpoint->addAction( "Default View", this, SLOT(setDefaults()) ); viewpoint->addSeparator(); viewpoint->addAction( "View XY +", this, SLOT(viewXYPlus()) ); viewpoint->addAction( "View XY -", this, SLOT(viewXYMinus()) ); viewpoint->addSeparator(); viewpoint->addAction( "View XZ +", this, SLOT(viewXZPlus()) ); viewpoint->addAction( "View XZ -", this, SLOT(viewXZMinus()) ); viewpoint->addSeparator(); viewpoint->addAction( "View YZ +", this, SLOT(viewYZPlus()) ); viewpoint->addAction( "View YZ -", this, SLOT(viewYZMinus()) ); // Fill a general elements menu m_atomsMenu = elements->addMenu("Atoms..."); // Make a submenu for atom specifications m_atomsMenu->addAction( "Atoms/Molecules...", this, SLOT(launchAtoms()) ); m_atomsMenu->addAction( "Bonds...", this, SLOT(launchBonds()) ); m_spinsAction = elements->addAction( "Spins...", this, SLOT(launchSpins()) ); m_liquidCrystalsAction = elements->addAction( "Liquid Crystals...", this, SLOT(launchLiquidCrystals()) ); m_polymersMenu = elements->addMenu( "Polymers..."); m_poresAction = elements->addAction( "Pores ...", this, SLOT(launchPores()) ); elements->addAction( "Lights...", this, SLOT(launchLights()) ); elements->addAction( "Annotation...", this, SLOT(launchAnnotation()) ); // fill submenu for polymer specifications m_polymersMenu->addAction( "Polymers...", this, SLOT(launchPolymers()) ); m_polymersMenu->addAction( "Bonds...", this, SLOT(launchBonds()) ); // fill a general settings menu m_showHideAxesAction = settings->addAction( "Hide Axes", this, SLOT(showHideAxesCB()) ); m_showHideContourAction = settings->addAction( "Hide Contour", this, SLOT(showHideContourCB()) ); m_onlyContourAction = settings->addAction( "Only Contour", this, SLOT(onlyContourCB()) ); // fill a general data menu data->addAction( "&Translate...", this, SLOT(launchTranslation()) ); data->addSeparator(); data->addAction( "Swap XY", this, SLOT(swapXY()) ); data->addAction( "Swap XZ", this, SLOT(swapXZ()) ); data->addAction( "Swap YZ", this, SLOT(swapYZ()) ); data->addSeparator(); data->addAction( "Mirror X", this, SLOT(mirrorX()) ); data->addAction( "Mirror Y", this, SLOT(mirrorY()) ); data->addAction( "Mirror Z", this, SLOT(mirrorZ()) ); data->addSeparator(); data->addAction( "Stretch XYZ...", this, SLOT(launchStretch()) ); // fill a general help menu help->addAction( "&About", this, SLOT(about()), Qt::CTRL+Qt::Key_H ); help->addAction( "License", this, SLOT(license()) ); help->addAction( "Distribution", this, SLOT(distribute()) ); // Now construct the main form // (Note having aviz as paramter for MainForm ctor // is "This is an ugly hack, intended to propagate the // address of the calling class") m_mainForm = new MainForm(this/*parent*/, this /*aviz*/); setCentralWidget(m_mainForm); // Construct a timer m_watchTimer = new QTimer(this); // Set initial settings setAtomMenus(); }
void StackTreeView::contextMenuEvent(QContextMenuEvent *ev) { DebuggerEngine *engine = currentEngine(); StackHandler *handler = engine->stackHandler(); const QModelIndex index = indexAt(ev->pos()); const int row = index.row(); StackFrame frame; if (row >= 0 && row < handler->stackSize()) frame = handler->frameAt(row); const quint64 address = frame.address; QMenu menu; menu.addAction(debuggerCore()->action(ExpandStack)); QAction *actCopyContents = menu.addAction(tr("Copy Contents to Clipboard")); actCopyContents->setEnabled(model() != 0); QAction *actSaveTaskFile = menu.addAction(tr("Save as Task File...")); actSaveTaskFile->setEnabled(model() != 0); if (engine->hasCapability(CreateFullBacktraceCapability)) menu.addAction(debuggerCore()->action(CreateFullBacktrace)); QAction *additionalQmlStackAction = 0; if (engine->hasCapability(AdditionalQmlStackCapability)) additionalQmlStackAction = menu.addAction(tr("Load QML Stack")); QAction *actShowMemory = 0; if (engine->hasCapability(ShowMemoryCapability)) { actShowMemory = menu.addAction(QString()); if (address == 0) { actShowMemory->setText(tr("Open Memory Editor")); actShowMemory->setEnabled(false); } else { actShowMemory->setText(tr("Open Memory Editor at 0x%1").arg(address, 0, 16)); actShowMemory->setEnabled(engine->hasCapability(ShowMemoryCapability)); } } QAction *actShowDisassemblerAt = 0; QAction *actShowDisassemblerAtAddress = 0; QAction *actShowDisassemblerAtFunction = 0; if (engine->hasCapability(DisassemblerCapability)) { actShowDisassemblerAt = menu.addAction(QString()); actShowDisassemblerAtAddress = menu.addAction(tr("Open Disassembler at Address...")); actShowDisassemblerAtFunction = menu.addAction(tr("Disassemble Function...")); if (address == 0) { actShowDisassemblerAt->setText(tr("Open Disassembler")); actShowDisassemblerAt->setEnabled(false); } else { actShowDisassemblerAt->setText(tr("Open Disassembler at 0x%1").arg(address, 0, 16)); } } QAction *actLoadSymbols = 0; if (engine->hasCapability(ShowModuleSymbolsCapability)) actLoadSymbols = menu.addAction(tr("Try to Load Unknown Symbols")); #if 0 // @TODO: not implemented menu.addAction(debuggerCore()->action(UseToolTipsInStackView)); #endif if (engine->hasCapability(MemoryAddressCapability)) menu.addAction(debuggerCore()->action(UseAddressInStackView)); menu.addSeparator(); menu.addAction(debuggerCore()->action(UseToolTipsInStackView)); menu.addSeparator(); addBaseContextActions(&menu); QAction *act = menu.exec(ev->globalPos()); if (!act) return; if (act == actCopyContents) { copyContentsToClipboard(); } else if (act == actShowMemory) { const QString title = tr("Memory at Frame #%1 (%2) 0x%3"). arg(row).arg(frame.function).arg(address, 0, 16); QList<MemoryMarkup> ml; ml.push_back(MemoryMarkup(address, 1, QColor(Qt::blue).lighter(), tr("Frame #%1 (%2)").arg(row).arg(frame.function))); engine->openMemoryView(address, 0, ml, QPoint(), title); } else if (act == actShowDisassemblerAtAddress) { AddressDialog dialog; if (address) dialog.setAddress(address); if (dialog.exec() == QDialog::Accepted) currentEngine()->openDisassemblerView(Location(dialog.address())); } else if (act == actShowDisassemblerAtFunction) { const StackFrame frame = inputFunctionForDisassembly(); if (!frame.function.isEmpty()) currentEngine()->openDisassemblerView(Location(frame)); } else if (act == actShowDisassemblerAt) engine->openDisassemblerView(frame); else if (act == actLoadSymbols) engine->loadSymbolsForStack(); else if (act == actSaveTaskFile) saveTaskFile(this, handler); else if (act == additionalQmlStackAction) engine->loadAdditionalQmlStack(); else handleBaseContextAction(act); }
LuaEditor::LuaEditor() { filename.clear(); updating = true; code = new QTextEdit; output = new QTextEdit; output->setReadOnly(true); code->setFontFamily("Monospace"); output->setFontFamily("Monospace"); setStatusBar(new QStatusBar); code->setWordWrapMode(QTextOption::NoWrap); code->setTabStopWidth(23); output->setWordWrapMode(QTextOption::NoWrap); QPalette pal; pal.setColor(QPalette::Active, QPalette::Base, Qt::black); pal.setColor(QPalette::Active, QPalette::Text, Qt::gray); output->setPalette(pal); new LuaSyntaxHighlighter(code); setCentralWidget(new QWidget); centralWidget()->setLayout( new QVBoxLayout ); QTabWidget *tabs = new QTabWidget; centralWidget()->layout()->addWidget(tabs); QWidget *codeTab = new QWidget; QVBoxLayout *curLayout = new QVBoxLayout; codeTab->setLayout( curLayout ); curLayout->addWidget(code); QMenu *mnuFile = new QMenu(tr("&File")); mnuFile->addAction(QIcon("icons/new.png"), tr("&new"), this, SLOT(loadTemplate()),QKeySequence(Qt::CTRL + Qt::Key_N)); mnuFile->addAction(QIcon("icons/open.png"), tr("&open"), this, SLOT(loadProgram()),QKeySequence(Qt::CTRL + Qt::Key_O)); mnuFile->addAction(QIcon("icons/save.png"), tr("&save"), this, SLOT(quickSave()),QKeySequence(Qt::CTRL + Qt::Key_S)); mnuFile->addAction(QIcon("icons/save.png"), tr("&save as"), this, SLOT(saveProgram())); mnuFile->addSeparator(); mnuFile->addAction(QIcon("icons/exit.png"), tr("&close"), this, SLOT(close()),QKeySequence(Qt::CTRL + Qt::Key_W)); setMenuBar(new QMenuBar); menuBar()->addMenu(mnuFile); tabs->addTab( codeTab, tr("&Code")); QWidget *outputTab = new QWidget; curLayout = new QVBoxLayout; outputTab->setLayout( curLayout ); curLayout->addWidget(output); commandInput = new QLineEdit; curLayout->addWidget(commandInput); QWidget *bottom = new QWidget; curLayout->addWidget(bottom); QHBoxLayout *bottomLayout = new QHBoxLayout(bottom); QPushButton *bOutput = new QPushButton(tr("&Build")); bOutput->setMaximumWidth(100); bottomLayout->addWidget(bOutput); bRun = new QPushButton(tr("&Start")); bRun->setMaximumWidth(100); bRun->setCheckable(true); bottomLayout->addWidget(bRun); QPushButton *bStep = new QPushButton(tr("&Step")); bStep->setMaximumWidth(100); bottomLayout->addWidget(bStep); tabs->addTab( outputTab, tr("&Console")); updateWindowTitle(); resize(600, height()); connect(commandInput, SIGNAL(returnPressed()), this, SLOT(runLuaCommand())); connect(bOutput, SIGNAL(clicked()), this, SLOT(compileCode())); connect(bRun, SIGNAL(toggled(bool)), this, SLOT(toggleTimer(bool))); connect(bStep, SIGNAL(clicked()), this, SLOT(runLuaCode())); luaTimer.setInterval(1000 / 30); // Run at game speed 30 ticks/sec luaTimer.setSingleShot(false); connect(&luaTimer, SIGNAL(timeout()), this, SLOT(runLuaCode())); updating = false; stream.setString(&logs, QIODevice::WriteOnly); }
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() { // very bad hack... berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = qobject_cast<QMainWindow*> (window->GetShell()->GetControl()); if (!windowIcon.isEmpty()) { mainWindow->setWindowIcon(QIcon(windowIcon)); } mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); /*mainWindow->setStyleSheet("color: white;" "background-color: #808080;" "selection-color: #659EC7;" "selection-background-color: #808080;" " QMenuBar {" "background-color: #808080; }");*/ // Load selected icon theme QStringList searchPaths = QIcon::themeSearchPaths(); searchPaths.push_front( QString(":/org_mitk_icons/icons/") ); QIcon::setThemeSearchPaths( searchPaths ); berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE); QString iconTheme = stylePref->Get(berry::QtPreferences::QT_ICON_THEME, "<<default>>"); if( iconTheme == QString( "<<default>>" ) ) { iconTheme = QString( "tango" ); } QIcon::setThemeName( iconTheme ); // ==== Application menu ============================ QMenuBar* menuBar = mainWindow->menuBar(); menuBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ menuBar->setNativeMenuBar(true); #else menuBar->setNativeMenuBar(false); #endif QAction* fileOpenAction = new QmitkFileOpenAction(QIcon::fromTheme("document-open",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-open.svg")), window); fileOpenAction->setShortcut(QKeySequence::Open); QAction* fileSaveAction = new QmitkFileSaveAction(QIcon(":/org.mitk.gui.qt.ext/Save_48.png"), window); fileSaveAction->setShortcut(QKeySequence::Save); fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); fileSaveProjectAction->setIcon(QIcon::fromTheme("document-save",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-save.svg"))); closeProjectAction = new QmitkCloseProjectAction(window); closeProjectAction->setIcon(QIcon::fromTheme("edit-delete",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-delete.svg"))); auto perspGroup = new QActionGroup(menuBar); std::map<QString, berry::IViewDescriptor::Pointer> VDMap; // sort elements (converting vector to map...) QList<berry::IViewDescriptor::Pointer>::const_iterator iter; berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); const QList<berry::IViewDescriptor::Pointer> viewDescriptors = viewRegistry->GetViews(); bool skip = false; for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) { // if viewExcludeList is set, it contains the id-strings of view, which // should not appear as an menu-entry in the menu if (viewExcludeList.size() > 0) { for (int i=0; i<viewExcludeList.size(); i++) { if (viewExcludeList.at(i) == (*iter)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") continue; if ((*iter)->GetId() == "org.mitk.views.imagenavigator") continue; if ((*iter)->GetId() == "org.mitk.views.viewnavigatorview") continue; std::pair<QString, berry::IViewDescriptor::Pointer> p( (*iter)->GetLabel(), (*iter)); VDMap.insert(p); } std::map<QString, berry::IViewDescriptor::Pointer>::const_iterator MapIter; for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) { berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); viewActions.push_back(viewAction); } if (!USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS) { QMenu* fileMenu = menuBar->addMenu("&File"); fileMenu->setObjectName("FileMenu"); fileMenu->addAction(fileOpenAction); fileMenu->addAction(fileSaveAction); fileMenu->addAction(fileSaveProjectAction); fileMenu->addAction(closeProjectAction); fileMenu->addSeparator(); QAction* fileExitAction = new QmitkFileExitAction(window); fileExitAction->setIcon(QIcon::fromTheme("system-log-out",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/system-log-out.svg"))); fileExitAction->setShortcut(QKeySequence::Quit); fileExitAction->setObjectName("QmitkFileExitAction"); fileMenu->addAction(fileExitAction); // another bad hack to get an edit/undo menu... QMenu* editMenu = menuBar->addMenu("&Edit"); undoAction = editMenu->addAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), "&Undo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), QKeySequence("CTRL+Z")); undoAction->setToolTip("Undo the last action (not supported by all modules)"); redoAction = editMenu->addAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg")) , "&Redo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), QKeySequence("CTRL+Y")); redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); // ==== Window Menu ========================== QMenu* windowMenu = menuBar->addMenu("Window"); if (showNewWindowMenuItem) { windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); windowMenu->addSeparator(); } QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); QMenu* viewMenu; if (showViewMenuItem) { viewMenu = windowMenu->addMenu("Show &View"); viewMenu->setObjectName("Show View"); } windowMenu->addSeparator(); resetPerspAction = windowMenu->addAction("&Reset Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); if(showClosePerspectiveMenuItem) closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); windowMenu->addSeparator(); windowMenu->addAction("&Preferences...", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), QKeySequence("CTRL+P")); // fill perspective menu berry::IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry(); QList<berry::IPerspectiveDescriptor::Pointer> perspectives( perspRegistry->GetPerspectives()); skip = false; for (QList<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt = perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu if (perspectiveExcludeList.size() > 0) { for (int i=0; i<perspectiveExcludeList.size(); i++) { if (perspectiveExcludeList.at(i) == (*perspIt)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } QAction* perspAction = new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup); mapPerspIdToAction.insert((*perspIt)->GetId(), perspAction); } perspMenu->addActions(perspGroup->actions()); if (showViewMenuItem) { for (auto viewAction : viewActions) { viewMenu->addAction(viewAction); } } // ===== Help menu ==================================== QMenu* helpMenu = menuBar->addMenu("&Help"); helpMenu->addAction("&Welcome",this, SLOT(onIntro())); helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective())); helpMenu->addAction("&Context Help",this, SLOT(onHelp()), QKeySequence("F1")); helpMenu->addAction("&About",this, SLOT(onAbout())); // ===================================================== } else { //undoAction = new QAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), // "&Undo", nullptr); undoAction = new QmitkUndoAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), nullptr); undoAction->setShortcut(QKeySequence::Undo); redoAction = new QmitkRedoAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg")), nullptr); redoAction->setShortcut(QKeySequence::Redo); } // toolbar for showing file open, undo, redo and other main actions auto mainActionsToolBar = new QToolBar; mainActionsToolBar->setObjectName("mainActionsToolBar"); mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); #else mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); #endif imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", nullptr); bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) { openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window); } if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) { openXnatEditorAction = new QmitkOpenXnatEditorAction(QIcon(":/org.mitk.gui.qt.ext/xnat-icon.png"),window); } if (imageNavigatorViewFound) { QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); imageNavigatorAction->setCheckable(true); // add part listener for image navigator imageNavigatorPartListener.reset(new PartListenerForImageNavigator(imageNavigatorAction)); window->GetPartService()->AddPartListener(imageNavigatorPartListener.data()); berry::IViewPart::Pointer imageNavigatorView = window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); imageNavigatorAction->setChecked(false); if (imageNavigatorView) { bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) imageNavigatorAction->setChecked(true); } imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image"); } viewNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/view-manager_48.png"),"&View Navigator", nullptr); viewNavigatorFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.viewnavigatorview"); if (viewNavigatorFound) { QObject::connect(viewNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onViewNavigator())); viewNavigatorAction->setCheckable(true); // add part listener for view navigator viewNavigatorPartListener.reset(new PartListenerForViewNavigator(viewNavigatorAction)); window->GetPartService()->AddPartListener(viewNavigatorPartListener.data()); berry::IViewPart::Pointer viewnavigatorview = window->GetActivePage()->FindView("org.mitk.views.viewnavigatorview"); viewNavigatorAction->setChecked(false); if (viewnavigatorview) { bool isViewNavigatorVisible = window->GetActivePage()->IsPartVisible(viewnavigatorview); if (isViewNavigatorVisible) viewNavigatorAction->setChecked(true); } viewNavigatorAction->setToolTip("Toggle View Navigator"); } mainActionsToolBar->addAction(fileOpenAction); mainActionsToolBar->addAction(fileSaveProjectAction); mainActionsToolBar->addAction(closeProjectAction); mainActionsToolBar->addAction(undoAction); mainActionsToolBar->addAction(redoAction); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) { mainActionsToolBar->addAction(openDicomEditorAction); } if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) { mainActionsToolBar->addAction(openXnatEditorAction); } if (imageNavigatorViewFound) { mainActionsToolBar->addAction(imageNavigatorAction); } if (viewNavigatorFound) { mainActionsToolBar->addAction(viewNavigatorAction); } mainWindow->addToolBar(mainActionsToolBar); // ==== Perspective Toolbar ================================== auto qPerspectiveToolbar = new QToolBar; qPerspectiveToolbar->setObjectName("perspectiveToolBar"); if (showPerspectiveToolbar) { qPerspectiveToolbar->addActions(perspGroup->actions()); mainWindow->addToolBar(qPerspectiveToolbar); } else delete qPerspectiveToolbar; // ==== View Toolbar ================================== auto qToolbar = new QToolBar; qToolbar->setObjectName("viewToolBar"); if (showViewToolbar) { mainWindow->addToolBar(qToolbar); for (auto viewAction : viewActions) { qToolbar->addAction(viewAction); } } else delete qToolbar; QSettings settings(GetQSettingsFile(), QSettings::IniFormat); mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); auto qStatusBar = new QStatusBar(); //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar auto statusBar = new QmitkStatusBar(qStatusBar); //disabling the SizeGrip in the lower right corner statusBar->SetSizeGripEnabled(false); auto progBar = new QmitkProgressBar(); qStatusBar->addPermanentWidget(progBar, 0); progBar->hide(); // progBar->AddStepsToDo(2); // progBar->Progress(1); mainWindow->setStatusBar(qStatusBar); if (showMemoryIndicator) { auto memoryIndicator = new QmitkMemoryUsageIndicatorView(); qStatusBar->addPermanentWidget(memoryIndicator, 0); } }
void Peers::context_menu(const QPoint &pos) { QMenu *menu = new QMenu; if (menu == NULL) return; QModelIndex idx = peers->indexAt(pos); if (idx.isValid()) { ctx_item = model.itemFromIndex(idx); int type = ctx_item->data(peer_role_type).toInt(); menu->addAction(Peers::ItemType(type))->setEnabled(false); menu->addSeparator(); int config_methods = -1; QVariant var = ctx_item->data(peer_role_config_methods); if (var.isValid()) config_methods = var.toInt(); enum selected_method method = SEL_METHOD_NONE; var = ctx_item->data(peer_role_selected_method); if (var.isValid()) method = (enum selected_method) var.toInt(); if ((type == PEER_TYPE_ASSOCIATED_STATION || type == PEER_TYPE_AP_WPS || type == PEER_TYPE_WPS_PIN_NEEDED || type == PEER_TYPE_WPS_ER_ENROLLEE || type == PEER_TYPE_WPS_ENROLLEE) && (config_methods == -1 || (config_methods & 0x010c))) { menu->addAction(tr("Enter WPS PIN"), this, SLOT(enter_pin())); } if (type == PEER_TYPE_P2P || type == PEER_TYPE_P2P_CLIENT) { menu->addAction(tr("P2P Connect"), this, SLOT(ctx_p2p_connect())); if (method == SEL_METHOD_NONE && config_methods > -1 && config_methods & 0x0080 /* PBC */ && config_methods != 0x0080) menu->addAction(tr("P2P Connect (PBC)"), this, SLOT(connect_pbc())); if (method == SEL_METHOD_NONE) { menu->addAction(tr("P2P Request PIN"), this, SLOT(ctx_p2p_req_pin())); menu->addAction(tr("P2P Show PIN"), this, SLOT(ctx_p2p_show_pin())); } if (config_methods > -1 && (config_methods & 0x0100)) { /* Peer has Keypad */ menu->addAction(tr("P2P Display PIN"), this, SLOT(ctx_p2p_display_pin())); } if (config_methods > -1 && (config_methods & 0x000c)) { /* Peer has Label or Display */ menu->addAction(tr("P2P Enter PIN"), this, SLOT(ctx_p2p_enter_pin())); } } if (type == PEER_TYPE_P2P_GROUP) { menu->addAction(tr("Show passphrase"), this, SLOT(ctx_p2p_show_passphrase())); menu->addAction(tr("Remove P2P Group"), this, SLOT(ctx_p2p_remove_group())); } if (type == PEER_TYPE_P2P_PERSISTENT_GROUP_GO || type == PEER_TYPE_P2P_PERSISTENT_GROUP_CLIENT || type == PEER_TYPE_P2P_INVITATION) { menu->addAction(tr("Start group"), this, SLOT(ctx_p2p_start_persistent())); } if (type == PEER_TYPE_P2P_PERSISTENT_GROUP_GO || type == PEER_TYPE_P2P_PERSISTENT_GROUP_CLIENT) { menu->addAction(tr("Invite"), this, SLOT(ctx_p2p_invite())); } if (type == PEER_TYPE_P2P_INVITATION) { menu->addAction(tr("Ignore"), this, SLOT(ctx_p2p_delete())); } if (type == PEER_TYPE_AP_WPS) { menu->addAction(tr("Connect (PBC)"), this, SLOT(connect_pbc())); } if ((type == PEER_TYPE_ASSOCIATED_STATION || type == PEER_TYPE_WPS_ER_ENROLLEE || type == PEER_TYPE_WPS_ENROLLEE) && config_methods >= 0 && (config_methods & 0x0080)) { menu->addAction(tr("Enroll (PBC)"), this, SLOT(connect_pbc())); } if (type == PEER_TYPE_WPS_ER_AP) { menu->addAction(tr("Learn Configuration"), this, SLOT(learn_ap_config())); } menu->addAction(tr("Properties"), this, SLOT(properties())); } else { ctx_item = NULL; menu->addAction(QString(tr("Refresh")), this, SLOT(ctx_refresh())); menu->addAction(tr("Start P2P discovery"), this, SLOT(ctx_p2p_start())); menu->addAction(tr("Stop P2P discovery"), this, SLOT(ctx_p2p_stop())); menu->addAction(tr("P2P listen only"), this, SLOT(ctx_p2p_listen())); menu->addAction(tr("Start P2P group"), this, SLOT(ctx_p2p_start_group())); if (hide_ap) menu->addAction(tr("Show AP entries"), this, SLOT(ctx_show_ap())); else menu->addAction(tr("Hide AP entries"), this, SLOT(ctx_hide_ap())); } menu->exec(peers->mapToGlobal(pos)); }
QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() { QMenu *menu = new QMenu; QgsLayerTreeViewDefaultActions *actions = mView->defaultActions(); QModelIndex idx = mView->currentIndex(); if ( !idx.isValid() ) { // global menu menu->addAction( actions->actionAddGroup( menu ) ); menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionExpandTree.svg" ) ), tr( "&Expand All" ), mView, SLOT( expandAll() ) ); menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionCollapseTree.svg" ) ), tr( "&Collapse All" ), mView, SLOT( collapseAll() ) ); menu->addSeparator(); if ( QgisApp::instance()->clipboard()->hasFormat( QGSCLIPBOARD_MAPLAYER_MIME ) ) { QAction *actionPasteLayerOrGroup = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionEditPaste.svg" ) ), tr( "Paste Layer/Group" ), menu ); connect( actionPasteLayerOrGroup, &QAction::triggered, QgisApp::instance(), &QgisApp::pasteLayer ); menu->addAction( actionPasteLayerOrGroup ); } // TODO: update drawing order } else if ( QgsLayerTreeNode *node = mView->layerTreeModel()->index2node( idx ) ) { // layer or group selected if ( QgsLayerTree::isGroup( node ) ) { menu->addAction( actions->actionZoomToGroup( mCanvas, menu ) ); menu->addAction( tr( "Copy Group" ), QgisApp::instance(), SLOT( copyLayer() ) ); if ( QgisApp::instance()->clipboard()->hasFormat( QGSCLIPBOARD_MAPLAYER_MIME ) ) { QAction *actionPasteLayerOrGroup = new QAction( tr( "Paste Layer/Group" ), menu ); connect( actionPasteLayerOrGroup, &QAction::triggered, QgisApp::instance(), &QgisApp::pasteLayer ); menu->addAction( actionPasteLayerOrGroup ); } menu->addAction( actions->actionRenameGroupOrLayer( menu ) ); menu->addSeparator(); menu->addAction( actions->actionAddGroup( menu ) ); QAction *removeAction = menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionRemoveLayer.svg" ) ), tr( "&Remove Group…" ), QgisApp::instance(), SLOT( removeLayer() ) ); removeAction->setEnabled( removeActionEnabled() ); menu->addSeparator(); menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSetCRS.png" ) ), tr( "&Set Group CRS…" ), QgisApp::instance(), SLOT( legendGroupSetCrs() ) ); menu->addAction( tr( "&Set Group WMS Data…" ), QgisApp::instance(), SLOT( legendGroupSetWmsData() ) ); menu->addSeparator(); menu->addAction( actions->actionMutuallyExclusiveGroup( menu ) ); menu->addAction( actions->actionCheckAndAllChildren( menu ) ); menu->addAction( actions->actionUncheckAndAllChildren( menu ) ); if ( !( mView->selectedNodes( true ).count() == 1 && idx.row() == 0 ) ) { menu->addAction( actions->actionMoveToTop( menu ) ); } menu->addSeparator(); if ( mView->selectedNodes( true ).count() >= 2 ) menu->addAction( actions->actionGroupSelected( menu ) ); if ( QgisApp::instance()->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) ) { menu->addAction( tr( "Paste Style" ), QgisApp::instance(), SLOT( applyStyleToGroup() ) ); } menu->addSeparator(); QMenu *menuExportGroup = new QMenu( tr( "Export" ), menu ); QAction *actionSaveAsDefinitionGroup = new QAction( tr( "Save as Layer Definition File…" ), menuExportGroup ); connect( actionSaveAsDefinitionGroup, &QAction::triggered, QgisApp::instance(), &QgisApp::saveAsLayerDefinition ); menuExportGroup->addAction( actionSaveAsDefinitionGroup ); menu->addMenu( menuExportGroup ); } else if ( QgsLayerTree::isLayer( node ) ) { QgsMapLayer *layer = QgsLayerTree::toLayer( node )->layer(); QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer ); QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer ); if ( layer && layer->isSpatial() ) { menu->addAction( actions->actionZoomToLayer( mCanvas, menu ) ); if ( vlayer ) { QAction *actionZoomSelected = actions->actionZoomToSelection( mCanvas, menu ); actionZoomSelected->setEnabled( !vlayer->selectedFeatures().isEmpty() ); menu->addAction( actionZoomSelected ); } menu->addAction( actions->actionShowInOverview( menu ) ); } if ( vlayer ) menu->addAction( actions->actionShowFeatureCount( menu ) ); QAction *actionCopyLayer = new QAction( tr( "Copy Layer" ), menu ); connect( actionCopyLayer, &QAction::triggered, QgisApp::instance(), &QgisApp::copyLayer ); menu->addAction( actionCopyLayer ); menu->addAction( actions->actionRenameGroupOrLayer( menu ) ); if ( rlayer ) { menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomActual.svg" ) ), tr( "&Zoom to Native Resolution (100%)" ), QgisApp::instance(), SLOT( legendLayerZoomNative() ) ); if ( rlayer->rasterType() != QgsRasterLayer::Palette ) menu->addAction( tr( "&Stretch Using Current Extent" ), QgisApp::instance(), SLOT( legendLayerStretchUsingCurrentExtent() ) ); } addCustomLayerActions( menu, layer ); if ( layer && layer->type() == QgsMapLayer::VectorLayer && static_cast<QgsVectorLayer *>( layer )->providerType() == QLatin1String( "virtual" ) ) { menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddVirtualLayer.svg" ) ), tr( "Edit Virtual Layer…" ), QgisApp::instance(), SLOT( addVirtualLayer() ) ); } menu->addSeparator(); // duplicate layer QAction *duplicateLayersAction = menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateLayer.svg" ) ), tr( "&Duplicate Layer" ), QgisApp::instance(), SLOT( duplicateLayers() ) ); QAction *removeAction = menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionRemoveLayer.svg" ) ), tr( "&Remove Layer…" ), QgisApp::instance(), SLOT( removeLayer() ) ); removeAction->setEnabled( removeActionEnabled() ); menu->addSeparator(); if ( node->parent() != mView->layerTreeModel()->rootGroup() ) menu->addAction( actions->actionMoveOutOfGroup( menu ) ); if ( !( mView->selectedNodes( true ).count() == 1 && idx.row() == 0 ) ) { menu->addAction( actions->actionMoveToTop( menu ) ); } QAction *checkAll = actions->actionCheckAndAllParents( menu ); if ( checkAll ) menu->addAction( checkAll ); if ( mView->selectedNodes( true ).count() >= 2 ) menu->addAction( actions->actionGroupSelected( menu ) ); menu->addSeparator(); if ( vlayer ) { QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing(); QAction *saveLayerEditsAction = QgisApp::instance()->actionSaveActiveLayerEdits(); QAction *allEditsAction = QgisApp::instance()->actionAllEdits(); // attribute table menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOpenTable.svg" ) ), tr( "&Open Attribute Table" ), QgisApp::instance(), SLOT( attributeTable() ) ); // allow editing int cap = vlayer->dataProvider()->capabilities(); if ( cap & QgsVectorDataProvider::EditingCapabilities ) { if ( toggleEditingAction ) { menu->addAction( toggleEditingAction ); toggleEditingAction->setChecked( vlayer->isEditable() ); toggleEditingAction->setEnabled( true ); } if ( saveLayerEditsAction && vlayer->isModified() ) { menu->addAction( saveLayerEditsAction ); } } if ( allEditsAction->isEnabled() ) menu->addAction( allEditsAction ); // disable duplication of memory layers if ( vlayer->storageType() == QLatin1String( "Memory storage" ) && mView->selectedLayerNodes().count() == 1 ) duplicateLayersAction->setEnabled( false ); if ( vlayer->dataProvider()->supportsSubsetString() ) { QAction *action = menu->addAction( tr( "&Filter…" ), QgisApp::instance(), SLOT( layerSubsetString() ) ); action->setEnabled( !vlayer->isEditable() ); } } menu->addSeparator(); if ( layer && layer->isSpatial() ) { // set layer scale visibility menu->addAction( tr( "&Set Layer Scale Visibility…" ), QgisApp::instance(), SLOT( setLayerScaleVisibility() ) ); if ( !layer->isInScaleRange( mCanvas->scale() ) ) menu->addAction( tr( "Zoom to &Visible Scale" ), QgisApp::instance(), SLOT( zoomToLayerScale() ) ); QMenu *menuSetCRS = new QMenu( tr( "Set CRS" ), menu ); // set layer crs QAction *actionSetLayerCrs = new QAction( tr( "Set Layer CRS…" ), menuSetCRS ); connect( actionSetLayerCrs, &QAction::triggered, QgisApp::instance(), &QgisApp::setLayerCrs ); menuSetCRS->addAction( actionSetLayerCrs ); // assign layer crs to project QAction *actionSetProjectCrs = new QAction( tr( "Set &Project CRS from Layer" ), menuSetCRS ); connect( actionSetProjectCrs, &QAction::triggered, QgisApp::instance(), &QgisApp::setProjectCrsFromLayer ); menuSetCRS->addAction( actionSetProjectCrs ); menu->addMenu( menuSetCRS ); } menu->addSeparator(); if ( vlayer ) { // save as vector file QMenu *menuExportVector = new QMenu( tr( "Export" ), menu ); QAction *actionSaveAs = new QAction( tr( "Save Features As…" ), menuExportVector ); connect( actionSaveAs, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveAsFile(); } ); menuExportVector->addAction( actionSaveAs ); QAction *actionSaveSelectedFeaturesAs = new QAction( tr( "Save Selected Features As…" ), menuExportVector ); connect( actionSaveSelectedFeaturesAs, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveAsFile( nullptr, true ); } ); actionSaveSelectedFeaturesAs->setEnabled( vlayer->selectedFeatureCount() > 0 ); menuExportVector->addAction( actionSaveSelectedFeaturesAs ); QAction *actionSaveAsDefinitionLayer = new QAction( tr( "Save as Layer Definition File…" ), menuExportVector ); connect( actionSaveAsDefinitionLayer, &QAction::triggered, QgisApp::instance(), &QgisApp::saveAsLayerDefinition ); menuExportVector->addAction( actionSaveAsDefinitionLayer ); if ( vlayer->isSpatial() ) { QAction *actionSaveStyle = new QAction( tr( "Save as QGIS Layer Style File…" ), menuExportVector ); connect( actionSaveStyle, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveStyleFile(); } ); menuExportVector->addAction( actionSaveStyle ); } menu->addMenu( menuExportVector ); } else if ( rlayer ) { QMenu *menuExportRaster = new QMenu( tr( "Export" ), menu ); QAction *actionSaveAs = new QAction( tr( "Save As…" ), menuExportRaster ); QAction *actionSaveAsDefinitionLayer = new QAction( tr( "Save as Layer Definition File…" ), menuExportRaster ); QAction *actionSaveStyle = new QAction( tr( "Save as QGIS Layer Style File…" ), menuExportRaster ); connect( actionSaveAs, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveAsFile(); } ); menuExportRaster->addAction( actionSaveAs ); connect( actionSaveAsDefinitionLayer, &QAction::triggered, QgisApp::instance(), &QgisApp::saveAsLayerDefinition ); menuExportRaster->addAction( actionSaveAsDefinitionLayer ); connect( actionSaveStyle, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveStyleFile(); } ); menuExportRaster->addAction( actionSaveStyle ); menu->addMenu( menuExportRaster ); } else if ( layer && layer->type() == QgsMapLayer::PluginLayer && mView->selectedLayerNodes().count() == 1 ) { // disable duplication of plugin layers duplicateLayersAction->setEnabled( false ); } menu->addSeparator(); // style-related actions if ( layer && mView->selectedLayerNodes().count() == 1 ) { menu->addSeparator(); QMenu *menuStyleManager = new QMenu( tr( "Styles" ), menu ); QgisApp *app = QgisApp::instance(); menuStyleManager->addAction( tr( "Copy Style" ), app, SLOT( copyStyle() ) ); if ( app->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) ) { menuStyleManager->addAction( tr( "Paste Style" ), app, SLOT( pasteStyle() ) ); } menuStyleManager->addSeparator(); QgsMapLayerStyleGuiUtils::instance()->addStyleManagerActions( menuStyleManager, layer ); if ( vlayer ) { const QgsSingleSymbolRenderer *singleRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( vlayer->renderer() ); if ( !singleRenderer && vlayer->renderer() && vlayer->renderer()->embeddedRenderer() ) { singleRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( vlayer->renderer()->embeddedRenderer() ); } if ( singleRenderer && singleRenderer->symbol() ) { //single symbol renderer, so add set color/edit symbol actions menuStyleManager->addSeparator(); QgsColorWheel *colorWheel = new QgsColorWheel( menuStyleManager ); colorWheel->setColor( singleRenderer->symbol()->color() ); QgsColorWidgetAction *colorAction = new QgsColorWidgetAction( colorWheel, menuStyleManager, menuStyleManager ); colorAction->setDismissOnColorSelection( false ); connect( colorAction, &QgsColorWidgetAction::colorChanged, this, &QgsAppLayerTreeViewMenuProvider::setVectorSymbolColor ); //store the layer id in action, so we can later retrieve the corresponding layer colorAction->setProperty( "layerId", vlayer->id() ); menuStyleManager->addAction( colorAction ); //add recent colors action QList<QgsRecentColorScheme *> recentSchemes; QgsApplication::colorSchemeRegistry()->schemes( recentSchemes ); if ( !recentSchemes.isEmpty() ) { QgsColorSwatchGridAction *recentColorAction = new QgsColorSwatchGridAction( recentSchemes.at( 0 ), menuStyleManager, QStringLiteral( "symbology" ), menuStyleManager ); recentColorAction->setProperty( "layerId", vlayer->id() ); recentColorAction->setDismissOnColorSelection( false ); menuStyleManager->addAction( recentColorAction ); connect( recentColorAction, &QgsColorSwatchGridAction::colorChanged, this, &QgsAppLayerTreeViewMenuProvider::setVectorSymbolColor ); } menuStyleManager->addSeparator(); QAction *editSymbolAction = new QAction( tr( "Edit Symbol…" ), menuStyleManager ); //store the layer id in action, so we can later retrieve the corresponding layer editSymbolAction->setProperty( "layerId", vlayer->id() ); connect( editSymbolAction, &QAction::triggered, this, &QgsAppLayerTreeViewMenuProvider::editVectorSymbol ); menuStyleManager->addAction( editSymbolAction ); } } menu->addMenu( menuStyleManager ); } else { if ( QgisApp::instance()->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) ) { menu->addAction( tr( "Paste Style" ), QgisApp::instance(), SLOT( applyStyleToGroup() ) ); } } if ( layer && QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() ) menu->addAction( tr( "&Properties…" ), QgisApp::instance(), SLOT( layerProperties() ) ); } } else if ( QgsLayerTreeModelLegendNode *node = mView->layerTreeModel()->index2legendNode( idx ) ) { if ( QgsSymbolLegendNode *symbolNode = dynamic_cast< QgsSymbolLegendNode * >( node ) ) { // symbology item if ( symbolNode->flags() & Qt::ItemIsUserCheckable ) { menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowAllLayers.svg" ) ), tr( "&Show All Items" ), symbolNode, SLOT( checkAllItems() ) ); menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionHideAllLayers.svg" ) ), tr( "&Hide All Items" ), symbolNode, SLOT( uncheckAllItems() ) ); menu->addSeparator(); } if ( symbolNode->symbol() ) { QgsColorWheel *colorWheel = new QgsColorWheel( menu ); colorWheel->setColor( symbolNode->symbol()->color() ); QgsColorWidgetAction *colorAction = new QgsColorWidgetAction( colorWheel, menu, menu ); colorAction->setDismissOnColorSelection( false ); connect( colorAction, &QgsColorWidgetAction::colorChanged, this, &QgsAppLayerTreeViewMenuProvider::setSymbolLegendNodeColor ); //store the layer id and rule key in action, so we can later retrieve the corresponding //legend node, if it still exists colorAction->setProperty( "layerId", symbolNode->layerNode()->layerId() ); colorAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() ); menu->addAction( colorAction ); //add recent colors action QList<QgsRecentColorScheme *> recentSchemes; QgsApplication::colorSchemeRegistry()->schemes( recentSchemes ); if ( !recentSchemes.isEmpty() ) { QgsColorSwatchGridAction *recentColorAction = new QgsColorSwatchGridAction( recentSchemes.at( 0 ), menu, QStringLiteral( "symbology" ), menu ); recentColorAction->setProperty( "layerId", symbolNode->layerNode()->layerId() ); recentColorAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() ); recentColorAction->setDismissOnColorSelection( false ); menu->addAction( recentColorAction ); connect( recentColorAction, &QgsColorSwatchGridAction::colorChanged, this, &QgsAppLayerTreeViewMenuProvider::setSymbolLegendNodeColor ); } menu->addSeparator(); } QAction *editSymbolAction = new QAction( tr( "Edit Symbol…" ), menu ); //store the layer id and rule key in action, so we can later retrieve the corresponding //legend node, if it still exists editSymbolAction->setProperty( "layerId", symbolNode->layerNode()->layerId() ); editSymbolAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() ); connect( editSymbolAction, &QAction::triggered, this, &QgsAppLayerTreeViewMenuProvider::editSymbolLegendNodeSymbol ); menu->addAction( editSymbolAction ); } } return menu; }
MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) : WindowQt(machine, NULL) { setWindowTitle("Debug: Memory View"); if (parent != NULL) { QPoint parentPos = parent->pos(); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); } // // The main frame and its input and log widgets // QFrame* mainWindowFrame = new QFrame(this); // The top frame & groupbox that contains the input widgets QFrame* topSubFrame = new QFrame(mainWindowFrame); // The input edit m_inputEdit = new QLineEdit(topSubFrame); connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); // The memory space combo box m_memoryComboBox = new QComboBox(topSubFrame); m_memoryComboBox->setObjectName("memoryregion"); m_memoryComboBox->setMinimumWidth(300); connect(m_memoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(memoryRegionChanged(int))); // The main memory window m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this); // Layout QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); subLayout->addWidget(m_inputEdit); subLayout->addWidget(m_memoryComboBox); subLayout->setSpacing(3); subLayout->setContentsMargins(2,2,2,2); QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); vLayout->setSpacing(3); vLayout->setContentsMargins(2,2,2,2); vLayout->addWidget(topSubFrame); vLayout->addWidget(m_memTable); setCentralWidget(mainWindowFrame); // // Menu bars // // Create a data format group QActionGroup* dataFormat = new QActionGroup(this); dataFormat->setObjectName("dataformat"); QAction* formatActOne = new QAction("1-byte chunks", this); QAction* formatActTwo = new QAction("2-byte chunks", this); QAction* formatActFour = new QAction("4-byte chunks", this); QAction* formatActEight = new QAction("8-byte chunks", this); QAction* formatAct32bitFloat = new QAction("32 bit floating point", this); QAction* formatAct64bitFloat = new QAction("64 bit floating point", this); QAction* formatAct80bitFloat = new QAction("80 bit floating point", this); formatActOne->setObjectName("formatActOne"); formatActTwo->setObjectName("formatActTwo"); formatActFour->setObjectName("formatActFour"); formatActEight->setObjectName("formatActEight"); formatAct32bitFloat->setObjectName("formatAct32bitFloat"); formatAct64bitFloat->setObjectName("formatAct64bitFloat"); formatAct80bitFloat->setObjectName("formatAct80bitFloat"); formatActOne->setCheckable(true); formatActTwo->setCheckable(true); formatActFour->setCheckable(true); formatActEight->setCheckable(true); formatAct32bitFloat->setCheckable(true); formatAct64bitFloat->setCheckable(true); formatAct80bitFloat->setCheckable(true); formatActOne->setActionGroup(dataFormat); formatActTwo->setActionGroup(dataFormat); formatActFour->setActionGroup(dataFormat); formatActEight->setActionGroup(dataFormat); formatAct32bitFloat->setActionGroup(dataFormat); formatAct64bitFloat->setActionGroup(dataFormat); formatAct80bitFloat->setActionGroup(dataFormat); formatActOne->setShortcut(QKeySequence("Ctrl+1")); formatActTwo->setShortcut(QKeySequence("Ctrl+2")); formatActFour->setShortcut(QKeySequence("Ctrl+4")); formatActEight->setShortcut(QKeySequence("Ctrl+8")); formatAct32bitFloat->setShortcut(QKeySequence("Ctrl+9")); formatActOne->setChecked(true); connect(dataFormat, SIGNAL(triggered(QAction*)), this, SLOT(formatChanged(QAction*))); // Create a address display group QActionGroup* addressGroup = new QActionGroup(this); addressGroup->setObjectName("addressgroup"); QAction* addressActLogical = new QAction("Logical Addresses", this); QAction* addressActPhysical = new QAction("Physical Addresses", this); addressActLogical->setCheckable(true); addressActPhysical->setCheckable(true); addressActLogical->setActionGroup(addressGroup); addressActPhysical->setActionGroup(addressGroup); addressActLogical->setShortcut(QKeySequence("Ctrl+G")); addressActPhysical->setShortcut(QKeySequence("Ctrl+Y")); addressActLogical->setChecked(true); connect(addressGroup, SIGNAL(triggered(QAction*)), this, SLOT(addressChanged(QAction*))); // Create a reverse view radio QAction* reverseAct = new QAction("Reverse View", this); reverseAct->setObjectName("reverse"); reverseAct->setCheckable(true); reverseAct->setShortcut(QKeySequence("Ctrl+R")); connect(reverseAct, SIGNAL(toggled(bool)), this, SLOT(reverseChanged(bool))); // Create increase and decrease bytes-per-line actions QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this); QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this); increaseBplAct->setShortcut(QKeySequence("Ctrl+P")); decreaseBplAct->setShortcut(QKeySequence("Ctrl+O")); connect(increaseBplAct, SIGNAL(triggered(bool)), this, SLOT(increaseBytesPerLine(bool))); connect(decreaseBplAct, SIGNAL(triggered(bool)), this, SLOT(decreaseBytesPerLine(bool))); // Assemble the options menu QMenu* optionsMenu = menuBar()->addMenu("&Options"); optionsMenu->addActions(dataFormat->actions()); optionsMenu->addSeparator(); optionsMenu->addActions(addressGroup->actions()); optionsMenu->addSeparator(); optionsMenu->addAction(reverseAct); optionsMenu->addSeparator(); optionsMenu->addAction(increaseBplAct); optionsMenu->addAction(decreaseBplAct); // // Initialize // populateComboBox(); // Set to the current CPU's memory view setToCurrentCpu(); }
QgsComposer::QgsComposer( QgisApp *qgis, const QString& title ): QMainWindow(), mTitle( title ), mUndoView( 0 ) { setupUi( this ); setWindowTitle( mTitle ); setupTheme(); QObject::connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( close() ) ); QSettings settings; int size = settings.value( "/IconSize", 24 ).toInt(); setIconSize( QSize( size, size ) ); QToolButton* orderingToolButton = new QToolButton( this ); orderingToolButton->setPopupMode( QToolButton::InstantPopup ); orderingToolButton->setAutoRaise( true ); orderingToolButton->setToolButtonStyle( Qt::ToolButtonIconOnly ); orderingToolButton->addAction( mActionRaiseItems ); orderingToolButton->addAction( mActionLowerItems ); orderingToolButton->addAction( mActionMoveItemsToTop ); orderingToolButton->addAction( mActionMoveItemsToBottom ); orderingToolButton->setDefaultAction( mActionRaiseItems ); toolBar->addWidget( orderingToolButton ); QToolButton* alignToolButton = new QToolButton( this ); alignToolButton->setPopupMode( QToolButton::InstantPopup ); alignToolButton->setAutoRaise( true ); alignToolButton->setToolButtonStyle( Qt::ToolButtonIconOnly ); alignToolButton->addAction( mActionAlignLeft ); alignToolButton->addAction( mActionAlignHCenter ); alignToolButton->addAction( mActionAlignRight ); alignToolButton->addAction( mActionAlignTop ); alignToolButton->addAction( mActionAlignVCenter ); alignToolButton->addAction( mActionAlignBottom ); alignToolButton->setDefaultAction( mActionAlignLeft ); toolBar->addWidget( alignToolButton ); QActionGroup* toggleActionGroup = new QActionGroup( this ); toggleActionGroup->addAction( mActionMoveItemContent ); toggleActionGroup->addAction( mActionAddNewMap ); toggleActionGroup->addAction( mActionAddNewLabel ); toggleActionGroup->addAction( mActionAddNewLegend ); toggleActionGroup->addAction( mActionAddNewScalebar ); toggleActionGroup->addAction( mActionAddImage ); toggleActionGroup->addAction( mActionSelectMoveItem ); toggleActionGroup->addAction( mActionAddBasicShape ); toggleActionGroup->addAction( mActionAddArrow ); toggleActionGroup->addAction( mActionAddTable ); toggleActionGroup->setExclusive( true ); mActionAddNewMap->setCheckable( true ); mActionAddNewLabel->setCheckable( true ); mActionAddNewLegend->setCheckable( true ); mActionSelectMoveItem->setCheckable( true ); mActionAddNewScalebar->setCheckable( true ); mActionAddImage->setCheckable( true ); mActionMoveItemContent->setCheckable( true ); mActionAddBasicShape->setCheckable( true ); mActionAddArrow->setCheckable( true ); #ifdef Q_WS_MAC QMenu *appMenu = menuBar()->addMenu( tr( "QGIS" ) ); appMenu->addAction( QgisApp::instance()->actionAbout() ); appMenu->addAction( QgisApp::instance()->actionOptions() ); #endif QMenu *fileMenu = menuBar()->addMenu( tr( "File" ) ); fileMenu->addAction( mActionLoadFromTemplate ); fileMenu->addAction( mActionSaveAsTemplate ); fileMenu->addSeparator(); fileMenu->addAction( mActionExportAsImage ); fileMenu->addAction( mActionExportAsPDF ); fileMenu->addAction( mActionExportAsSVG ); fileMenu->addSeparator(); fileMenu->addAction( mActionPageSetup ); fileMenu->addAction( mActionPrint ); fileMenu->addSeparator(); fileMenu->addAction( mActionQuit ); QObject::connect( mActionQuit, SIGNAL( triggered() ), this, SLOT( close() ) ); QMenu *viewMenu = menuBar()->addMenu( tr( "View" ) ); viewMenu->addAction( mActionZoomIn ); viewMenu->addAction( mActionZoomOut ); viewMenu->addAction( mActionZoomAll ); viewMenu->addSeparator(); viewMenu->addAction( mActionRefreshView ); QMenu *layoutMenu = menuBar()->addMenu( tr( "Layout" ) ); layoutMenu->addAction( mActionUndo ); layoutMenu->addAction( mActionRedo ); layoutMenu->addSeparator(); layoutMenu->addAction( mActionAddNewMap ); layoutMenu->addAction( mActionAddNewLabel ); layoutMenu->addAction( mActionAddNewScalebar ); layoutMenu->addAction( mActionAddNewLegend ); layoutMenu->addAction( mActionAddImage ); layoutMenu->addAction( mActionSelectMoveItem ); layoutMenu->addAction( mActionMoveItemContent ); layoutMenu->addAction( mActionAddBasicShape ); layoutMenu->addAction( mActionAddArrow ); layoutMenu->addAction( mActionAddTable ); layoutMenu->addSeparator(); layoutMenu->addAction( mActionGroupItems ); layoutMenu->addAction( mActionUngroupItems ); layoutMenu->addAction( mActionRaiseItems ); layoutMenu->addAction( mActionLowerItems ); layoutMenu->addAction( mActionMoveItemsToTop ); layoutMenu->addAction( mActionMoveItemsToBottom ); #ifdef Q_WS_MAC #ifndef Q_WS_MAC64 /* assertion failure in NSMenuItem setSubmenu (Qt 4.5.0-snapshot-20080830) */ menuBar()->addMenu( QgisApp::instance()->windowMenu() ); menuBar()->addMenu( QgisApp::instance()->helpMenu() ); #endif #endif mQgis = qgis; mFirstTime = true; // Create action to select this window mWindowAction = new QAction( windowTitle(), this ); connect( mWindowAction, SIGNAL( triggered() ), this, SLOT( activate() ) ); QgsDebugMsg( "entered." ); setMouseTracking( true ); //mSplitter->setMouseTracking(true); mViewFrame->setMouseTracking( true ); //create composer view mView = new QgsComposerView( mViewFrame ); connectSlots(); //init undo/redo buttons mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() ); mActionUndo->setEnabled( false ); mActionRedo->setEnabled( false ); if ( mComposition->undoStack() ) { connect( mComposition->undoStack(), SIGNAL( canUndoChanged( bool ) ), mActionUndo, SLOT( setEnabled( bool ) ) ); connect( mComposition->undoStack(), SIGNAL( canRedoChanged( bool ) ), mActionRedo, SLOT( setEnabled( bool ) ) ); }
/// /// Public Funcitons /// //! //! Fills the given tool bars with actions for the TableViewPanel view. //! //! \param mainToolBar The main tool bar to fill with actions. //! \param panelToolBar The panel tool bar to fill with actions. //! void TableViewPanel::fillToolBars ( QToolBar *mainToolBar, QToolBar *panelToolBar ) { // Temp QAction *ui_descriptionAction; ui_descriptionAction = new QAction(this); ui_descriptionAction->setObjectName(QString::fromUtf8("ui_descriptionAction")); ui_descriptionAction->setCheckable(true); QIcon icon1; icon1.addFile(QString::fromUtf8(":/infoIcon"), QSize(), QIcon::Normal, QIcon::Off); ui_descriptionAction->setIcon(icon1); ui_descriptionAction->setToolTip("Show Description"); connect(ui_descriptionAction, SIGNAL(toggled(bool)), this, SLOT(showDiscription(bool))); // Column visibility select control // Place holder for drop down to select which columns of table are visible // This should be populated with column names QAction *visibilityAct = new QAction(tr("&Select Columns..."), this); visibilityAct->setStatusTip(tr("Select columns for visibility...")); connect(visibilityAct, SIGNAL(triggered()), this, SLOT()); QMenu *visibilityMenu = new QMenu(); visibilityMenu->addAction(visibilityAct); visibilityMenu->addSeparator(); QString menuStyleSheet ( "QMenuBar {" " border: none;" " margin: 0px;" " padding: 0px;" " background: none;" "}" "QMenuBar::item {" " background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a5a5a5, stop:0.2 #999999, stop:0.8 #b0b0b0, stop:1 #555555);" " color: #000000;" " border: 1px solid #323232" " border-radius: 5px;" "}" "QMenuBar::item:selected {" " background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a6a6a6, stop:1 #8a8a8a);" " color: #000000;" " border: 1px solid #222222" " border-radius: 5px;" "}" "QMenuBar::item:pressed {" " background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a6a6a6, stop:1 #8a8a8a);" " color: #000000;" " border: 1px solid #222222" " border-radius: 5px;" "}" ); QMenuBar *visibilityMenuBar = new QMenuBar(); visibilityMenuBar->setMinimumWidth(50); visibilityMenuBar->setStyleSheet(menuStyleSheet); visibilityMenuBar->addMenu(visibilityMenu); visibilityMenuBar->addAction(visibilityAct); // Search control // Keyword search highlights rows QLineEdit *searchField = new QLineEdit(); searchField->setMaximumWidth(200); mainToolBar->addAction(ui_descriptionAction); mainToolBar->addSeparator(); mainToolBar->addWidget(visibilityMenuBar); mainToolBar->addSeparator(); mainToolBar->addWidget(searchField); }
void MainWindow::menuBookmarksAboutToShow() { QMenu *menu = qobject_cast<QMenu*>(sender()); if (!menu || !menu->menuAction()) { return; } menu->setObjectName(QLatin1String("bookmarks")); menu->installEventFilter(this); const int folder = menu->menuAction()->data().toInt(); if ((folder == 0 && menu->actions().count() == 3) || (folder != 0 && menu->actions().isEmpty())) { WebBackend *backend = WebBackendsManager::getBackend(); const QList<BookmarkInformation*> bookmarks = BookmarksManager::getFolder(folder); if (folder != 0 && bookmarks.count() > 1) { QAction *openAllAction = menu->addAction(Utils::getIcon(QLatin1String("document-open-folder")), tr("Open All")); openAllAction->setData(folder); connect(openAllAction, SIGNAL(triggered()), this, SLOT(actionOpenBookmarkFolder())); menu->addSeparator(); } for (int i = 0; i < bookmarks.count(); ++i) { if (bookmarks.at(i)->type == FolderBookmark || bookmarks.at(i)->type == UrlBookmark) { QAction *action = menu->addAction(((bookmarks.at(i)->type == FolderBookmark) ? Utils::getIcon(QLatin1String("inode-directory")) : backend->getIconForUrl(QUrl(bookmarks.at(i)->url))), (bookmarks.at(i)->title.isEmpty() ? tr("(Untitled)") : Utils::elideText(QString(bookmarks.at(i)->title).replace(QLatin1Char('&'), QLatin1String("&&")), menu))); action->setToolTip(bookmarks.at(i)->description); if (bookmarks.at(i)->type == FolderBookmark) { action->setData(bookmarks.at(i)->identifier); if (!bookmarks.at(i)->children.isEmpty()) { action->setMenu(new QMenu()); connect(action->menu(), SIGNAL(aboutToShow()), this, SLOT(menuBookmarksAboutToShow())); } } else { action->setData(bookmarks.at(i)->url); connect(action, SIGNAL(triggered()), this, SLOT(actionOpenBookmark())); } } else { menu->addSeparator(); } } } }
//----------------------------------------------------------------------------- void swftParaViewMenuBuilders::buildToolsMenu(QMenu& menu) { new pqCreateCustomFilterReaction(menu.addAction("Create Custom Filter...") << pqSetName("actionToolsCreateCustomFilter")); new pqCameraLinkReaction(menu.addAction("Add Camera Link...") << pqSetName("actionToolsAddCameraLink")); menu.addSeparator(); new pqManageCustomFiltersReaction(menu.addAction("Manage Custom Filters...") << pqSetName("actionToolsManageCustomFilters")); new pqManageLinksReaction(menu.addAction("Manage Links...") << pqSetName("actionToolsManageLinks")); //<addaction name="actionToolsAddCameraLink" /> #ifdef BUILD_SHARED_LIBS // Add support for importing plugins only if ParaView was built shared. new pqManagePluginsReaction(menu.addAction("Manage Plugins...") << pqSetName("actionManage_Plugins")); #else QAction* action2 = menu.addAction("Manage Plugins..."); action2->setEnabled(false); action2->setToolTip( "Use BUILD_SHARED:ON while compiling to enable plugin support."); action2->setStatusTip(action2->toolTip()); #endif menu.addSeparator(); // -------------------------------------------------- //<addaction name="actionToolsDumpWidgetNames" /> new pqTestingReaction(menu.addAction("Record Test...") << pqSetName("actionToolsRecordTest"), pqTestingReaction::RECORD); new pqTestingReaction(menu.addAction("Play Test...") << pqSetName("actionToolsPlayTest"), pqTestingReaction::PLAYBACK,Qt::QueuedConnection); new pqTestingReaction(menu.addAction("Lock View Size") << pqSetName("actionTesting_Window_Size"), pqTestingReaction::LOCK_VIEW_SIZE); new pqTestingReaction(menu.addAction("Lock View Size Custom...") << pqSetName("actionTesting_Window_Size_Custom"), pqTestingReaction::LOCK_VIEW_SIZE_CUSTOM); menu.addSeparator(); new pqTimerLogReaction(menu.addAction("Timer Log") << pqSetName("actionToolsTimerLog")); QAction* action = menu.addAction("&Output Window") << pqSetName("actionToolsOutputWindow"); QObject::connect(action, SIGNAL(triggered()), pqApplicationCore::instance(), SLOT(showOutputWindow())); menu.addSeparator(); // -------------------------------------------------- new pqCatalystConnectReaction(menu.addAction("Connect To Catalyst") << pqSetName("actionConnectCatalyst")); menu.addSeparator(); // -------------------------------------------------- new pqPythonShellReaction(menu.addAction("Python Shell") << pqSetName("actionToolsPythonShell")); #ifdef PARAVIEW_ENABLE_PYTHON menu.addSeparator(); // -------------------------------------------------- new pqTraceReaction( menu.addAction("Start Trace") << pqSetName("actionToolsStartTrace"), true); new pqTraceReaction(menu.addAction("Stop Trace") << pqSetName("actionToolsStartTrace"), false); #endif }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // Menu QMenu* modelMenu = menuBar()->addMenu("&Model"); modelMenu->addAction("&Open model...", this, SLOT(openModel()) ); modelMenu->addSeparator(); modelMenu->addAction("&Close model", this, SLOT(closeModel()) ); QMenu* markMenu = menuBar()->addMenu("&Bookmarks"); markMenu->addAction("&New file...", this, SLOT(closeBookmarksFile()) ); markMenu->addAction("&Open file...", this, SLOT(openBookmarksFile()) ); markMenu->addSeparator(); markMenu->addAction("&Close file", this, SLOT(closeBookmarksFile()) ); markMenu->addSeparator(); markMenu->addAction("&Save file", this, SLOT(saveBookmarksFile())); markMenu->addAction("&Save file as...", this, SLOT(saveAsBookmarksFile())); QMenu* viewMenu = menuBar()->addMenu("&View"); viewMenu->addAction("&View as points", this, SLOT(viewAsPoints()) ); viewMenu->addAction("&View as wired", this, SLOT(viewAsWired()) ); viewMenu->addAction("&View as solid", this, SLOT(viewAsSolid()) ); viewMenu->addAction("&View as solid + wired",this, SLOT(viewAsSolidWire()) ); QMenu* modeMenu = menuBar()->addMenu("&Mode"); modeMenu->addAction("&Viewer", this, SLOT(viewerMode()) ); modeMenu->addAction("&Editor", this, SLOT(editorMode()) ); modeMenu->addAction("&Ask Me!", this, SLOT(testMode()) ); // Section list panel buttons. QObject::connect(ui->addButton, SIGNAL(clicked()), this, SLOT(showAddSectionPanel())); QObject::connect(ui->editButton, SIGNAL(clicked()), this, SLOT(showEditSectionPanel())); QObject::connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCurrentSection())); QObject::connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(showInfoSectionPanel())); QObject::connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(listWidgetItemClicked(QListWidgetItem*))); // Add bookmark panel buttons. QObject::connect(ui->addModeButton, SIGNAL(clicked()), this, SLOT(setAddSelectionMode())); QObject::connect(ui->removeModeButton, SIGNAL(clicked()), this, SLOT(setRemoveSelectionMode())); QObject::connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveBookmark())); QObject::connect(ui->discardButton, SIGNAL(clicked()), this, SLOT(discardBookmark())); QObject::connect(ui->brushSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrushSize(int))); // Information panel buttons QObject::connect(ui->backButton, SIGNAL(clicked()), this, SLOT(showListPanel())); // Test panel buttons QObject::connect(ui->nextQuestionButton, SIGNAL(clicked()), this, SLOT(nextQuestion())); QObject::connect(ui->glwidget, SIGNAL(pickResult(std::set<unsigned int>)), this, SLOT(checkResponse(std::set<unsigned int>))); // Set window title. setWindowTitle("untitled.txt"); // Initialize variables. _bookmarkList = new BookmarkList(); clearBookmarkList(); _model = new Model(); _indexTest = 0; // Set viewer mode. viewerMode(); // Show welcome message statusBar()->showMessage("Welcome to 3D Marker."); }