Skip to content

Commit

Permalink
feat: Add shortcuts for crawler toggle buttons (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
boki1 authored Nov 18, 2024
1 parent f8e8547 commit 7397f7f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/settings/include/shortcuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ struct ShortcutAction {
static constexpr auto CrawlerChangeVisibilityToMatches = "crawler.change_visibility_to_matches";
static constexpr auto CrawlerIncreseTopViewSize = "crawler.increase_top_view_size";
static constexpr auto CrawlerDecreaseTopViewSize = "crawler.decrease_top_view_size";
static constexpr auto CrawlerEnableCaseMatching = "crawler.enable_case_matching";
static constexpr auto CrawlerEnableRegex = "crawler.enable_regex";
static constexpr auto CrawlerEnableInverseMatching = "crawler.enable_inverse_matching";
static constexpr auto CrawlerEnableRegexCombining = "crawler.enable_regex_combining";
static constexpr auto CrawlerEnableAutoRefresh = "crawler.enable_auto_refresh";
static constexpr auto CrawlerKeepResults = "crawler.enable_keep_results";

static constexpr auto QfFindNext = "qf.find_next";
static constexpr auto QfFindPrev = "qf.find_prev";
Expand Down Expand Up @@ -133,4 +139,4 @@ struct ShortcutAction {
const ConfiguredShortcuts& configuredShortcuts );
};

#endif
#endif
20 changes: 19 additions & 1 deletion src/settings/src/shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ const std::map<std::string, QStringList>& ShortcutAction::defaultShortcuts()
QStringList() << QKeySequence( Qt::Key_Plus ).toString() );
shortcuts.emplace( CrawlerDecreaseTopViewSize,
QStringList() << QKeySequence( Qt::Key_Minus ).toString() );
shortcuts.emplace( CrawlerEnableCaseMatching,
QStringList() << QKeySequence( Qt::Key_4 ).toString() );
shortcuts.emplace( CrawlerEnableRegex,
QStringList() << QKeySequence( Qt::Key_5 ).toString() );
shortcuts.emplace( CrawlerEnableInverseMatching,
QStringList() << QKeySequence( Qt::Key_6 ).toString() );
shortcuts.emplace( CrawlerEnableRegexCombining,
QStringList() << QKeySequence( Qt::Key_7 ).toString() );
shortcuts.emplace( CrawlerEnableAutoRefresh,
QStringList() << QKeySequence( Qt::Key_8 ).toString() );
shortcuts.emplace( CrawlerKeepResults,
QStringList() << QKeySequence( Qt::Key_9 ).toString() );

// shortcuts.emplace( QfFindNext, getKeyBindings( QKeySequence::FindNext ) );
// shortcuts.emplace( QfFindPrev, getKeyBindings( QKeySequence::FindPrevious ) );
Expand Down Expand Up @@ -220,6 +232,12 @@ QString ShortcutAction::actionName( const std::string& action )
QApplication::tr( "Change filtered lines visibility to matches" ) );
shortcuts.emplace( CrawlerIncreseTopViewSize, QApplication::tr( "Increase main view" ) );
shortcuts.emplace( CrawlerDecreaseTopViewSize, QApplication::tr( "Decrease main view" ) );
shortcuts.emplace( CrawlerEnableCaseMatching, QApplication::tr( "Enable case matching" ) );
shortcuts.emplace( CrawlerEnableRegex, QApplication::tr( "Enable regex" ) );
shortcuts.emplace( CrawlerEnableInverseMatching, QApplication::tr( "Enable inverse matching" ) );
shortcuts.emplace( CrawlerEnableRegexCombining, QApplication::tr( "Enable regex combining" ) );
shortcuts.emplace( CrawlerEnableAutoRefresh, QApplication::tr( "Enable auto refresh" ) );
shortcuts.emplace( CrawlerKeepResults, QApplication::tr( "Keep search results" ) );

shortcuts.emplace( QfFindNext, QApplication::tr( "QuickFind: Find next" ) );
shortcuts.emplace( QfFindPrev, QApplication::tr( "QuickFind: Find previous" ) );
Expand Down Expand Up @@ -351,4 +369,4 @@ QList<QKeySequence> ShortcutAction::shortcutKeys( const std::string& action,
[]( const QString& hotkeys ) { return QKeySequence( hotkeys ); } );

return shortcuts;
}
}
36 changes: 36 additions & 0 deletions src/ui/src/crawlerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,42 @@ void CrawlerWidget::registerShortcuts()
% visibilityBox_->count() );
} );

ShortcutAction::registerShortcut(
configuredShortcuts, shortcuts_, this, Qt::WidgetWithChildrenShortcut,
ShortcutAction::CrawlerEnableCaseMatching, [ this ]() {
matchCaseButton_->toggle();
} );

ShortcutAction::registerShortcut(
configuredShortcuts, shortcuts_, this, Qt::WidgetWithChildrenShortcut,
ShortcutAction::CrawlerEnableRegex, [ this ]() {
useRegexpButton_->toggle();
} );

ShortcutAction::registerShortcut(
configuredShortcuts, shortcuts_, this, Qt::WidgetWithChildrenShortcut,
ShortcutAction::CrawlerEnableInverseMatching, [ this ]() {
inverseButton_->toggle();
} );

ShortcutAction::registerShortcut(
configuredShortcuts, shortcuts_, this, Qt::WidgetWithChildrenShortcut,
ShortcutAction::CrawlerEnableRegexCombining, [ this ]() {
booleanButton_->toggle();
} );

ShortcutAction::registerShortcut(
configuredShortcuts, shortcuts_, this, Qt::WidgetWithChildrenShortcut,
ShortcutAction::CrawlerEnableAutoRefresh, [ this ]() {
searchRefreshButton_->toggle();
} );

ShortcutAction::registerShortcut(
configuredShortcuts, shortcuts_, this, Qt::WidgetWithChildrenShortcut,
ShortcutAction::CrawlerKeepResults, [ this ]() {
keepSearchResultsButton_->toggle();
} );

ShortcutAction::registerShortcut( configuredShortcuts, shortcuts_, this,
Qt::WidgetWithChildrenShortcut,
ShortcutAction::CrawlerChangeVisibilityBackward, [ this ]() {
Expand Down

0 comments on commit 7397f7f

Please sign in to comment.