Support assigning shortcuts to toolbars. Fixes #463.

This commit is contained in:
Leonardo Zide 2020-07-11 12:22:01 -07:00
parent 0cead36c7f
commit 92d75c4963
4 changed files with 127 additions and 14 deletions

View file

@ -1018,6 +1018,55 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
QT_TRANSLATE_NOOP("Status", "Reset all views"),
""
},
// LC_VIEW_TOOLBAR_STANDARD
{
QT_TRANSLATE_NOOP("Action", "View.Toolbars.Standard"),
QT_TRANSLATE_NOOP("Menu", "Standard"),
QT_TRANSLATE_NOOP("Status", "Toggle the Standard Toolbar"),
""
},
// LC_VIEW_TOOLBAR_TOOLS
{
QT_TRANSLATE_NOOP("Action", "View.Toolbars.Tools"),
QT_TRANSLATE_NOOP("Menu", "Tools"),
QT_TRANSLATE_NOOP("Status", "Toggle the Tools Toolbar"),
""
},
// LC_VIEW_TOOLBAR_TIME
{
QT_TRANSLATE_NOOP("Action", "View.Toolbars.Time"),
QT_TRANSLATE_NOOP("Menu", "Time"),
QT_TRANSLATE_NOOP("Status", "Toggle the Time Toolbar"),
""
},
// LC_VIEW_TOOLBAR_PARTS
{
QT_TRANSLATE_NOOP("Action", "View.Toolbars.Parts"),
QT_TRANSLATE_NOOP("Menu", "Parts"),
QT_TRANSLATE_NOOP("Status", "Toggle the Parts Toolbar"),
""
},
// LC_VIEW_TOOLBAR_COLORS
{
QT_TRANSLATE_NOOP("Action", "View.Toolbars.Colors"),
QT_TRANSLATE_NOOP("Menu", "Colors"),
QT_TRANSLATE_NOOP("Status", "Toggle the Colors Toolbar"),
""
},
// LC_VIEW_TOOLBAR_PROPERTIES
{
QT_TRANSLATE_NOOP("Action", "View.Toolbars.Properties"),
QT_TRANSLATE_NOOP("Menu", "Properties"),
QT_TRANSLATE_NOOP("Status", "Toggle the Properties Toolbar"),
""
},
// LC_VIEW_TOOLBAR_TIMELINE
{
QT_TRANSLATE_NOOP("Action", "View.Toolbars.Timeline"),
QT_TRANSLATE_NOOP("Menu", "Timeline"),
QT_TRANSLATE_NOOP("Status", "Toggle the Timeline Toolbar"),
""
},
// LC_VIEW_FULLSCREEN
{
QT_TRANSLATE_NOOP("Action", "View.FullScreen"),

View file

@ -155,6 +155,15 @@ enum lcCommandId
LC_VIEW_SPLIT_VERTICAL,
LC_VIEW_REMOVE_VIEW,
LC_VIEW_RESET_VIEWS,
LC_VIEW_TOOLBAR_STANDARD,
LC_VIEW_TOOLBAR_FIRST = LC_VIEW_TOOLBAR_STANDARD,
LC_VIEW_TOOLBAR_TOOLS,
LC_VIEW_TOOLBAR_TIME,
LC_VIEW_TOOLBAR_PARTS,
LC_VIEW_TOOLBAR_COLORS,
LC_VIEW_TOOLBAR_PROPERTIES,
LC_VIEW_TOOLBAR_TIMELINE,
LC_VIEW_TOOLBAR_LAST = LC_VIEW_TOOLBAR_TIMELINE,
LC_VIEW_FULLSCREEN,
LC_VIEW_CLOSE_CURRENT_TAB,
LC_VIEW_SHADING_FIRST,

View file

@ -329,6 +329,9 @@ void lcMainWindow::CreateActions()
mActions[LC_VIEW_CAMERA_NONE]->setCheckable(true);
mActions[LC_VIEW_TIME_ADD_KEYS]->setCheckable(true);
for (int ActionIndex = LC_VIEW_TOOLBAR_FIRST; ActionIndex <= LC_VIEW_TOOLBAR_LAST; ActionIndex++)
mActions[ActionIndex]->setCheckable(true);
QActionGroup* ActionSnapXYGroup = new QActionGroup(this);
for (int ActionIdx = LC_EDIT_SNAP_MOVE_XY0; ActionIdx <= LC_EDIT_SNAP_MOVE_XY9; ActionIdx++)
{
@ -540,14 +543,15 @@ void lcMainWindow::CreateMenus()
ViewMenu->addAction(mActions[LC_VIEW_RESET_VIEWS]);
ViewMenu->addSeparator();
QMenu* ToolBarsMenu = ViewMenu->addMenu(tr("T&oolbars"));
ToolBarsMenu->addAction(mPartsToolBar->toggleViewAction());
ToolBarsMenu->addAction(mColorsToolBar->toggleViewAction());
ToolBarsMenu->addAction(mPropertiesToolBar->toggleViewAction());
ToolBarsMenu->addAction(mTimelineToolBar->toggleViewAction());
connect(ToolBarsMenu, SIGNAL(aboutToShow()), this, SLOT(UpdateDockWidgetActions()));
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_PARTS]);
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_COLORS]);
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_PROPERTIES]);
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_TIMELINE]);
ToolBarsMenu->addSeparator();
ToolBarsMenu->addAction(mStandardToolBar->toggleViewAction());
ToolBarsMenu->addAction(mToolsToolBar->toggleViewAction());
ToolBarsMenu->addAction(mTimeToolBar->toggleViewAction());
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_STANDARD]);
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_TOOLS]);
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_TIME]);
ViewMenu->addAction(mActions[LC_VIEW_FULLSCREEN]);
QMenu* PieceMenu = menuBar()->addMenu(tr("&Piece"));
@ -873,18 +877,31 @@ QMenu* lcMainWindow::createPopupMenu()
{
QMenu* Menu = new QMenu(this);
Menu->addAction(mPartsToolBar->toggleViewAction());
Menu->addAction(mColorsToolBar->toggleViewAction());
Menu->addAction(mPropertiesToolBar->toggleViewAction());
Menu->addAction(mTimelineToolBar->toggleViewAction());
UpdateDockWidgetActions();
Menu->addAction(mActions[LC_VIEW_TOOLBAR_PARTS]);
Menu->addAction(mActions[LC_VIEW_TOOLBAR_COLORS]);
Menu->addAction(mActions[LC_VIEW_TOOLBAR_PROPERTIES]);
Menu->addAction(mActions[LC_VIEW_TOOLBAR_TIMELINE]);
Menu->addSeparator();
Menu->addAction(mStandardToolBar->toggleViewAction());
Menu->addAction(mToolsToolBar->toggleViewAction());
Menu->addAction(mTimeToolBar->toggleViewAction());
Menu->addAction(mActions[LC_VIEW_TOOLBAR_STANDARD]);
Menu->addAction(mActions[LC_VIEW_TOOLBAR_TOOLS]);
Menu->addAction(mActions[LC_VIEW_TOOLBAR_TIME]);
return Menu;
}
void lcMainWindow::UpdateDockWidgetActions()
{
mActions[LC_VIEW_TOOLBAR_PARTS]->setChecked(mPartsToolBar->isVisible());
mActions[LC_VIEW_TOOLBAR_COLORS]->setChecked(mColorsToolBar->isVisible());
mActions[LC_VIEW_TOOLBAR_PROPERTIES]->setChecked(mPropertiesToolBar->isVisible());
mActions[LC_VIEW_TOOLBAR_TIMELINE]->setChecked(mTimelineToolBar->isVisible());
mActions[LC_VIEW_TOOLBAR_STANDARD]->setChecked(mStandardToolBar->isVisible());
mActions[LC_VIEW_TOOLBAR_TOOLS]->setChecked(mToolsToolBar->isVisible());
mActions[LC_VIEW_TOOLBAR_TIME]->setChecked(mTimeToolBar->isVisible());
}
void lcMainWindow::UpdateGamepads()
{
#if LC_ENABLE_GAMEPAD
@ -1829,6 +1846,14 @@ void lcMainWindow::ResetViews()
TabWidget->GetActiveView()->SetViewpoint(LC_VIEWPOINT_HOME);
}
void lcMainWindow::ToggleDockWidget(QWidget* DockWidget)
{
if (DockWidget->isHidden())
DockWidget->show();
else
DockWidget->hide();
}
void lcMainWindow::TogglePrintPreview()
{
#ifndef QT_NO_PRINTER
@ -2655,6 +2680,34 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
ResetViews();
break;
case LC_VIEW_TOOLBAR_STANDARD:
ToggleDockWidget(mStandardToolBar);
break;
case LC_VIEW_TOOLBAR_TOOLS:
ToggleDockWidget(mToolsToolBar);
break;
case LC_VIEW_TOOLBAR_TIME:
ToggleDockWidget(mTimeToolBar);
break;
case LC_VIEW_TOOLBAR_PARTS:
ToggleDockWidget(mPartsToolBar);
break;
case LC_VIEW_TOOLBAR_COLORS:
ToggleDockWidget(mColorsToolBar);
break;
case LC_VIEW_TOOLBAR_PROPERTIES:
ToggleDockWidget(mPropertiesToolBar);
break;
case LC_VIEW_TOOLBAR_TIMELINE:
ToggleDockWidget(mTimelineToolBar);
break;
case LC_VIEW_FULLSCREEN:
ToggleFullScreen();
break;

View file

@ -353,6 +353,7 @@ public slots:
void ProjectFileChanged(const QString& Path);
protected slots:
void UpdateDockWidgetActions();
void UpdateGamepads();
void ModelTabContextMenuRequested(const QPoint& Point);
void ModelTabCloseOtherTabs();
@ -373,6 +374,7 @@ protected:
void CreateMenus();
void CreateToolBars();
void CreateStatusBar();
void ToggleDockWidget(QWidget* DockWidget);
void SplitView(Qt::Orientation Orientation);
void ShowSearchDialog();
void ShowUpdatesDialog();