Fix #864589 ([Enhancement] Change to Preferences - Toolbar menu)

This commit is contained in:
Kovid Goyal 2011-10-02 09:17:50 -06:00
parent 8025977447
commit 74286693e9
2 changed files with 180 additions and 139 deletions

View File

@ -231,6 +231,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
def genesis(self, gui): def genesis(self, gui):
self.models = {} self.models = {}
self.what.addItem(_('Click to choose toolbar or menu to customize'),
'blank')
for key, text in self.LOCATIONS: for key, text in self.LOCATIONS:
self.what.addItem(text, key) self.what.addItem(text, key)
all_model = AllModel(key, gui) all_model = AllModel(key, gui)
@ -247,6 +249,12 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
def what_changed(self, idx): def what_changed(self, idx):
key = unicode(self.what.itemData(idx).toString()) key = unicode(self.what.itemData(idx).toString())
if key == 'blank':
self.actions_widget.setVisible(False)
self.spacer_widget.setVisible(True)
else:
self.actions_widget.setVisible(True)
self.spacer_widget.setVisible(False)
self.all_actions.setModel(self.models[key][0]) self.all_actions.setModel(self.models[key][0])
self.current_actions.setModel(self.models[key][1]) self.current_actions.setModel(self.models[key][1])

View File

@ -13,16 +13,19 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item row="0" column="0" colspan="5"> <item>
<widget class="QComboBox" name="what"> <widget class="QLabel" name="label">
<property name="font"> <property name="text">
<font> <string>&lt;p&gt;The toolbar in calibre is different depending on whether a device is connected or not. Choose &lt;b&gt;which toolbar&lt;/b&gt; you would like to customize:</string>
<pointsize>20</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property> </property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="what">
<property name="toolTip"> <property name="toolTip">
<string>Choose the toolbar to customize</string> <string>Choose the toolbar to customize</string>
</property> </property>
@ -34,7 +37,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item>
<widget class="QWidget" name="actions_widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>A&amp;vailable actions</string> <string>A&amp;vailable actions</string>
@ -42,6 +51,12 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QListView" name="all_actions"> <widget class="QListView" name="all_actions">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum> <enum>QAbstractItemView::MultiSelection</enum>
</property> </property>
@ -62,7 +77,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QToolButton" name="add_action_button"> <widget class="QToolButton" name="add_action_button">
@ -122,7 +137,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="3" colspan="2"> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
<string>&amp;Current actions</string> <string>&amp;Current actions</string>
@ -130,6 +145,12 @@
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QListView" name="current_actions"> <widget class="QListView" name="current_actions">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum> <enum>QAbstractItemView::MultiSelection</enum>
</property> </property>
@ -210,14 +231,26 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="5"> </layout>
<widget class="QLabel" name="label"> </widget>
<property name="text"> </item>
<string>&lt;p&gt;The toolbar in calibre is different depending on whether a device is connected or not. To customize the toolbar when a device is connected as well as customizing right click menus, &lt;b&gt;click the dropdown above&lt;/b&gt; and select which toolbar/menu you want to customize.</string> <item>
<widget class="QWidget" name="spacer_widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property> </property>
<property name="wordWrap"> <property name="sizeHint" stdset="0">
<bool>true</bool> <size>
<width>20</width>
<height>224</height>
</size>
</property> </property>
</spacer>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>