forked from qt-creator/qt-creator
Core: More ActionBuilder use in icore.cpp
After introducing ActionBuilder::setSeparator(). Change-Id: I54e89aae66c4e4a6f2073df6287140c41da887d8 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -207,6 +207,11 @@ void ActionBuilder::setCheckable(bool on)
|
|||||||
d->contextAction->setCheckable(on);
|
d->contextAction->setCheckable(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActionBuilder::setSeperator(bool on)
|
||||||
|
{
|
||||||
|
d->contextAction->setSeparator(on);
|
||||||
|
}
|
||||||
|
|
||||||
void ActionBuilder::setScriptable(bool on)
|
void ActionBuilder::setScriptable(bool on)
|
||||||
{
|
{
|
||||||
d->scriptable = on;
|
d->scriptable = on;
|
||||||
|
@@ -78,6 +78,7 @@ public:
|
|||||||
void setChecked(bool on);
|
void setChecked(bool on);
|
||||||
void setVisible(bool on);
|
void setVisible(bool on);
|
||||||
void setCheckable(bool on);
|
void setCheckable(bool on);
|
||||||
|
void setSeperator(bool on);
|
||||||
void setScriptable(bool on);
|
void setScriptable(bool on);
|
||||||
void setMenuRole(QAction::MenuRole role);
|
void setMenuRole(QAction::MenuRole role);
|
||||||
|
|
||||||
|
@@ -1839,37 +1839,37 @@ void ICorePrivate::registerDefaultActions()
|
|||||||
|
|
||||||
if (useMacShortcuts) {
|
if (useMacShortcuts) {
|
||||||
// Minimize Action
|
// Minimize Action
|
||||||
QAction *minimizeAction = new QAction(Tr::tr("Minimize"), this);
|
ActionBuilder minimizeAction(this, Constants::MINIMIZE_WINDOW);
|
||||||
minimizeAction->setEnabled(false); // actual implementation in WindowSupport
|
minimizeAction.setText(Tr::tr("Minimize"));
|
||||||
Command *cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW);
|
minimizeAction.setEnabled(false); // actual implementation in WindowSupport
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+M")));
|
minimizeAction.setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+M")));
|
||||||
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
minimizeAction.addToContainer(Constants::M_WINDOW, Constants::G_WINDOW_SIZE);
|
||||||
|
|
||||||
// Zoom Action
|
// Zoom Action
|
||||||
QAction *zoomAction = new QAction(Tr::tr("Zoom"), this);
|
ActionBuilder zoomAction(this, Constants::ZOOM_WINDOW);
|
||||||
zoomAction->setEnabled(false); // actual implementation in WindowSupport
|
zoomAction.setText(Tr::tr("Zoom"));
|
||||||
cmd = ActionManager::registerAction(zoomAction, Constants::ZOOM_WINDOW);
|
zoomAction.setEnabled(false); // actual implementation in WindowSupport
|
||||||
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
zoomAction.addToContainer(Constants::M_WINDOW, Constants::G_WINDOW_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full Screen Action
|
// Full Screen Action
|
||||||
QAction *toggleFullScreenAction = new QAction(Tr::tr("Full Screen"), this);
|
ActionBuilder toggleFullScreenAction(this, Constants::TOGGLE_FULLSCREEN);
|
||||||
toggleFullScreenAction->setCheckable(!HostOsInfo::isMacHost());
|
toggleFullScreenAction.setText(Tr::tr("Full Screen"));
|
||||||
toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport
|
toggleFullScreenAction.setCheckable(!HostOsInfo::isMacHost());
|
||||||
Command *cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN);
|
toggleFullScreenAction.setEnabled(false); // actual implementation in WindowSupport
|
||||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Ctrl+Meta+F") : Tr::tr("Ctrl+Shift+F11")));
|
toggleFullScreenAction.setDefaultKeySequence(Tr::tr("Ctrl+Meta+F"), Tr::tr("Ctrl+Shift+F11"));
|
||||||
if (HostOsInfo::isMacHost())
|
if (HostOsInfo::isMacHost())
|
||||||
cmd->setAttribute(Command::CA_UpdateText);
|
toggleFullScreenAction.setCommandAttribute(Command::CA_UpdateText);
|
||||||
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
toggleFullScreenAction.addToContainer(Constants::M_WINDOW, Constants::G_WINDOW_SIZE);
|
||||||
|
|
||||||
if (useMacShortcuts) {
|
if (useMacShortcuts) {
|
||||||
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
|
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
|
||||||
|
|
||||||
QAction *closeAction = new QAction(Tr::tr("Close Window"), this);
|
ActionBuilder closeAction(this, Constants::CLOSE_WINDOW);
|
||||||
closeAction->setEnabled(false);
|
closeAction.setText(Tr::tr("Close Window"));
|
||||||
cmd = ActionManager::registerAction(closeAction, Constants::CLOSE_WINDOW);
|
closeAction.setEnabled(false);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Meta+W")));
|
closeAction.setDefaultKeySequence(Tr::tr("Ctrl+Meta+W"));
|
||||||
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
closeAction.addToContainer(Constants::M_WINDOW, Constants::G_WINDOW_SIZE);
|
||||||
|
|
||||||
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
|
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
|
||||||
}
|
}
|
||||||
@@ -1908,23 +1908,25 @@ void ICorePrivate::registerDefaultActions()
|
|||||||
|
|
||||||
// Show Menubar Action
|
// Show Menubar Action
|
||||||
if (globalMenuBar() && !globalMenuBar()->isNativeMenuBar()) {
|
if (globalMenuBar() && !globalMenuBar()->isNativeMenuBar()) {
|
||||||
m_toggleMenubarAction = new QAction(Tr::tr("Show Menu Bar"), this);
|
ActionBuilder toggleMenubarAction(this, Constants::TOGGLE_MENUBAR);
|
||||||
m_toggleMenubarAction->setCheckable(true);
|
toggleMenubarAction.setText(Tr::tr("Show Menu Bar"));
|
||||||
cmd = ActionManager::registerAction(m_toggleMenubarAction, Constants::TOGGLE_MENUBAR);
|
toggleMenubarAction.bindContextAction(&m_toggleMenubarAction);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Alt+M")));
|
toggleMenubarAction.setCheckable(true);
|
||||||
connect(m_toggleMenubarAction, &QAction::toggled, this, [cmd](bool visible) {
|
toggleMenubarAction.setDefaultKeySequence(Tr::tr("Ctrl+Alt+M"));
|
||||||
|
toggleMenubarAction.addToContainer(Constants::M_VIEW, Constants::G_VIEW_VIEWS);
|
||||||
|
toggleMenubarAction.addOnToggled(this, [](bool visible) {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
|
const QString keys = ActionManager::command(Constants::TOGGLE_MENUBAR)
|
||||||
|
->keySequence().toString(QKeySequence::NativeText);
|
||||||
CheckableMessageBox::information(Core::ICore::dialogParent(),
|
CheckableMessageBox::information(Core::ICore::dialogParent(),
|
||||||
Tr::tr("Hide Menu Bar"),
|
Tr::tr("Hide Menu Bar"),
|
||||||
Tr::tr("This will hide the menu bar completely. "
|
Tr::tr("This will hide the menu bar completely. "
|
||||||
"You can show it again by typing %1.")
|
"You can show it again by typing %1.")
|
||||||
.arg(cmd->keySequence().toString(
|
.arg(keys),
|
||||||
QKeySequence::NativeText)),
|
|
||||||
Key("ToogleMenuBarHint"));
|
Key("ToogleMenuBarHint"));
|
||||||
}
|
}
|
||||||
globalMenuBar()->setVisible(visible);
|
globalMenuBar()->setVisible(visible);
|
||||||
});
|
});
|
||||||
mview->addAction(cmd, Constants::G_VIEW_VIEWS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerModeSelectorStyleActions();
|
registerModeSelectorStyleActions();
|
||||||
@@ -1975,10 +1977,9 @@ void ICorePrivate::registerDefaultActions()
|
|||||||
|
|
||||||
// About sep
|
// About sep
|
||||||
if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu
|
if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu
|
||||||
auto tmpaction = new QAction(this);
|
ActionBuilder tmpAction(this, "QtCreator.Help.Sep.About");
|
||||||
tmpaction->setSeparator(true);
|
tmpAction.setSeperator(true);
|
||||||
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About");
|
tmpAction.addToContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
|
||||||
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user