documentwindow: Add top level menu accelerators and a few File shortcuts.

- Remove routing of Ctrl+S shortcut through skeletongraphicswidget.
master
Karl Robillard 2019-12-30 22:54:07 -05:00 committed by Jeremy Hu
parent 7a65725c41
commit c251d4aa21
4 changed files with 14 additions and 23 deletions

View File

@ -425,19 +425,19 @@ DocumentWindow::DocumentWindow() :
setCentralWidget(centralWidget); setCentralWidget(centralWidget);
setWindowTitle(APP_NAME); setWindowTitle(APP_NAME);
m_fileMenu = menuBar()->addMenu(tr("File")); m_fileMenu = menuBar()->addMenu(tr("&File"));
m_newWindowAction = new QAction(tr("New Window"), this); m_newWindowAction = new QAction(tr("New Window"), this);
connect(m_newWindowAction, &QAction::triggered, this, &DocumentWindow::newWindow, Qt::QueuedConnection); connect(m_newWindowAction, &QAction::triggered, this, &DocumentWindow::newWindow, Qt::QueuedConnection);
m_fileMenu->addAction(m_newWindowAction); m_fileMenu->addAction(m_newWindowAction);
m_newDocumentAction = new QAction(tr("New"), this); m_newDocumentAction = m_fileMenu->addAction(tr("&New"),
connect(m_newDocumentAction, &QAction::triggered, this, &DocumentWindow::newDocument); this, &DocumentWindow::newDocument,
m_fileMenu->addAction(m_newDocumentAction); QKeySequence::New);
m_openAction = new QAction(tr("Open..."), this); m_openAction = m_fileMenu->addAction(tr("&Open..."),
connect(m_openAction, &QAction::triggered, this, &DocumentWindow::open, Qt::QueuedConnection); this, &DocumentWindow::open,
m_fileMenu->addAction(m_openAction); QKeySequence::Open);
m_openExampleMenu = new QMenu(tr("Open Example")); m_openExampleMenu = new QMenu(tr("Open Example"));
std::vector<QString> exampleModels = { std::vector<QString> exampleModels = {
@ -460,9 +460,9 @@ DocumentWindow::DocumentWindow() :
m_fileMenu->addMenu(m_openExampleMenu); m_fileMenu->addMenu(m_openExampleMenu);
m_saveAction = new QAction(tr("Save"), this); m_saveAction = m_fileMenu->addAction(tr("&Save"),
connect(m_saveAction, &QAction::triggered, this, &DocumentWindow::save, Qt::QueuedConnection); this, &DocumentWindow::save,
m_fileMenu->addAction(m_saveAction); QKeySequence::Save);
m_saveAsAction = new QAction(tr("Save As..."), this); m_saveAsAction = new QAction(tr("Save As..."), this);
connect(m_saveAsAction, &QAction::triggered, this, &DocumentWindow::saveAs, Qt::QueuedConnection); connect(m_saveAsAction, &QAction::triggered, this, &DocumentWindow::saveAs, Qt::QueuedConnection);
@ -517,7 +517,7 @@ DocumentWindow::DocumentWindow() :
//m_exportRenderedAsImageAction->setEnabled(m_graphicsWidget->hasItems()); //m_exportRenderedAsImageAction->setEnabled(m_graphicsWidget->hasItems());
}); });
m_editMenu = menuBar()->addMenu(tr("Edit")); m_editMenu = menuBar()->addMenu(tr("&Edit"));
m_addAction = new QAction(tr("Add..."), this); m_addAction = new QAction(tr("Add..."), this);
connect(m_addAction, &QAction::triggered, [=]() { connect(m_addAction, &QAction::triggered, [=]() {
@ -709,7 +709,7 @@ DocumentWindow::DocumentWindow() :
m_unselectAllAction->setEnabled(m_graphicsWidget->hasSelection()); m_unselectAllAction->setEnabled(m_graphicsWidget->hasSelection());
}); });
m_viewMenu = menuBar()->addMenu(tr("View")); m_viewMenu = menuBar()->addMenu(tr("&View"));
auto isModelSitInVisibleArea = [](ModelWidget *modelWidget) { auto isModelSitInVisibleArea = [](ModelWidget *modelWidget) {
QRect parentRect = QRect(QPoint(0, 0), modelWidget->parentWidget()->size()); QRect parentRect = QRect(QPoint(0, 0), modelWidget->parentWidget()->size());
@ -740,7 +740,7 @@ DocumentWindow::DocumentWindow() :
m_resetModelWidgetPosAction->setEnabled(!isModelSitInVisibleArea(m_modelRenderWidget)); m_resetModelWidgetPosAction->setEnabled(!isModelSitInVisibleArea(m_modelRenderWidget));
}); });
m_windowMenu = menuBar()->addMenu(tr("Window")); m_windowMenu = menuBar()->addMenu(tr("&Window"));
m_showPartsListAction = new QAction(tr("Parts"), this); m_showPartsListAction = new QAction(tr("Parts"), this);
connect(m_showPartsListAction, &QAction::triggered, [=]() { connect(m_showPartsListAction, &QAction::triggered, [=]() {
@ -805,7 +805,7 @@ DocumentWindow::DocumentWindow() :
connect(m_showDebugDialogAction, &QAction::triggered, g_logBrowser, &LogBrowser::showDialog); connect(m_showDebugDialogAction, &QAction::triggered, g_logBrowser, &LogBrowser::showDialog);
m_windowMenu->addAction(m_showDebugDialogAction); m_windowMenu->addAction(m_showDebugDialogAction);
m_helpMenu = menuBar()->addMenu(tr("Help")); m_helpMenu = menuBar()->addMenu(tr("&Help"));
m_gotoHomepageAction = new QAction(tr("Dust3D Homepage"), this); m_gotoHomepageAction = new QAction(tr("Dust3D Homepage"), this);
connect(m_gotoHomepageAction, &QAction::triggered, this, &DocumentWindow::gotoHomepage); connect(m_gotoHomepageAction, &QAction::triggered, this, &DocumentWindow::gotoHomepage);
@ -965,7 +965,6 @@ DocumentWindow::DocumentWindow() :
connect(graphicsWidget, &SkeletonGraphicsWidget::disableAllPositionRelatedLocks, m_document, &Document::disableAllPositionRelatedLocks); connect(graphicsWidget, &SkeletonGraphicsWidget::disableAllPositionRelatedLocks, m_document, &Document::disableAllPositionRelatedLocks);
connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &DocumentWindow::changeTurnaround); connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &DocumentWindow::changeTurnaround);
connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &DocumentWindow::save);
connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &DocumentWindow::open); connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &DocumentWindow::open);
connect(graphicsWidget, &SkeletonGraphicsWidget::showCutFaceSettingPopup, this, &DocumentWindow::showCutFaceSettingPopup); connect(graphicsWidget, &SkeletonGraphicsWidget::showCutFaceSettingPopup, this, &DocumentWindow::showCutFaceSettingPopup);

View File

@ -26,7 +26,6 @@ void initShortCuts(QWidget *widget, SkeletonGraphicsWidget *graphicsWidget)
defineKey(Qt::Key_X, &SkeletonGraphicsWidget::shortcutXlock); defineKey(Qt::Key_X, &SkeletonGraphicsWidget::shortcutXlock);
defineKey(Qt::CTRL + Qt::Key_C, &SkeletonGraphicsWidget::shortcutCopy); defineKey(Qt::CTRL + Qt::Key_C, &SkeletonGraphicsWidget::shortcutCopy);
defineKey(Qt::CTRL + Qt::Key_V, &SkeletonGraphicsWidget::shortcutPaste); defineKey(Qt::CTRL + Qt::Key_V, &SkeletonGraphicsWidget::shortcutPaste);
defineKey(Qt::CTRL + Qt::Key_S, &SkeletonGraphicsWidget::shortcutSave);
defineKey(Qt::Key_S, &SkeletonGraphicsWidget::shortcutSelectMode); defineKey(Qt::Key_S, &SkeletonGraphicsWidget::shortcutSelectMode);
defineKey(Qt::Key_D, &SkeletonGraphicsWidget::shortcutPaintMode); defineKey(Qt::Key_D, &SkeletonGraphicsWidget::shortcutPaintMode);
defineKey(Qt::ALT + Qt::Key_Minus, &SkeletonGraphicsWidget::shortcutZoomRenderedModelByMinus10); defineKey(Qt::ALT + Qt::Key_Minus, &SkeletonGraphicsWidget::shortcutZoomRenderedModelByMinus10);

View File

@ -1782,11 +1782,6 @@ void SkeletonGraphicsWidget::shortcutPaste()
emit paste(); emit paste();
} }
void SkeletonGraphicsWidget::shortcutSave()
{
emit save();
}
void SkeletonGraphicsWidget::shortcutSelectMode() void SkeletonGraphicsWidget::shortcutSelectMode()
{ {
emit setEditMode(SkeletonDocumentEditMode::Select); emit setEditMode(SkeletonDocumentEditMode::Select);

View File

@ -469,7 +469,6 @@ signals:
void changeTurnaround(); void changeTurnaround();
void batchChangeBegin(); void batchChangeBegin();
void batchChangeEnd(); void batchChangeEnd();
void save();
void open(); void open();
void exportResult(); void exportResult();
void breakEdge(QUuid edgeId); void breakEdge(QUuid edgeId);
@ -616,7 +615,6 @@ public slots:
void shortcutCut(); void shortcutCut();
void shortcutCopy(); void shortcutCopy();
void shortcutPaste(); void shortcutPaste();
void shortcutSave();
void shortcutSelectMode(); void shortcutSelectMode();
void shortcutPaintMode(); void shortcutPaintMode();
void shortcutZoomRenderedModelByMinus10(); void shortcutZoomRenderedModelByMinus10();