Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ set(SOURCES
CutterApplication.cpp
dialogs/RizinPluginsDialog.cpp
widgets/CutterDockWidget.cpp
widgets/CutterTreeWidget.cpp
widgets/GraphWidget.cpp
widgets/OverviewWidget.cpp
common/JsonModel.cpp
Expand Down Expand Up @@ -169,6 +168,9 @@ set(SOURCES
widgets/SearchableDockWidget.cpp
common/CutterSearchable.cpp
widgets/SearchableTextEdit.cpp
widgets/ItemCountLineEdit.cpp
widgets/AbstractFilterView.cpp
dialogs/preferences/InterfaceOptionsWidget.cpp
)
set(HEADER_FILES
core/Cutter.h
Expand Down Expand Up @@ -242,7 +244,6 @@ set(HEADER_FILES
widgets/SearchWidget.h
dialogs/RizinPluginsDialog.h
widgets/CutterDockWidget.h
widgets/CutterTreeWidget.h
widgets/GraphWidget.h
widgets/OverviewWidget.h
common/JsonModel.h
Expand Down Expand Up @@ -347,6 +348,9 @@ set(HEADER_FILES
widgets/SearchableDockWidget.h
common/CutterSearchable.h
widgets/SearchableTextEdit.h
widgets/ItemCountLineEdit.h
widgets/AbstractFilterView.h
dialogs/preferences/InterfaceOptionsWidget.h
)
set(UI_FILES
dialogs/AboutDialog.ui
Expand Down Expand Up @@ -428,6 +432,7 @@ set(UI_FILES
dialogs/RegisterProfileDialog.ui
dialogs/EditRegProfileDialog.ui
widgets/SearchBarWidget.ui
dialogs/preferences/InterfaceOptionsWidget.ui
)
set(QRC_FILES
resources.qrc
Expand Down
33 changes: 33 additions & 0 deletions src/common/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,3 +947,36 @@ bool Configuration::getNavBarLegendEnabled()
{
return s.value("navBarLegend").toBool();
}

void Configuration::setShowQuickFilter(bool show)
{
s.setValue("showQuickFilter", show);
emit quickFilterToggled(show);
}

bool Configuration::getShowQuickFilter() const
{
return s.value("showQuickFilter", true).toBool();
}

void Configuration::setItemCountVisible(bool visible)
{
s.setValue("itemCountVisible", visible);
emit itemCountToggled(visible);
}

bool Configuration::getItemCountVisible() const
{
return s.value("itemCountVisible", true).toBool();
}

void Configuration::setItemCountAutoHide(bool value)
{
s.value("autoHideItemCount", value);
emit itemCountAutoHideToggled(value);
}

bool Configuration::getItemCountAutoHide() const
{
return s.value("autoHideItemCount", false).toBool();
}
41 changes: 41 additions & 0 deletions src/common/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,53 @@ class CUTTER_EXPORT Configuration : public QObject
*/
bool getNavBarLegendEnabled();

/**
* @brief Enable or disable the display of the Quick Filter by default in views
* @param show Set to true to show the Quick Filter by default
*/
void setShowQuickFilter(bool show);

/**
* @brief Check if the Quick Filter is set to be shown by default
* @return True if the Quick Filter is shown by default, false otherwise
*/
bool getShowQuickFilter() const;

/**
* @brief Enable or disable the visibility of the item count label within the Quick Filter
* @param visible Set to true to show the item count, false to hide it
*/
void setItemCountVisible(bool visible);

/**
* @brief Check if the item count label within the Quick Filter is set to be visible
* @return True if the item count is visible, false otherwise
*/
bool getItemCountVisible() const;

/**
* @brief Enable or disable the item count label automatically hiding on overflow within the
* Quick Filter
* @param value Set to true to auto hide the item count, false otherwise
*/
void setItemCountAutoHide(bool value);

/**
* @brief Check if the item count label within the Quick Filter is set to automatically hide on
* overflow
* @return True if the item count is set to auto hide, false otherwise
*/
bool getItemCountAutoHide() const;

public slots:
void refreshFont();
signals:
void fontsUpdated();
void colorsUpdated();
void interfaceThemeChanged();
void quickFilterToggled(bool show);
void itemCountToggled(bool visible);
void itemCountAutoHideToggled(bool value);
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
void kSyntaxHighlightingThemeChanged();
#endif
Expand Down
1 change: 1 addition & 0 deletions src/common/CutterSearchable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void CutterSearchableHelper::setupConnections(QWidget *parent, SearchBarWidget *
[searchable]() { searchable->searchBarShown(); });

QShortcut *shortcut = Shortcuts()->makeQShortcut("Search.toggle", parent);
shortcut->setContext(Qt::WidgetWithChildrenShortcut);
QObject::connect(shortcut, &QShortcut::activated, parent, [=]() {
if (searchBar->isVisible()) {
if (searchBar->hasFocus()) {
Expand Down
10 changes: 6 additions & 4 deletions src/dialogs/TypesVariablesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,11 @@ bool TypesVariablesProxyModel::lessThan(const QModelIndex &left, const QModelInd
}

TypesVariablesDialog::TypesVariablesDialog(QWidget *parent, const QString &typeName)
: QDialog(parent), ui(new Ui::TypesVariablesDialog), tree(new CutterTreeWidget(this))
: QDialog(parent), ui(new Ui::TypesVariablesDialog)
{
ui->setupUi(this);
setWindowTitle(tr("Variables: %1").arg(typeName));

tree->addStatusBar(ui->verticalLayout);

sourceModel = new TypesVariablesModel(this);
proxyModel = new TypesVariablesProxyModel(this);
proxyModel->setSourceModel(sourceModel);
Expand All @@ -158,7 +156,7 @@ TypesVariablesDialog::TypesVariablesDialog(QWidget *parent, const QString &typeN
scopeCombo->addItem(tr("Globals Only"), GLOBAL);
scopeCombo->addItem(tr("Locals Only"), LOCAL);

auto updateCount = [this]() { tree->showItemsNumber(proxyModel->rowCount()); };
auto updateCount = [this]() { ui->quickFilterView->setItemCount(proxyModel->rowCount()); };

connect(ui->quickFilterView, &ComboQuickFilterView::filterTextChanged, proxyModel,
&TypesVariablesProxyModel::setFilterFixedString);
Expand Down Expand Up @@ -204,6 +202,10 @@ void TypesVariablesDialog::refreshModel(const QString &typeName)
}

sourceModel->updateVariables(newVariables);

// set the initial item count
ui->quickFilterView->setItemCount(proxyModel->rowCount());

qhelpers::adjustColumns(ui->treeView, TypesVariablesModel::Column::COUNT, 0);
}

Expand Down
2 changes: 0 additions & 2 deletions src/dialogs/TypesVariablesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <QDialog>
#include <QSortFilterProxyModel>
#include <QAbstractTableModel>
#include "CutterTreeWidget.h"

#include "core/Cutter.h"

Expand Down Expand Up @@ -93,7 +92,6 @@ private slots:
std::unique_ptr<Ui::TypesVariablesDialog> ui;
TypesVariablesModel *sourceModel;
TypesVariablesProxyModel *proxyModel;
CutterTreeWidget *tree;
};

#endif // TYPESVARIABLESDIALOG_H
33 changes: 33 additions & 0 deletions src/dialogs/preferences/InterfaceOptionsWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "InterfaceOptionsWidget.h"
#include "ui_InterfaceOptionsWidget.h"

#include "PreferencesDialog.h"
#include "Configuration.h"

InterfaceOptionsWidget::InterfaceOptionsWidget(PreferencesDialog *dialog)
: QDialog(dialog), ui(new Ui::InterfaceOptionsWidget)
{
ui->setupUi(this);

setUpQuickFilter();
}

InterfaceOptionsWidget::~InterfaceOptionsWidget() {}

void InterfaceOptionsWidget::setUpQuickFilter()
{
ui->quickFilterCheckBox->setChecked(Config()->getShowQuickFilter());
connect(ui->quickFilterCheckBox, &QCheckBox::toggled, this,
[](bool checked) { Config()->setShowQuickFilter(checked); });

ui->itemCountCheckBox->setChecked(Config()->getItemCountVisible());
connect(ui->itemCountCheckBox, &QCheckBox::toggled, this, [this](bool checked) {
Config()->setItemCountVisible(checked);
ui->hideItemCountCheckBox->setEnabled(checked);
});

connect(ui->hideItemCountCheckBox, &QCheckBox::toggled, this,
[](bool checked) { Config()->setItemCountAutoHide(checked); });
ui->hideItemCountCheckBox->setChecked(Config()->getItemCountAutoHide());
ui->hideItemCountCheckBox->setEnabled(ui->itemCountCheckBox->isChecked());
}
31 changes: 31 additions & 0 deletions src/dialogs/preferences/InterfaceOptionsWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef INTERFACEOPTIONSWIDGET_H
#define INTERFACEOPTIONSWIDGET_H

#include <QDialog>
#include <memory>

namespace Ui {
class InterfaceOptionsWidget;
};

class PreferencesDialog;

/**
* @brief Widget containing options for interface related settings
*
* Uses groupboxes to seperate options available for different widgets/views
* Groupboxes must be in alphabetical order according to their titles
*/
class InterfaceOptionsWidget : public QDialog
{
public:
explicit InterfaceOptionsWidget(PreferencesDialog *dialog);
~InterfaceOptionsWidget();

private:
std::unique_ptr<Ui::InterfaceOptionsWidget> ui;

void setUpQuickFilter();
};

#endif // INTERFACEOPTIONSWIDGET_H
107 changes: 107 additions & 0 deletions src/dialogs/preferences/InterfaceOptionsWidget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InterfaceOptionsWidget</class>
<widget class="QWidget" name="InterfaceOptionsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>633</width>
<height>361</height>
</rect>
</property>
<property name="windowTitle">
<string>Interface</string>
</property>
<layout class="QVBoxLayout" name="mainVerticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>633</width>
<height>361</height>
</rect>
</property>
<layout class="QVBoxLayout" name="scrollLayout">
<item>
<widget class="QGroupBox" name="quickFilterGroupBox">
<property name="title">
<string>Quick FIlter</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>24</number>
</property>
<item>
<widget class="QCheckBox" name="quickFilterCheckBox">
<property name="text">
<string>Show Quick Filter by default</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="itemCountCheckBox">
<property name="text">
<string>Show Item Count in Quick Filter</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="hideItemCountCheckBox">
<property name="text">
<string>Hide Item Count on overflow</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
5 changes: 4 additions & 1 deletion src/dialogs/preferences/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "InitializationFileEditor.h"
#include "AnalysisOptionsWidget.h"
#include "ShortcutOptionsWidget.h"
#include "InterfaceOptionsWidget.h"

#include "PreferenceCategory.h"

Expand Down Expand Up @@ -38,7 +39,8 @@ PreferencesDialog::PreferencesDialog(QWidget *parent)
{ tr("Initialization Script"), new InitializationFileEditor(this),
QIcon(":/img/icons/initialization.svg") },
{ tr("Analysis"), new AnalysisOptionsWidget(this), QIcon(":/img/icons/cog_light.svg") },
{ tr("Shortcuts"), new ShortcutOptionsWidget(this), QIcon(":/img/icons/edit_light.svg") }
{ tr("Shortcuts"), new ShortcutOptionsWidget(this), QIcon(":/img/icons/edit_light.svg") },
{ tr("Interface"), new InterfaceOptionsWidget(this), QIcon(":/img/icons/layout.svg") }
};

for (auto &c : prefs) {
Expand Down Expand Up @@ -98,6 +100,7 @@ void PreferencesDialog::chooseThemeIcons()
{ QStringLiteral("Plugins"), QStringLiteral("plugins.svg") },
{ QStringLiteral("Initialization Script"), QStringLiteral("initialization.svg") },
{ QStringLiteral("Analysis"), QStringLiteral("cog_light.svg") },
{ QStringLiteral("Interface"), QStringLiteral("layout.svg") },
};
QList<QPair<void *, QString>> supportedIconsNames;

Expand Down
Loading
Loading