Skip to content

Commit

Permalink
feat: add settings for default search state (#743), increase max inde…
Browse files Browse the repository at this point in the history
…xing buffer (#745), add bold fonts (#741)
  • Loading branch information
variar committed Nov 23, 2024
1 parent 22fc3ca commit 59c26d5
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 83 deletions.
19 changes: 19 additions & 0 deletions src/settings/include/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ class Configuration final : public Persistable<Configuration> {
{
searchIgnoreCase_ = ignoreCase;
}
bool isSearchLogicalCombiningDefault() const
{
return searchLogicalCombining_;
}
void setSearchLogicalCombiningDefault( bool logicalCombining )
{
searchLogicalCombining_ = logicalCombining;
}
QList<int> splitterSizes() const
{
return splitterSizes_;
Expand Down Expand Up @@ -382,6 +390,15 @@ class Configuration final : public Persistable<Configuration> {
forceFontAntialiasing_ = force;
}

bool useBoldFont() const
{
return useBoldFont_;
}
void setUseBoldFont( bool bold )
{
useBoldFont_ = bold;
}

bool enableQtHighDpi() const
{
return enableQtHighDpi_;
Expand Down Expand Up @@ -550,6 +567,7 @@ class Configuration final : public Persistable<Configuration> {
// Default settings for new views
bool searchAutoRefresh_ = false;
bool searchIgnoreCase_ = false;
bool searchLogicalCombining_ = false;
QList<int> splitterSizes_;

// Performance settings
Expand All @@ -574,6 +592,7 @@ class Configuration final : public Persistable<Configuration> {

bool forceFontAntialiasing_ = false;
bool enableQtHighDpi_ = true;
bool useBoldFont_ = false;

int scaleFactorRounding_ = 1;

Expand Down
8 changes: 8 additions & 0 deletions src/settings/src/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ void Configuration::retrieveFromStorage( QSettings& settings )
forceFontAntialiasing_
= settings.value( "mainFont.antialiasing", DefaultConfiguration.forceFontAntialiasing_ )
.toBool();
useBoldFont_
= settings.value( "mainFont.bold", DefaultConfiguration.useBoldFont_ )
.toBool();

language_ = settings.value( "view.language", DefaultConfiguration.language_ ).toString();

Expand Down Expand Up @@ -295,6 +298,9 @@ void Configuration::retrieveFromStorage( QSettings& settings )
searchIgnoreCase_
= settings.value( "defaultView.searchIgnoreCase", DefaultConfiguration.searchIgnoreCase_ )
.toBool();
searchLogicalCombining_
= settings.value( "defaultView.searchLogicalCombining", DefaultConfiguration.searchLogicalCombining_ )
.toBool();

defaultEncodingMib_
= settings.value( "defaultView.encodingMib", DefaultConfiguration.defaultEncodingMib_ )
Expand Down Expand Up @@ -353,6 +359,7 @@ void Configuration::saveToStorage( QSettings& settings ) const
settings.setValue( "mainFont.family", fi.family() );
settings.setValue( "mainFont.size", fi.pointSize() );
settings.setValue( "mainFont.antialiasing", forceFontAntialiasing_ );
settings.setValue( "mainFont.bold", useBoldFont_ );

settings.setValue( "regexpType.engine", static_cast<int>( regexpEngine_ ) );

Expand Down Expand Up @@ -413,6 +420,7 @@ void Configuration::saveToStorage( QSettings& settings ) const

settings.setValue( "defaultView.searchAutoRefresh", searchAutoRefresh_ );
settings.setValue( "defaultView.searchIgnoreCase", searchIgnoreCase_ );
settings.setValue( "defaultView.searchLogicalCombining", searchLogicalCombining_ );
settings.setValue( "defaultView.encodingMib", defaultEncodingMib_ );

QList<QVariant> splitterSizes;
Expand Down
5 changes: 0 additions & 5 deletions src/ui/include/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ class MainWindow : public QMainWindow {
// or an error recovery when loading is finished
void handleLoadingFinished( LoadingStatus status );

// Save the new state as default setting when a crawler
// is changing their view options.
void handleSearchRefreshChanged( bool isRefreshing );
void handleMatchCaseChanged( bool matchCase );

// Update quick find searchable
void handleFilteredViewChanged();

Expand Down
105 changes: 68 additions & 37 deletions src/ui/include/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,27 @@
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="2">
<widget class="QPushButton" name="quickFindColorButton">
<item row="0" column="2">
<widget class="QPushButton" name="mainSearchColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="mainSearchBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="1" column="1">
<widget class="QCheckBox" name="highlightMainSearchCheckBox">
<property name="text">
<string>Highlight matches</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="incrementalCheckBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Incremental</string>
</property>
</widget>
</item>
Expand All @@ -71,27 +78,31 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<item row="1" column="2">
<widget class="QCheckBox" name="variateHighlightCheckBox">
<property name="text">
<string>QuickFind search type: </string>
<string>Variate highlight</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="highlightMainSearchCheckBox">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Highlight matches</string>
<string>Main search type: </string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="incrementalCheckBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="autoRunSearchOnAddCheckBox">
<property name="text">
<string>Run search on add or replace pattern</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Incremental</string>
<string>QuickFind search type: </string>
</property>
</widget>
</item>
Expand All @@ -102,24 +113,20 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="mainSearchColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="variateHighlightCheckBox">
<property name="text">
<string>Variate highlight</string>
<item row="0" column="1">
<widget class="QComboBox" name="mainSearchBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<item row="4" column="2">
<widget class="QPushButton" name="quickFindColorButton">
<property name="text">
<string>Main search type: </string>
<string/>
</property>
</widget>
</item>
Expand All @@ -133,10 +140,24 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="autoRunSearchOnAddCheckBox">
<item row="2" column="0">
<widget class="QCheckBox" name="caseSensitiveCheckBox">
<property name="text">
<string>Run search on add or replace pattern</string>
<string>Case sensitive</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="logicalCombiningCheckBox">
<property name="text">
<string>Logical combining</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="autoRefreshCheckBox">
<property name="text">
<string>Auto refresh</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -280,6 +301,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="boldFontCheckBox">
<property name="text">
<string>Use bold font (if supported by selected font)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="wrapTextCheckBox">
<property name="text">
Expand Down Expand Up @@ -714,6 +742,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>256</number>
</property>
</widget>
</item>
<item row="2" column="0">
Expand Down
33 changes: 12 additions & 21 deletions src/ui/src/crawlerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const QPalette CrawlerWidget::ErrorPalette( Qt::darkYellow );

// Implementation of the view context for the CrawlerWidget
class CrawlerWidgetContext : public ViewContextInterface {
public:
public:
// Construct from the stored string representation
explicit CrawlerWidgetContext( const QString& string );
// Construct from the value passsed
Expand Down Expand Up @@ -142,11 +142,11 @@ class CrawlerWidgetContext : public ViewContextInterface {
return marks_;
}

private:
private:
void loadFromString( const QString& string );
void loadFromJson( const QString& json );

private:
private:
QList<int> sizes_;

bool ignoreCase_;
Expand Down Expand Up @@ -631,6 +631,8 @@ void CrawlerWidget::applyConfiguration()
font.setStyleStrategy( QFont::PreferAntialias );
}

font.setBold( config.useBoldFont() );

if ( config.hideAnsiColorSequences() ) {
logData_->setPrefilter( AnsiColorSequenceRegex );
}
Expand Down Expand Up @@ -1159,6 +1161,7 @@ void CrawlerWidget::setup()
searchRefreshButton_->setChecked( config.isSearchAutoRefreshDefault() );
matchCaseButton_->setChecked( !config.isSearchIgnoreCaseDefault() );
useRegexpButton_->setChecked( config.mainRegexpType() == SearchRegexpType::ExtendedRegexp );
booleanButton_->setChecked( config.isSearchLogicalCombiningDefault() );

// Manually call the handler as it is not called when changing the state programmatically
searchRefreshChangedHandler( searchRefreshButton_->isChecked() );
Expand Down Expand Up @@ -1440,39 +1443,27 @@ void CrawlerWidget::registerShortcuts()

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

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

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

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

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

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

ShortcutAction::registerShortcut( configuredShortcuts, shortcuts_, this,
Qt::WidgetWithChildrenShortcut,
Expand Down
20 changes: 0 additions & 20 deletions src/ui/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,6 @@ MainWindow::MainWindow( WindowSession session )
signalMux_.connect( SIGNAL( loadingFinished( LoadingStatus ) ), this,
SLOT( handleLoadingFinished( LoadingStatus ) ) );

// Register for checkbox changes
signalMux_.connect( SIGNAL( searchRefreshChanged( bool ) ), this,
SLOT( handleSearchRefreshChanged( bool ) ) );
signalMux_.connect( SIGNAL( matchCaseChanged( bool ) ), this,
SLOT( handleMatchCaseChanged( bool ) ) );

signalMux_.connect( SIGNAL( filteredViewChanged() ), this,
SLOT( handleFilteredViewChanged() ) );

Expand Down Expand Up @@ -1422,20 +1416,6 @@ void MainWindow::handleLoadingFinished( LoadingStatus status )
// mainTabWidget_.setEnabled( true );
}

void MainWindow::handleSearchRefreshChanged( bool isRefreshing )
{
auto& config = Configuration::get();
config.setSearchAutoRefreshDefault( isRefreshing );
config.save();
}

void MainWindow::handleMatchCaseChanged( bool matchCase )
{
auto& config = Configuration::get();
config.setSearchIgnoreCaseDefault( !matchCase );
config.save();
}

void MainWindow::handleFilteredViewChanged()
{
int currentIndex = mainTabWidget_.currentIndex();
Expand Down
Loading

0 comments on commit 59c26d5

Please sign in to comment.