ProcessView::ProcessView(QWidget *parent) : QTableView(parent) { initialActions(); connect(m_refresh, SIGNAL(triggered()), this, SLOT(onRefreshActionTriggered())); connect(m_modules, SIGNAL(triggered()), this, SLOT(onModulesActionTriggered())); connect(m_threads, SIGNAL(triggered()), this, SLOT(onThreadsActionTriggered())); connect(m_location, SIGNAL(triggered()), this, SLOT(onLocationActionTriggered())); }
void MainWindow::createActions() { // File menu m_newDocumentAction = new QAction(QIcon::fromTheme("document-new"), tr("&New"), this); m_newDocumentAction->setShortcut(QKeySequence::New); connect(m_newDocumentAction, SIGNAL(triggered()), this, SLOT(newDocument())); m_openDocumentAction = new QAction(QIcon::fromTheme("document-open"), tr("&Open"), this); m_openDocumentAction->setShortcuts(QKeySequence::Open); connect(m_openDocumentAction, SIGNAL(triggered()), this, SLOT(onOpenDocumentActionTriggered())); m_saveDocumentAction = new QAction(QIcon::fromTheme("document-save"), tr("&Save"), this); m_saveDocumentAction->setShortcuts(QKeySequence::Save); connect(m_saveDocumentAction, SIGNAL(triggered()), this, SLOT(onSaveActionTriggered())); m_saveAsDocumentAction = new QAction(QIcon::fromTheme("document-save-as"), tr("Save As..."), this); m_saveAsDocumentAction->setShortcuts(QKeySequence::SaveAs); connect(m_saveAsDocumentAction, SIGNAL(triggered()), this, SLOT(onSaveAsActionTriggered())); m_exportImageAction = new QAction(EXPORT_TO_MENU_FORMAT_STRING.arg(""), this); m_exportImageAction->setShortcut(Qt::CTRL + Qt::Key_E); connect(m_exportImageAction, SIGNAL(triggered()), this, SLOT(onExportImageActionTriggered())); m_exportAsImageAction = new QAction(tr("Export as ..."), this); m_exportAsImageAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_E); connect(m_exportAsImageAction, SIGNAL(triggered()), this, SLOT(onExportAsImageActionTriggered())); m_quitAction = new QAction(QIcon::fromTheme("application-exit"), tr("&Quit"), this); m_quitAction->setShortcuts(QKeySequence::Quit); // m_quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); m_quitAction->setStatusTip(tr("Quit the application")); connect(m_quitAction, SIGNAL(triggered()), this, SLOT(close())); // Edit menu m_undoAction = new QAction(QIcon::fromTheme("edit-undo"), tr("&Undo"), this); m_undoAction->setShortcuts(QKeySequence::Undo); connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo())); m_redoAction = new QAction(QIcon::fromTheme("edit-redo"), tr("&Redo"), this); m_redoAction->setShortcuts(QKeySequence::Redo); connect(m_redoAction, SIGNAL(triggered()), this, SLOT(redo())); m_copyImageAction = new QAction(QIcon::fromTheme("copy"), tr("&Copy Image"), this); m_copyImageAction->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C) << QKeySequence::Copy ); connect(m_copyImageAction, SIGNAL(triggered()), this, SLOT(copyImage()) ); // Tools menu m_pngPreviewAction = new QAction(tr("PNG"), this); m_pngPreviewAction->setCheckable(true); m_pngPreviewAction->setStatusTip(tr("Tell PlantUML to produce PNG output")); connect(m_pngPreviewAction, SIGNAL(toggled(bool)), this, SLOT(changeImageFormat())); m_svgPreviewAction = new QAction(tr("SVG"), this); m_svgPreviewAction->setCheckable(true); m_svgPreviewAction->setStatusTip(tr("Tell PlantUML to produce SVG output")); connect(m_svgPreviewAction, SIGNAL(toggled(bool)), this, SLOT(changeImageFormat())); QActionGroup* output_action_group = new QActionGroup(this); output_action_group->setExclusive(true); output_action_group->addAction(m_pngPreviewAction); output_action_group->addAction(m_svgPreviewAction); m_svgPreviewAction->setChecked(true); m_refreshAction = new QAction(QIcon::fromTheme("view-refresh"), tr("Refresh"), this); m_refreshAction->setShortcuts(QKeySequence::Refresh); m_refreshAction->setStatusTip(tr("Call PlantUML to regenerate the UML image")); connect(m_refreshAction, SIGNAL(triggered()), this, SLOT(onRefreshActionTriggered())); m_autoRefreshAction = new QAction(tr("Auto-Refresh"), this); m_autoRefreshAction->setCheckable(true); m_autoSaveImageAction = new QAction(tr("Auto-Save image"), this); m_autoSaveImageAction->setCheckable(true); connect(m_autoRefreshAction, SIGNAL(toggled(bool)), this, SLOT(onAutoRefreshActionToggled(bool))); // Settings menu m_showMainToolbarAction = new QAction(tr("Show toolbar"), this); m_showMainToolbarAction->setCheckable(true); m_showStatusBarAction = new QAction(tr("Show statusbar"), this); m_showStatusBarAction->setCheckable(true); m_preferencesAction = new QAction(QIcon::fromTheme("preferences-other"), tr("Preferences"), this); connect(m_preferencesAction, SIGNAL(triggered()), this, SLOT(onPreferencesActionTriggered())); // Help menu m_aboutAction = new QAction(QIcon::fromTheme("help-about"), tr("&About"), this); m_aboutAction->setStatusTip(tr("Show the application's About box")); connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(about())); m_aboutQtAction = new QAction(tr("About &Qt"), this); m_aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(m_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); // focus actions QAction* focus_action = new QAction(this); focus_action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0)); connect(focus_action, SIGNAL(triggered()), m_editor, SLOT(setFocus())); this->addAction(focus_action); focus_action = new QAction(this); focus_action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1)); connect(focus_action, SIGNAL(triggered()), this, SLOT(onAssistantFocus())); this->addAction(focus_action); // assistant actions QAction* navigation_action = new QAction(this); navigation_action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down)); connect(navigation_action, SIGNAL(triggered()), this, SLOT(onNextAssistant())); addAction(navigation_action); navigation_action = new QAction(this); navigation_action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up)); connect(navigation_action, SIGNAL(triggered()), this, SLOT(onPrevAssistant())); addAction(navigation_action); // zoom action m_zoomInAction = new QAction(QIcon::fromTheme("zoom-in"), tr("Zoom In"), this); connect(m_zoomInAction, SIGNAL(triggered()), m_imageWidget, SLOT(zoomIn())); m_zoomOutAction = new QAction(QIcon::fromTheme("zoom-out"), tr("Zoom Out"), this); connect(m_zoomOutAction, SIGNAL(triggered()), m_imageWidget, SLOT(zoomOut())); m_zoomOriginalAction = new QAction(QIcon::fromTheme("zoom-original"), tr("1:1"), this); connect(m_zoomOriginalAction, SIGNAL(triggered()), m_imageWidget, SLOT(zoomOriginal())); }
void MainWindow::onSaveActionTriggered() { saveDocument(m_documentPath); if (m_refreshOnSave) onRefreshActionTriggered(); }