16 #include <QHBoxLayout>
17 #include <QKeySequence>
20 #include <QMessageBox>
21 #include <QNonConstOverload>
22 #include <QStackedWidget>
24 #include <QVBoxLayout>
26 #include "../../util/btconnect.h"
27 #include "../../util/cresmgr.h"
28 #include "../bibletime.h"
29 #include "../displaywindow/btactioncollection.h"
30 #include "../displaywindow/cbiblereadwindow.h"
31 #include "../displaywindow/cbookreadwindow.h"
32 #include "../displaywindow/ccommentaryreadwindow.h"
33 #include "../displaywindow/cdisplaywindow.h"
34 #include "../displaywindow/clexiconreadwindow.h"
35 #include "../messagedialog.h"
43 QVBoxLayout *mainLayout =
new QVBoxLayout(
this);
45 QHBoxLayout* layoutForWindowTypeChooser =
new QHBoxLayout();
46 mainLayout->addLayout(layoutForWindowTypeChooser);
62 auto const initShortcutEditor =
65 char const *
const groupName)
77 [
this, &windowType](QString
const &
actionName,
78 QKeySequence
const & keys)
86 QList<WindowType *> list;
87 list.append(&m_application);
88 list.append(&m_general);
89 if ((&windowType == &m_application)
90 || (&windowType == &m_general))
92 list.append(&m_bible);
93 list.append(&m_commentary);
94 list.append(&m_lexicon);
97 list.append(&windowType);
99 QStringList conflicts;
100 auto const conflictTr = tr(
"\"%1\" in the \"%2\" group");
101 for (
auto const *
const windowType2 : list)
103 windowType2->keyChooser->findConflictWithKeys(
106 conflicts.append(conflictTr
107 .arg(std::move(conflict))
108 .arg(windowType2->title));
110 if (!conflicts.isEmpty()) {
111 if (message::showQuestion(
113 tr(
"Shortcut conflict detected"),
114 QStringLiteral(
"%1<ul><li>%2</li></ul>%3")
116 tr(
"The shortcut \"%1\" you want to "
117 "assign to \"%2\" in the \"%3\" "
118 "group conflicts with the following "
122 .arg(keys.toString())
124 .arg(windowType.title),
125 conflicts.join(QStringLiteral(
"</li><li>")),
126 tr(
"Do you want to clear these conflicting "
127 "shortcuts and continue?")),
128 QMessageBox::Yes | QMessageBox::No,
129 QMessageBox::Yes) == QMessageBox::Yes)
132 for (auto const * const windowType2 : list)
133 windowType2->keyChooser->clearConflictWithKeys(
136 windowType.keyChooser->changeShortcutInDialog(keys);
139 windowType.
keyChooser->changeShortcutInDialog(keys);
143 initShortcutEditor(m_application,
145 "Application shortcuts");
146 initShortcutEditor(m_general,
148 "Displaywindow shortcuts");
149 initShortcutEditor(m_bible,
152 initShortcutEditor(m_commentary,
154 "Commentary shortcuts");
155 initShortcutEditor(m_lexicon,
157 "Lexicon shortcuts");
158 initShortcutEditor(m_book,
162 mainLayout->addWidget(m_keyChooserStack);
163 m_keyChooserStack->setCurrentIndex(m_typeChooser->currentIndex());
165 m_typeChooser->setFocus(Qt::MouseFocusReason);
static void insertKeyboardActions(BtActionCollection *const a)
void readShortcuts(QString const &group)
Read shortcuts from config.
void writeShortcuts(QString const &group) const
Write shortcuts to config.
void setHeaderText(QString const &headerText)
void keyChangeRequest(QString const &actionName, QKeySequence const &keys)
QStackedWidget * m_keyChooserStack
QComboBox * m_typeChooser
QLabel * m_actionGroupLabel
void save() const final override
CAcceleratorSettingsPage(CConfigurationDialog *parent=nullptr)
static void insertKeyboardActions(BtActionCollection *const a)
static void insertKeyboardActions(BtActionCollection *const a)
static void insertKeyboardActions(BtActionCollection *const a)
static void insertKeyboardActions(BtActionCollection *a)
QPointer< BtShortcutsEditor > keyChooser
BtActionCollection * actionCollection