refs #883, shortcuts for dock widgets

This commit is contained in:
Klaus Basan
2017-02-18 05:07:01 +01:00
committed by Mathew Sutcliffe
parent c460505d2e
commit abbcd18d82
6 changed files with 16 additions and 9 deletions

View File

@@ -105,7 +105,7 @@ namespace BlackGui
subMenuRestore->setIcon(CIcons::load16());
subMenuResetPositions->setIcon(CIcons::refresh16());
subMenuRestore->addActions(this->getInfoAreaRestoreActions(subMenuRestore));
subMenuDisplay->addActions(this->getInfoAreaSelectActions(subMenuDisplay));
subMenuDisplay->addActions(this->getInfoAreaSelectActions(false, subMenuDisplay));
subMenuResetPositions->addActions(this->getInfoAreaResetPositionActions(subMenuResetPositions));
QSignalMapper *signalMapperToggleFloating = new QSignalMapper(menu);
@@ -205,7 +205,7 @@ namespace BlackGui
return constDockWidgets;
}
QList<QAction *> CInfoArea::getInfoAreaSelectActions(QWidget *parent) const
QList<QAction *> CInfoArea::getInfoAreaSelectActions(bool withShortcut, QWidget *parent) const
{
Q_ASSERT(parent);
int i = 0;
@@ -214,9 +214,16 @@ namespace BlackGui
{
const QPixmap pm = this->indexToPixmap(i);
const QString wt(dockWidgetInfoArea->windowTitleBackup());
static const QString keys("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ");
QAction *action = new QAction(QIcon(pm), wt, parent);
action->setData(i);
action->setObjectName(this->objectName().append(":getInfoAreaSelectActions:").append(wt));
if (withShortcut && i < keys.length())
{
static const QString ks("Ctrl+%1");
action->setShortcut(QKeySequence(ks.arg(keys.at(i))));
}
connect(action, &QAction::triggered, this, &CInfoArea::selectAreaByAction);
actions.append(action);
i++;

View File

@@ -71,8 +71,9 @@ namespace BlackGui
//! Create a list of actions to select the info areas.
//! This could be used in a menu or somewhere else.
//! \param withShortcut automatically add a shortcut
//! \param parent which will own the action (deletion)
QList<QAction *> getInfoAreaSelectActions(QWidget *parent) const;
QList<QAction *> getInfoAreaSelectActions(bool withShortcut, QWidget *parent) const;
//! Create a list of actions to select the info areas and toogle its floating state.
//! This could be used in a menu or somewhere else.
@@ -272,7 +273,6 @@ namespace BlackGui
//! Tab bar index changed
void ps_onTabBarIndexChanged(int tabBarIndex);
};
} // namespace