Skip to content

Commit

Permalink
Preferences->Add your own columns: Add buttons to show/hide all colum…
Browse files Browse the repository at this point in the history
…ns. Fixes #2031570 [have every column be ticked or unticked instead of doing them all manually](https://bugs.launchpad.net/calibre/+bug/2031570)
  • Loading branch information
kovidgoyal committed Aug 17, 2023
1 parent a69604b commit 8f405d4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 11 deletions.
16 changes: 16 additions & 0 deletions src/calibre/gui2/preferences/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def genesis(self, gui):
for signal in ('Activated', 'Changed', 'DoubleClicked', 'Clicked'):
signal = getattr(self.opt_columns, 'item'+signal)
signal.connect(self.columns_changed)
self.show_all_button.clicked.connect(self.show_all)
self.hide_all_button.clicked.connect(self.hide_all)

def initialize(self):
ConfigWidgetBase.initialize(self)
Expand Down Expand Up @@ -137,6 +139,20 @@ def restore_geometry(self):
return
self.opt_columns.resizeColumnsToContents()

def hide_all(self):
for row in range(self.opt_columns.rowCount()):
item = self.opt_columns.item(row, 0)
if item.checkState() != Qt.CheckState.PartiallyChecked:
item.setCheckState(Qt.CheckState.Unchecked)
self.changed_signal.emit()

def show_all(self):
for row in range(self.opt_columns.rowCount()):
item = self.opt_columns.item(row, 0)
if item.checkState() != Qt.CheckState.PartiallyChecked:
item.setCheckState(Qt.CheckState.Checked)
self.changed_signal.emit()

def setup_row(self, row, key, order, force_checked_to=None):
flags = Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable

Expand Down
53 changes: 42 additions & 11 deletions src/calibre/gui2/preferences/columns.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>399</height>
<width>611</width>
<height>482</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -191,15 +191,46 @@
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="add_col_button">
<property name="text">
<string>Add &amp;custom column</string>
</property>
<property name="icon">
<iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/plus.png</normaloff>:/images/plus.png</iconset>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="add_col_button">
<property name="text">
<string>Add &amp;custom column</string>
</property>
<property name="icon">
<iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/plus.png</normaloff>:/images/plus.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="show_all_button">
<property name="text">
<string>&amp;Show all</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="hide_all_button">
<property name="text">
<string>&amp;Hide all</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down

0 comments on commit 8f405d4

Please sign in to comment.