mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow user customization of the toolbar and context menus via Preferences->Interface->Toolbars
This commit is contained in:
parent
ff827175f7
commit
140852631a
@ -19,8 +19,35 @@ from calibre.ebooks.metadata.meta import get_metadata, metadata_from_formats
|
|||||||
from calibre.ebooks.metadata import MetaInformation
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
from calibre.utils.date import UNDEFINED_DATE
|
from calibre.utils.date import UNDEFINED_DATE
|
||||||
|
|
||||||
|
# Setup gprefs {{{
|
||||||
gprefs = JSONConfig('gui')
|
gprefs = JSONConfig('gui')
|
||||||
|
|
||||||
|
gprefs.defaults['action-layout-toolbar'] = (
|
||||||
|
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None,
|
||||||
|
'Choose Library', 'Donate', None, 'Fetch News', 'Save To Disk',
|
||||||
|
'Connect Share', None, 'Remove Books', None, 'Help', 'Preferences',
|
||||||
|
)
|
||||||
|
|
||||||
|
gprefs.defaults['action-layout-toolbar-device'] = (
|
||||||
|
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
|
||||||
|
'Send To Device', None, None, 'Location Manager', None, None,
|
||||||
|
'Fetch News', 'Save To Disk', 'Connect Share', None,
|
||||||
|
'Remove Books', None, 'Help', 'Preferences',
|
||||||
|
)
|
||||||
|
|
||||||
|
gprefs.defaults['action-layout-context-menu'] = (
|
||||||
|
'Edit Metadata', 'Send To Device', 'Save To Disk',
|
||||||
|
'Connect Share', 'Copy To Library', None,
|
||||||
|
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
|
||||||
|
'Similar Books', None, 'Remove Books',
|
||||||
|
)
|
||||||
|
|
||||||
|
gprefs.defaults['action-layout-context-menu-device'] = (
|
||||||
|
'View', 'Save To Disk', None, 'Remove Books', None,
|
||||||
|
'Add To Library', 'Edit Collections',
|
||||||
|
)
|
||||||
|
# }}}
|
||||||
|
|
||||||
NONE = QVariant() #: Null value to return from the data function of item models
|
NONE = QVariant() #: Null value to return from the data function of item models
|
||||||
UNDEFINED_QDATE = QDate(UNDEFINED_DATE)
|
UNDEFINED_QDATE = QDate(UNDEFINED_DATE)
|
||||||
|
|
||||||
|
@ -56,6 +56,8 @@ class PreferencesAction(InterfaceAction):
|
|||||||
self.gui.tags_view.recount()
|
self.gui.tags_view.recount()
|
||||||
self.gui.create_device_menu()
|
self.gui.create_device_menu()
|
||||||
self.gui.set_device_menu_items_state(bool(self.gui.device_connected))
|
self.gui.set_device_menu_items_state(bool(self.gui.device_connected))
|
||||||
|
self.gui.tool_bar.build_bar()
|
||||||
|
self.gui.build_context_menus()
|
||||||
self.gui.tool_bar.apply_settings()
|
self.gui.tool_bar.apply_settings()
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ from PyQt4.Qt import QDialog, QListWidgetItem, QIcon, \
|
|||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, isosx
|
||||||
from calibre.gui2.dialogs.config.config_ui import Ui_Dialog
|
from calibre.gui2.dialogs.config.config_ui import Ui_Dialog
|
||||||
from calibre.gui2.dialogs.config.create_custom_column import CreateCustomColumn
|
from calibre.gui2.dialogs.config.create_custom_column import CreateCustomColumn
|
||||||
|
from calibre.gui2.dialogs.config.toolbar import ToolbarLayout
|
||||||
from calibre.gui2 import error_dialog, config, gprefs, \
|
from calibre.gui2 import error_dialog, config, gprefs, \
|
||||||
open_url, open_local_file, \
|
open_url, open_local_file, \
|
||||||
ALL_COLUMNS, NONE, info_dialog, choose_files, \
|
ALL_COLUMNS, NONE, info_dialog, choose_files, \
|
||||||
@ -524,6 +525,9 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
|||||||
self.current_tweaks.setPlainText(curt.decode('utf-8'))
|
self.current_tweaks.setPlainText(curt.decode('utf-8'))
|
||||||
self.default_tweaks.setPlainText(deft.decode('utf-8'))
|
self.default_tweaks.setPlainText(deft.decode('utf-8'))
|
||||||
self.restore_tweaks_to_default_button.clicked.connect(self.restore_tweaks_to_default)
|
self.restore_tweaks_to_default_button.clicked.connect(self.restore_tweaks_to_default)
|
||||||
|
self.toolbar_cm_widget = ToolbarLayout(parent, parent)
|
||||||
|
self.toolbar_cm_tab.addTab(self.toolbar_cm_widget,
|
||||||
|
_('Toolbars/Context menus'))
|
||||||
|
|
||||||
self.category_view.setCurrentIndex(self.category_view.model().index_for_name(initial_category))
|
self.category_view.setCurrentIndex(self.category_view.model().index_for_name(initial_category))
|
||||||
|
|
||||||
@ -888,6 +892,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
|||||||
wl = self.opt_worker_limit.value()
|
wl = self.opt_worker_limit.value()
|
||||||
if wl%2 != 0:
|
if wl%2 != 0:
|
||||||
wl += 1
|
wl += 1
|
||||||
|
self.toolbar_cm_widget.commit()
|
||||||
config['worker_limit'] = wl
|
config['worker_limit'] = wl
|
||||||
|
|
||||||
config['use_roman_numerals_for_series_number'] = bool(self.roman_numerals.isChecked())
|
config['use_roman_numerals_for_series_number'] = bool(self.roman_numerals.isChecked())
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page_3">
|
<widget class="QWidget" name="page_3">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
@ -294,361 +294,371 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page">
|
<widget class="QWidget" name="page">
|
||||||
<layout class="QGridLayout" name="gridLayout_8">
|
<layout class="QGridLayout" name="gridLayout_12">
|
||||||
<item row="2" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="roman_numerals">
|
<widget class="QTabWidget" name="toolbar_cm_tab">
|
||||||
<property name="text">
|
<property name="currentIndex">
|
||||||
<string>Use &Roman numerals for series number</string>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<widget class="QWidget" name="tab_3">
|
||||||
<bool>true</bool>
|
<attribute name="title">
|
||||||
</property>
|
<string>&Miscellaneous</string>
|
||||||
</widget>
|
</attribute>
|
||||||
</item>
|
<layout class="QGridLayout" name="gridLayout_8">
|
||||||
<item row="3" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="systray_icon">
|
<widget class="QLabel" name="label_17">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable system &tray icon (needs restart)</string>
|
<string>User Interface &layout (needs restart):</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="buddy">
|
||||||
</item>
|
<cstring>opt_gui_layout</cstring>
|
||||||
<item row="3" column="1">
|
</property>
|
||||||
<widget class="QCheckBox" name="systray_notifications">
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string>Show &notifications in system tray</string>
|
<item row="0" column="1">
|
||||||
</property>
|
<widget class="QComboBox" name="opt_gui_layout">
|
||||||
</widget>
|
<property name="maximumSize">
|
||||||
</item>
|
<size>
|
||||||
<item row="4" column="0">
|
<width>250</width>
|
||||||
<widget class="QCheckBox" name="show_splash_screen">
|
<height>16777215</height>
|
||||||
<property name="text">
|
</size>
|
||||||
<string>Show &splash screen at startup</string>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
<item row="1" column="0">
|
||||||
<item row="5" column="0" colspan="2">
|
<widget class="QLabel" name="label_6">
|
||||||
<widget class="QCheckBox" name="separate_cover_flow">
|
<property name="text">
|
||||||
<property name="text">
|
<string>&Number of covers to show in browse mode (needs restart):</string>
|
||||||
<string>Show cover &browser in a separate window (needs restart)</string>
|
</property>
|
||||||
</property>
|
<property name="buddy">
|
||||||
</widget>
|
<cstring>cover_browse</cstring>
|
||||||
</item>
|
</property>
|
||||||
<item row="6" column="0" colspan="2">
|
</widget>
|
||||||
<widget class="QCheckBox" name="show_avg_rating">
|
</item>
|
||||||
<property name="text">
|
<item row="1" column="1">
|
||||||
<string>Show &average ratings in the tags browser</string>
|
<widget class="QSpinBox" name="cover_browse"/>
|
||||||
</property>
|
</item>
|
||||||
<property name="checked">
|
<item row="2" column="0">
|
||||||
<bool>true</bool>
|
<widget class="QLabel" name="label_170">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Restriction to apply when the current library is opened:</string>
|
||||||
</item>
|
</property>
|
||||||
<item row="7" column="0">
|
<property name="buddy">
|
||||||
<widget class="QCheckBox" name="search_as_you_type">
|
<cstring>opt_gui_restriction</cstring>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Search as you type</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="checked">
|
<item row="2" column="1">
|
||||||
<bool>true</bool>
|
<widget class="QComboBox" name="opt_gui_restriction">
|
||||||
</property>
|
<property name="maximumSize">
|
||||||
</widget>
|
<size>
|
||||||
</item>
|
<width>250</width>
|
||||||
<item row="9" column="0" colspan="2">
|
<height>16777215</height>
|
||||||
<widget class="QCheckBox" name="sync_news">
|
</size>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Automatically send downloaded &news to ebook reader</string>
|
<property name="toolTip">
|
||||||
</property>
|
<string>Apply this restriction on calibre startup if the current library is being used. Also applied when switching to this library. Note that this setting is per library. </string>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
<property name="sizeAdjustPolicy">
|
||||||
<item row="10" column="0" colspan="2">
|
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||||
<widget class="QCheckBox" name="delete_news">
|
</property>
|
||||||
<property name="text">
|
<property name="minimumContentsLength">
|
||||||
<string>&Delete news from library when it is automatically sent to reader</string>
|
<number>15</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="0" colspan="2">
|
<item row="3" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<widget class="QCheckBox" name="roman_numerals">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QLabel" name="label_6">
|
<string>Use &Roman numerals for series number</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>&Number of covers to show in browse mode (needs restart):</string>
|
<property name="checked">
|
||||||
</property>
|
<bool>true</bool>
|
||||||
<property name="buddy">
|
</property>
|
||||||
<cstring>cover_browse</cstring>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="3" column="1">
|
||||||
</item>
|
<widget class="QCheckBox" name="opt_disable_animations">
|
||||||
<item>
|
<property name="toolTip">
|
||||||
<widget class="QSpinBox" name="cover_browse"/>
|
<string>Disable all animations. Useful if you have a slow/old computer.</string>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
<property name="text">
|
||||||
</item>
|
<string>Disable &animations</string>
|
||||||
<item row="12" column="0" colspan="2">
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
</widget>
|
||||||
<item>
|
</item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<item row="4" column="0">
|
||||||
<property name="title">
|
<widget class="QCheckBox" name="systray_icon">
|
||||||
<string>Select visible &columns in library view</string>
|
<property name="text">
|
||||||
</property>
|
<string>Enable system &tray icon (needs restart)</string>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
</item>
|
||||||
<item>
|
<item row="4" column="1">
|
||||||
<widget class="QListWidget" name="columns">
|
<widget class="QCheckBox" name="systray_notifications">
|
||||||
<property name="alternatingRowColors">
|
<property name="text">
|
||||||
<bool>true</bool>
|
<string>Show &notifications in system tray</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QCheckBox" name="opt_show_donate_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show &donate button (restart)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="0" colspan="2">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Toolbar</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="opt_toolbar_icon_size"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Icon size:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionBehavior">
|
<property name="buddy">
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
<cstring>opt_toolbar_icon_size</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="1">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<widget class="QComboBox" name="opt_toolbar_text"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show &text under icons:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>opt_toolbar_text</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="delete_news">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Delete news from library when it is automatically sent to reader</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="0" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Select visible &columns in library view</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="column_up">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>...</string>
|
<widget class="QListWidget" name="columns">
|
||||||
</property>
|
<property name="alternatingRowColors">
|
||||||
<property name="icon">
|
<bool>true</bool>
|
||||||
<iconset resource="../../../../../resources/images.qrc">
|
</property>
|
||||||
<normaloff>:/images/arrow-up.svg</normaloff>:/images/arrow-up.svg</iconset>
|
<property name="selectionBehavior">
|
||||||
</property>
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
</widget>
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="column_up">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../../../resources/images.qrc">
|
||||||
|
<normaloff>:/images/arrow-up.svg</normaloff>:/images/arrow-up.svg</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="del_custcol_button">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove a user-defined column</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../../../resources/images.qrc">
|
||||||
|
<normaloff>:/images/minus.svg</normaloff>:/images/minus.svg</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="add_custcol_button">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add a user-defined column</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../../../resources/images.qrc">
|
||||||
|
<normaloff>:/images/plus.svg</normaloff>:/images/plus.svg</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="edit_custcol_button">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Edit settings of a user-defined column</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../../../resources/images.qrc">
|
||||||
|
<normaloff>:/images/edit_input.svg</normaloff>:/images/edit_input.svg</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="column_down">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../../../resources/images.qrc">
|
||||||
|
<normaloff>:/images/arrow-down.svg</normaloff>:/images/arrow-down.svg</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<spacer name="verticalSpacer_2">
|
</widget>
|
||||||
<property name="orientation">
|
</item>
|
||||||
<enum>Qt::Vertical</enum>
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
|
<property name="title">
|
||||||
|
<string>Use internal &viewer for:</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QListWidget" name="viewer">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="selectionMode">
|
||||||
<size>
|
<enum>QAbstractItemView::NoSelection</enum>
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="del_custcol_button">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Remove a user-defined column</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../../../../../resources/images.qrc">
|
|
||||||
<normaloff>:/images/minus.svg</normaloff>:/images/minus.svg</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="add_custcol_button">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Add a user-defined column</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../../../../../resources/images.qrc">
|
|
||||||
<normaloff>:/images/plus.svg</normaloff>:/images/plus.svg</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="edit_custcol_button">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Edit settings of a user-defined column</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../../../../../resources/images.qrc">
|
|
||||||
<normaloff>:/images/edit_input.svg</normaloff>:/images/edit_input.svg</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="column_down">
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../../../../../resources/images.qrc">
|
|
||||||
<normaloff>:/images/arrow-down.svg</normaloff>:/images/arrow-down.svg</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</widget>
|
||||||
</layout>
|
</item>
|
||||||
</item>
|
</layout>
|
||||||
</layout>
|
</item>
|
||||||
</widget>
|
<item row="8" column="1">
|
||||||
</item>
|
<widget class="QCheckBox" name="show_splash_screen">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<string>Show &splash screen at startup</string>
|
||||||
<property name="title">
|
</property>
|
||||||
<string>Use internal &viewer for:</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<item row="8" column="0">
|
||||||
<item row="0" column="0">
|
<widget class="QCheckBox" name="sync_news">
|
||||||
<widget class="QListWidget" name="viewer">
|
<property name="text">
|
||||||
<property name="alternatingRowColors">
|
<string>Automatically send downloaded &news to ebook reader</string>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="selectionMode">
|
</item>
|
||||||
<enum>QAbstractItemView::NoSelection</enum>
|
<item row="6" column="1">
|
||||||
</property>
|
<widget class="QCheckBox" name="search_as_you_type">
|
||||||
</widget>
|
<property name="text">
|
||||||
</item>
|
<string>Search as you type</string>
|
||||||
</layout>
|
</property>
|
||||||
</widget>
|
<property name="checked">
|
||||||
</item>
|
<bool>true</bool>
|
||||||
</layout>
|
</property>
|
||||||
</item>
|
</widget>
|
||||||
<item row="0" column="0">
|
</item>
|
||||||
<widget class="QLabel" name="label_17">
|
<item row="5" column="0">
|
||||||
<property name="text">
|
<widget class="QCheckBox" name="show_avg_rating">
|
||||||
<string>User Interface &layout (needs restart):</string>
|
<property name="text">
|
||||||
</property>
|
<string>Show &average ratings in the tags browser</string>
|
||||||
<property name="buddy">
|
</property>
|
||||||
<cstring>opt_gui_layout</cstring>
|
<property name="checked">
|
||||||
</property>
|
<bool>true</bool>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
</widget>
|
||||||
<item row="0" column="1">
|
</item>
|
||||||
<widget class="QComboBox" name="opt_gui_layout">
|
<item row="6" column="0">
|
||||||
<property name="maximumSize">
|
<widget class="QCheckBox" name="separate_cover_flow">
|
||||||
<size>
|
<property name="text">
|
||||||
<width>250</width>
|
<string>Show cover &browser in a separate window (needs restart)</string>
|
||||||
<height>16777215</height>
|
</property>
|
||||||
</size>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
</layout>
|
||||||
</item>
|
</widget>
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_170">
|
|
||||||
<property name="text">
|
|
||||||
<string>Restriction to apply when the current library is opened:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>opt_gui_restriction</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QComboBox" name="opt_gui_restriction">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>250</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Apply this restriction on calibre startup if the current library is being used. Also applied when switching to this library. Note that this setting is per library. </string>
|
|
||||||
</property>
|
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
|
||||||
</property>
|
|
||||||
<property name="minimumContentsLength">
|
|
||||||
<number>20</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QCheckBox" name="opt_disable_animations">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Disable all animations. Useful if you have a slow/old computer.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Disable &animations</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QCheckBox" name="opt_show_donate_button">
|
|
||||||
<property name="text">
|
|
||||||
<string>Show &donate button (restart)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0" colspan="2">
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>&Toolbar</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QComboBox" name="opt_toolbar_icon_size"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Icon size:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>opt_toolbar_icon_size</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QComboBox" name="opt_toolbar_text"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>Show &text under icons:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>opt_toolbar_text</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -27,7 +27,9 @@ class BaseModel(QAbstractListModel):
|
|||||||
|
|
||||||
def name_to_action(self, name, gui):
|
def name_to_action(self, name, gui):
|
||||||
if name == 'Donate':
|
if name == 'Donate':
|
||||||
return FakeAction(name, 'donate.svg')
|
return FakeAction(name, 'donate.svg',
|
||||||
|
dont_add_to=frozenset(['context-menu',
|
||||||
|
'context-menu-device']))
|
||||||
if name == 'Location Manager':
|
if name == 'Location Manager':
|
||||||
return FakeAction(name, None,
|
return FakeAction(name, None,
|
||||||
_('Switch between library and device views'),
|
_('Switch between library and device views'),
|
||||||
@ -72,15 +74,19 @@ class AllModel(BaseModel):
|
|||||||
|
|
||||||
def __init__(self, key, gui):
|
def __init__(self, key, gui):
|
||||||
BaseModel.__init__(self)
|
BaseModel.__init__(self)
|
||||||
current = gprefs['action-layout-'+key]
|
self.gprefs_name = 'action-layout-'+key
|
||||||
all = list(gui.iactions.keys()) + ['Donate']
|
current = gprefs[self.gprefs_name]
|
||||||
all = [x for x in all if x not in current] + [None]
|
|
||||||
all = [self.name_to_action(x, gui) for x in all]
|
|
||||||
all = [x for x in all if key not in x.dont_add_to]
|
|
||||||
all.sort()
|
|
||||||
self.gui = gui
|
self.gui = gui
|
||||||
|
self.key = key
|
||||||
|
self._data = self.get_all_actions(current)
|
||||||
|
|
||||||
self._data = all
|
def get_all_actions(self, current):
|
||||||
|
all = list(self.gui.iactions.keys()) + ['Donate']
|
||||||
|
all = [x for x in all if x not in current] + [None]
|
||||||
|
all = [self.name_to_action(x, self.gui) for x in all]
|
||||||
|
all = [x for x in all if self.key not in x.dont_add_to]
|
||||||
|
all.sort()
|
||||||
|
return all
|
||||||
|
|
||||||
def add(self, names):
|
def add(self, names):
|
||||||
actions = []
|
actions = []
|
||||||
@ -106,12 +112,17 @@ class AllModel(BaseModel):
|
|||||||
self._data = ndata
|
self._data = ndata
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
|
def restore_defaults(self):
|
||||||
|
current = gprefs.defaults[self.gprefs_name]
|
||||||
|
self._data = self.get_all_actions(current)
|
||||||
|
self.reset()
|
||||||
|
|
||||||
class CurrentModel(BaseModel):
|
class CurrentModel(BaseModel):
|
||||||
|
|
||||||
def __init__(self, key, gui):
|
def __init__(self, key, gui):
|
||||||
BaseModel.__init__(self)
|
BaseModel.__init__(self)
|
||||||
current = gprefs['action-layout-'+key]
|
self.gprefs_name = 'action-layout-'+key
|
||||||
|
current = gprefs[self.gprefs_name]
|
||||||
self._data = [self.name_to_action(x, gui) for x in current]
|
self._data = [self.name_to_action(x, gui) for x in current]
|
||||||
self.key = key
|
self.key = key
|
||||||
self.gui = gui
|
self.gui = gui
|
||||||
@ -162,6 +173,27 @@ class CurrentModel(BaseModel):
|
|||||||
self.reset()
|
self.reset()
|
||||||
return rejected
|
return rejected
|
||||||
|
|
||||||
|
def commit(self):
|
||||||
|
old = gprefs[self.gprefs_name]
|
||||||
|
new = []
|
||||||
|
for x in self._data:
|
||||||
|
n = x.name
|
||||||
|
if n.startswith('---'):
|
||||||
|
n = None
|
||||||
|
new.append(n)
|
||||||
|
new = tuple(new)
|
||||||
|
if new != old:
|
||||||
|
defaults = gprefs.defaults[self.gprefs_name]
|
||||||
|
if defaults == new:
|
||||||
|
del gprefs[self.gprefs_name]
|
||||||
|
else:
|
||||||
|
gprefs[self.gprefs_name] = new
|
||||||
|
|
||||||
|
def restore_defaults(self):
|
||||||
|
current = gprefs.defaults[self.gprefs_name]
|
||||||
|
self._data = [self.name_to_action(x, self.gui) for x in current]
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
|
||||||
class ToolbarLayout(QWidget, Ui_Form):
|
class ToolbarLayout(QWidget, Ui_Form):
|
||||||
|
|
||||||
@ -190,6 +222,7 @@ class ToolbarLayout(QWidget, Ui_Form):
|
|||||||
|
|
||||||
self.add_action_button.clicked.connect(self.add_action)
|
self.add_action_button.clicked.connect(self.add_action)
|
||||||
self.remove_action_button.clicked.connect(self.remove_action)
|
self.remove_action_button.clicked.connect(self.remove_action)
|
||||||
|
self.restore_defaults_button.clicked.connect(self.restore_defaults)
|
||||||
self.action_up_button.clicked.connect(partial(self.move, -1))
|
self.action_up_button.clicked.connect(partial(self.move, -1))
|
||||||
self.action_down_button.clicked.connect(partial(self.move, 1))
|
self.action_down_button.clicked.connect(partial(self.move, 1))
|
||||||
|
|
||||||
@ -230,7 +263,6 @@ class ToolbarLayout(QWidget, Ui_Form):
|
|||||||
','.join([a.action_spec[0] for a in not_removed]),
|
','.join([a.action_spec[0] for a in not_removed]),
|
||||||
show=True)
|
show=True)
|
||||||
|
|
||||||
|
|
||||||
def move(self, delta, *args):
|
def move(self, delta, *args):
|
||||||
ci = self.current_actions.currentIndex()
|
ci = self.current_actions.currentIndex()
|
||||||
m = self.current_actions.model()
|
m = self.current_actions.model()
|
||||||
@ -241,6 +273,16 @@ class ToolbarLayout(QWidget, Ui_Form):
|
|||||||
self.current_actions.selectionModel().select(ni,
|
self.current_actions.selectionModel().select(ni,
|
||||||
QItemSelectionModel.ClearAndSelect)
|
QItemSelectionModel.ClearAndSelect)
|
||||||
|
|
||||||
|
def commit(self):
|
||||||
|
for am, cm in self.models.values():
|
||||||
|
cm.commit()
|
||||||
|
|
||||||
|
def restore_defaults(self, *args):
|
||||||
|
for am, cm in self.models.values():
|
||||||
|
cm.restore_defaults()
|
||||||
|
am.restore_defaults()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from PyQt4.Qt import QApplication
|
from PyQt4.Qt import QApplication
|
||||||
from calibre.gui2.ui import Main
|
from calibre.gui2.ui import Main
|
||||||
@ -249,4 +291,5 @@ if __name__ == '__main__':
|
|||||||
a = ToolbarLayout(m)
|
a = ToolbarLayout(m)
|
||||||
a.show()
|
a.show()
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
a.commit()
|
||||||
|
|
||||||
|
@ -207,6 +207,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QPushButton" name="restore_defaults_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Restore to &default</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -27,36 +27,10 @@ def partial(*args, **kwargs):
|
|||||||
_keep_refs.append(ans)
|
_keep_refs.append(ans)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
gprefs.defaults['action-layout-context-menu'] = (
|
|
||||||
'Edit Metadata', 'Send To Device', 'Save To Disk',
|
|
||||||
'Connect Share', 'Copy To Library', None,
|
|
||||||
'Convert Books', 'View', 'Open Folder', 'Show Book Details',
|
|
||||||
'Similar Books', None, 'Remove Books',
|
|
||||||
)
|
|
||||||
|
|
||||||
gprefs.defaults['action-layout-context-menu-device'] = (
|
|
||||||
'View', 'Save To Disk', None, 'Remove Books', None,
|
|
||||||
'Add To Library', 'Edit Collections',
|
|
||||||
)
|
|
||||||
|
|
||||||
class LibraryViewMixin(object): # {{{
|
class LibraryViewMixin(object): # {{{
|
||||||
|
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
lm = QMenu(self)
|
|
||||||
def populate_menu(m, items):
|
|
||||||
for what in items:
|
|
||||||
if what is None:
|
|
||||||
m.addSeparator()
|
|
||||||
elif what in self.iactions:
|
|
||||||
m.addAction(self.iactions[what].qaction)
|
|
||||||
populate_menu(lm, gprefs['action-layout-context-menu'])
|
|
||||||
dm = QMenu(self)
|
|
||||||
populate_menu(dm, gprefs['action-layout-context-menu-device'])
|
|
||||||
ec = self.iactions['Edit Collections'].qaction
|
|
||||||
self.library_view.set_context_menu(lm, ec)
|
|
||||||
for v in (self.memory_view, self.card_a_view, self.card_b_view):
|
|
||||||
v.set_context_menu(dm, ec)
|
|
||||||
|
|
||||||
self.library_view.files_dropped.connect(self.iactions['Add Books'].files_dropped, type=Qt.QueuedConnection)
|
self.library_view.files_dropped.connect(self.iactions['Add Books'].files_dropped, type=Qt.QueuedConnection)
|
||||||
for func, args in [
|
for func, args in [
|
||||||
('connect_to_search_box', (self.search,
|
('connect_to_search_box', (self.search,
|
||||||
@ -86,6 +60,23 @@ class LibraryViewMixin(object): # {{{
|
|||||||
view = getattr(self, view+'_view')
|
view = getattr(self, view+'_view')
|
||||||
view.verticalHeader().sectionDoubleClicked.connect(self.iactions['View'].view_specific_book)
|
view.verticalHeader().sectionDoubleClicked.connect(self.iactions['View'].view_specific_book)
|
||||||
|
|
||||||
|
self.build_context_menus()
|
||||||
|
|
||||||
|
def build_context_menus(self):
|
||||||
|
lm = QMenu(self)
|
||||||
|
def populate_menu(m, items):
|
||||||
|
for what in items:
|
||||||
|
if what is None:
|
||||||
|
m.addSeparator()
|
||||||
|
elif what in self.iactions:
|
||||||
|
m.addAction(self.iactions[what].qaction)
|
||||||
|
populate_menu(lm, gprefs['action-layout-context-menu'])
|
||||||
|
dm = QMenu(self)
|
||||||
|
populate_menu(dm, gprefs['action-layout-context-menu-device'])
|
||||||
|
ec = self.iactions['Edit Collections'].qaction
|
||||||
|
self.library_view.set_context_menu(lm, ec)
|
||||||
|
for v in (self.memory_view, self.card_a_view, self.card_b_view):
|
||||||
|
v.set_context_menu(dm, ec)
|
||||||
|
|
||||||
|
|
||||||
def search_done(self, view, ok):
|
def search_done(self, view, ok):
|
||||||
|
@ -19,19 +19,6 @@ from calibre.gui2 import config, gprefs
|
|||||||
from calibre.gui2.widgets import ComboBoxWithHelp
|
from calibre.gui2.widgets import ComboBoxWithHelp
|
||||||
from calibre import human_readable
|
from calibre import human_readable
|
||||||
|
|
||||||
gprefs.defaults['action-layout-toolbar'] = (
|
|
||||||
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View', None,
|
|
||||||
'Choose Library', 'Donate', None, 'Fetch News', 'Save To Disk',
|
|
||||||
'Connect Share', None, 'Remove Books', None, 'Help', 'Preferences',
|
|
||||||
)
|
|
||||||
|
|
||||||
gprefs.defaults['action-layout-toolbar-device'] = (
|
|
||||||
'Add Books', 'Edit Metadata', None, 'Convert Books', 'View',
|
|
||||||
'Send To Device', None, None, 'Location Manager', None, None,
|
|
||||||
'Fetch News', 'Save To Disk', 'Connect Share', None,
|
|
||||||
'Remove Books', None, 'Help', 'Preferences',
|
|
||||||
)
|
|
||||||
|
|
||||||
class LocationManager(QObject): # {{{
|
class LocationManager(QObject): # {{{
|
||||||
|
|
||||||
locations_changed = pyqtSignal()
|
locations_changed = pyqtSignal()
|
||||||
|
@ -621,8 +621,9 @@ class XMLConfig(dict):
|
|||||||
self.__setitem__(key, val)
|
self.__setitem__(key, val)
|
||||||
|
|
||||||
def __delitem__(self, key):
|
def __delitem__(self, key):
|
||||||
dict.__delitem__(self, key)
|
if dict.has_key(self, key):
|
||||||
self.commit()
|
dict.__delitem__(self, key)
|
||||||
|
self.commit()
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
if hasattr(self, 'file_path') and self.file_path:
|
if hasattr(self, 'file_path') and self.file_path:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user