Skip to content

Commit

Permalink
feat: Add some shortcuts (#676)
Browse files Browse the repository at this point in the history
* refact: modify the default shortcut storage structure

* feat: add some shortcut
  • Loading branch information
nowhszh authored Nov 25, 2024
1 parent 51a1b18 commit 7db2a11
Show file tree
Hide file tree
Showing 4 changed files with 616 additions and 302 deletions.
32 changes: 24 additions & 8 deletions src/settings/include/shortcuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class QShortcut;

struct ShortcutAction {
static constexpr auto CrawlerChangeVisibilityForward = "crawler.change_visibility_type";
static constexpr auto CrawlerChangeVisibilityBackward = "crawler.change_visibility_type_backward";
static constexpr auto CrawlerChangeVisibilityToMarksAndMatches = "crawler.change_visibility_to_marks_and_matches";
static constexpr auto CrawlerChangeVisibilityBackward
= "crawler.change_visibility_type_backward";
static constexpr auto CrawlerChangeVisibilityToMarksAndMatches
= "crawler.change_visibility_to_marks_and_matches";
static constexpr auto CrawlerChangeVisibilityToMarks = "crawler.change_visibility_to_marks";
static constexpr auto CrawlerChangeVisibilityToMatches = "crawler.change_visibility_to_matches";
static constexpr auto CrawlerIncreseTopViewSize = "crawler.increase_top_view_size";
Expand All @@ -52,6 +54,10 @@ struct ShortcutAction {
static constexpr auto MainWindowCloseFile = "mainwindow.close_file";
static constexpr auto MainWindowCloseAll = "mainwindow.close_all";
static constexpr auto MainWindowQuit = "mainwindow.quit";
static constexpr auto MainWindowFullScreen = "mainwindow.fullscreen";
static constexpr auto MainWindowMax = "mainwindow.max_window";
static constexpr auto MainWindowMin = "mainwindow.min_window";
static constexpr auto MainWindowPreference = "mainwindow.preference";
static constexpr auto MainWindowCopy = "mainwindow.copy_selection";
static constexpr auto MainWindowSelectAll = "mainwindow.select_all";
static constexpr auto MainWindowOpenQf = "mainwindow.open_qf";
Expand Down Expand Up @@ -110,21 +116,28 @@ struct ShortcutAction {
static constexpr auto LogViewAddNextColorLabel = "logview.add_next_color_label";

static constexpr auto LogViewSendSelectionToScratchpad = "logview.send_selection_to_scratchpad";
static constexpr auto LogViewReplaceScratchpadWithSelection = "logview.replace_scratchpad_with_selection";
static constexpr auto LogViewReplaceScratchpadWithSelection
= "logview.replace_scratchpad_with_selection";

static constexpr auto LogViewAddToSearch = "logview.add_to_search";
static constexpr auto LogViewExcludeFromSearch = "logview.exclude_from_search";
static constexpr auto LogViewReplaceSearch = "logview.replace_search";
static constexpr auto LogViewSelectLinesUp = "logview.select_lines_up";
static constexpr auto LogViewSelectLinesDown = "logview.select_lines_down";

static const std::map<std::string, QStringList>& defaultShortcuts();

static QStringList defaultShortcuts( const std::string& action );
private:
struct ShortcutDesc {
QString name;
QStringList keySequence;
};

static QString actionName( const std::string& action );
public:
using Shortcut = ShortcutDesc;
using ShortcutList = std::map<std::string, Shortcut>; // <action, shortcut>
using ConfiguredShortcuts = std::map<std::string, QStringList>; // <action,keySequence>

static const ShortcutList& defaultShortcutList();

using ConfiguredShortcuts = std::map<std::string, QStringList>;
static void registerShortcut( const ConfiguredShortcuts& configuredShortcuts,
std::map<QString, QShortcut*>& shortcutsStorage,
QWidget* shortcutsParent, Qt::ShortcutContext context,
Expand All @@ -137,6 +150,9 @@ struct ShortcutAction {

static QList<QKeySequence> shortcutKeys( const std::string& action,
const ConfiguredShortcuts& configuredShortcuts );

private:
static QStringList defaultShortcutKeys( const std::string& action );
};

#endif
Loading

0 comments on commit 7db2a11

Please sign in to comment.