123 :
QWidget(parent), m_dlg(new
BtShortcutsDialog(this)), m_table(nullptr), m_shortcutChooser(nullptr), m_noneButton(nullptr), m_defaultButton(nullptr),
124 m_customButton(nullptr), m_defaultLabelValue(nullptr), m_currentRow(-1) {
126 QVBoxLayout *
const vBox =
new QVBoxLayout(
this);
130 m_table =
new QTableWidget{
this};
132 m_table->setAlternatingRowColors(
true);
133 m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
134 m_table->setSelectionMode(QAbstractItemView::SingleSelection);
135 m_table->setHorizontalHeaderLabels({tr(
"Action"),
138 m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
139 m_table->horizontalHeader()->resizeSection(0, 180);
140 m_table->horizontalHeader()->resizeSection(1, 100);
141 m_table->horizontalHeader()->setStretchLastSection(
true);
142 m_table->verticalHeader()->setVisible(
false);
150 new QGroupBox(tr(
"Shortcut for selected action name"),
this);
155 QHBoxLayout *
const hLayout =
new QHBoxLayout();
156 vLayout->addLayout(hLayout);
181 hLayout->addItem(
new QSpacerItem(1,
183 QSizePolicy::Expanding,
184 QSizePolicy::Minimum));
187 QHBoxLayout *
const hLayout =
new QHBoxLayout();
188 vLayout->addLayout(hLayout);
195 hLayout->addItem(
new QSpacerItem(1,
197 QSizePolicy::Expanding,
198 QSizePolicy::Minimum));
202 for (
auto *
const action : collection->
actions()) {
203 int const count =
m_table->rowCount();
208 new BtShortcutsEditorItem(
213 m_table->setItem(count, 0, item);
220 QList<QKeySequence> keys = action->shortcuts();
225 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
226 item->setToolTip(tr(
"Select to change key"));
227 if (keys.count() > 0)
228 item->setText(keys[0].toString());
229 m_table->setItem(count, 1, item);
239 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
240 item->setToolTip(tr(
"Select to change key"));
241 if (keys.count() > 1)
242 item->setText(keys[1].toString());
243 m_table->setItem(count, 2, item);
254 [
this](QKeySequence
const & keys) {
273 auto const defaultKeys = item.getDefaultKeys();
278 QString shortcut = item1->text();
281 QString alternate = item2->text();
283 QString bothKeys = shortcut;
284 if (!alternate.isEmpty())
285 bothKeys = bothKeys + QStringLiteral(
"; ") + alternate;
288 if ( bothKeys == defaultKeys.toString())
290 else if (bothKeys.isEmpty())
336 int code =
m_dlg->exec();
337 if (code == QDialog::Accepted) {
340 if (newPriKeys == newAltKeys)
341 newAltKeys = QString();
343 item.setFirstHotkey(newPriKeys);
344 item.setSecondHotkey(newAltKeys);
357 auto const keyString(keys.toString());
358 for (
int row = 0; row <
m_table->rowCount(); row++) {
359 auto & item = *getShortcutsEditor(*
m_table, row);
360 if (
m_table->item(row, 1)->text() == keyString) {
361 m_table->item(row, 1)->setText(QString());
362 item.setFirstHotkey();
364 if (
m_table->item(row, 2)->text() == keyString) {
365 m_table->item(row, 2)->setText(QString());
366 item.setSecondHotkey();