Skip to content

Commit

Permalink
Switch to color picker for filters. Merge nickbnf#194 and fix nickbnf…
Browse files Browse the repository at this point in the history
  • Loading branch information
variar committed Jan 30, 2019
1 parent 975c3d7 commit ac754d8
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 151 deletions.
8 changes: 7 additions & 1 deletion src/ui/include/filtersdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class FiltersDialog : public QDialog, public Ui::FiltersDialog
void on_buttonBox_clicked( QAbstractButton* button );
void on_upFilterButton_clicked();
void on_downFilterButton_clicked();
void on_foreColorButton_clicked();
void on_backColorButton_clicked();
// Update the property (pattern, color...) fields from the
// selected Filter.
void updatePropertyFields();
Expand All @@ -58,7 +60,11 @@ class FiltersDialog : public QDialog, public Ui::FiltersDialog
// Index of the row currently selected or -1 if none.
int selectedRow_;

void populateColors();
QColor foreColor_ , backColor_;

static bool showColorPicker(const QColor& in , QColor& out);
void updateIcon(QPushButton* button , QColor color);

void populateFilterList();
};

Expand Down
45 changes: 26 additions & 19 deletions src/ui/include/filtersdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../glogg.qrc">
<iconset resource="../../app/klogg.qrc">
<normaloff>:/images/plus.png</normaloff>:/images/plus.png</iconset>
</property>
</widget>
Expand All @@ -54,7 +54,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../glogg.qrc">
<iconset resource="../../app/klogg.qrc">
<normaloff>:/images/minus.png</normaloff>:/images/minus.png</iconset>
</property>
</widget>
Expand All @@ -81,7 +81,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../glogg.qrc">
<iconset resource="../../app/klogg.qrc">
<normaloff>:/images/up.png</normaloff>:/images/up.png</iconset>
</property>
</widget>
Expand All @@ -95,7 +95,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="../glogg.qrc">
<iconset resource="../../app/klogg.qrc">
<normaloff>:/images/down.png</normaloff>:/images/down.png</iconset>
</property>
</widget>
Expand Down Expand Up @@ -129,20 +129,6 @@
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="backColorBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="foreColorBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
Expand All @@ -163,6 +149,26 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="foreColorButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="backColorButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand All @@ -184,7 +190,8 @@
</layout>
</widget>
<resources>
<include location="../glogg.qrc"/>
<include location="../../app/klogg.qrc"/>
<include location="../../app/klogg.qrc"/>
</resources>
<connections/>
</ui>
14 changes: 7 additions & 7 deletions src/ui/include/filterset.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Filter
// Construct an uninitialized Filter (when reading from a config file)
Filter() = default;
Filter(const QString& pattern, bool ignoreCase,
const QString& foreColor, const QString& backColor );
const QColor& foreColor, const QColor& backColor );

bool hasMatch( const QString& string ) const;

Expand All @@ -43,10 +43,10 @@ class Filter
void setPattern( const QString& pattern );
bool ignoreCase() const;
void setIgnoreCase( bool ignoreCase );
const QString& foreColorName() const;
void setForeColor( const QString& foreColorName );
const QString& backColorName() const;
void setBackColor( const QString& backColorName );
const QColor& foreColor() const;
void setForeColor( const QColor& foreColor );
const QColor& backColor() const;
void setBackColor( const QColor& backColor );

// Operators for serialization
// (must be kept to migrate filters from <=0.8.2)
Expand All @@ -59,8 +59,8 @@ class Filter

private:
QRegularExpression regexp_;
QString foreColorName_;
QString backColorName_;
QColor foreColor_;
QColor backColor_;
};

// Represents an ordered set of filters to be applied to each line displayed.
Expand Down
Loading

0 comments on commit ac754d8

Please sign in to comment.