Files
qelectrotech-source-mirror/sources/ui/configpage/shortcutsconfigpage.h
T
ispyisail 896c38435d Add icons, menu locations, key search and copy to the Shortcuts page
The Shortcuts page now shows:
- each command's icon, and a Menu column saying where it is
  ("Projet › Scripts"); the text filter matches that too
- a category filter beside the existing Bound/Unbound/Conflicts one
- "Rechercher par touche": press a key combination and only the
  commands using it are listed, however the key is spelled in the
  user's language. A key also finds the two-key shortcuts it starts.
- "Copier la liste": the shown rows go on the clipboard as
  tab-separated text with a header, so they paste into a spreadsheet
  one cell per column

ShortcutManager::ShortcutInfo carries the icon and the first live
QAction so the page needs no second registry.

New test tst_shortcutspage covers the menu path, the columns, both
filters and the copied text.

Second stage of discussion #1319.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 08:17:16 +13:00

95 lines
2.3 KiB
C++

/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHORTCUTSCONFIGPAGE_H
#define SHORTCUTSCONFIGPAGE_H
#include "configpage.h"
#include <QKeySequence>
class QAction;
class QComboBox;
class QKeySequenceEdit;
class QLabel;
class QLineEdit;
class QTreeWidget;
class QTreeWidgetItem;
/**
@brief The ShortcutsConfigPage class
Configuration page listing every shortcut registered with ShortcutManager,
letting the user rebind, reset and search them. Bindings are only
persisted (via ShortcutManager::setSequence()) when applyConf() runs, i.e.
when the user validates the surrounding ConfigDialog.
*/
class ShortcutsConfigPage : public ConfigPage
{
Q_OBJECT
public:
explicit ShortcutsConfigPage(QWidget *parent = nullptr);
~ShortcutsConfigPage() override;
void applyConf() override;
QString title() const override;
QIcon icon() const override;
static QString menuPath(const QAction *action);
QString listAsText() const;
private slots:
void filterRows(const QString &filter_text);
void quickFilterChanged(int index);
void checkConflicts();
void resetAllRows();
void copyList();
private:
enum QuickFilter {
ShowAll = 0,
BoundOnly,
UnboundOnly,
ConflictsOnly
};
struct Row {
QString id;
QString category;
QString description;
QString menu_path;
QKeySequence default_sequence;
QKeySequenceEdit *edit;
QTreeWidgetItem *item;
bool conflicted;
};
void populateTable();
void applyFilter();
void resetRow(int row_index);
QLineEdit *m_filter_edit;
QComboBox *m_quick_filter;
QComboBox *m_category_filter;
QKeySequenceEdit *m_key_search;
QLabel *m_count_label;
QTreeWidget *m_tree;
QList<Row> m_rows;
};
#endif // SHORTCUTSCONFIGPAGE_H