Allow right clicking on the layout buttons in the bottom right corner to configure the corresponding area of the user interface

Fixes #1690454 [[Enhancement] Make main window more customizable by right clicking](https://bugs.launchpad.net/calibre/+bug/1690454)
This commit is contained in:
Kovid Goyal 2017-05-13 20:46:02 +05:30
parent b76a70e528
commit 4b89e0e6a1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 28 additions and 6 deletions

View File

@ -19,7 +19,7 @@
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="main_interface_tab">
<attribute name="icon"> <attribute name="icon">
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/lt.png</normaloff>:/images/lt.png</iconset> <normaloff>:/images/lt.png</normaloff>:/images/lt.png</iconset>
@ -662,7 +662,7 @@ A value of zero means calculate automatically.</string>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_4"> <widget class="QWidget" name="book_details_tab">
<attribute name="icon"> <attribute name="icon">
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/book.png</normaloff>:/images/book.png</iconset> <normaloff>:/images/book.png</normaloff>:/images/book.png</iconset>
@ -795,7 +795,7 @@ A value of zero means calculate automatically.</string>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tag_browser_tab">
<attribute name="icon"> <attribute name="icon">
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/tags.png</normaloff>:/images/tags.png</iconset> <normaloff>:/images/tags.png</normaloff>:/images/tags.png</iconset>
@ -948,7 +948,7 @@ see the counts by hovering your mouse over any item.</string>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="cover_browser_tab">
<attribute name="icon"> <attribute name="icon">
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/cover_flow.png</normaloff>:/images/cover_flow.png</iconset> <normaloff>:/images/cover_flow.png</normaloff>:/images/cover_flow.png</iconset>

View File

@ -13,7 +13,7 @@ from PyQt5.Qt import (
Qt, QIcon, QFont, QWidget, QScrollArea, QStackedWidget, QVBoxLayout, Qt, QIcon, QFont, QWidget, QScrollArea, QStackedWidget, QVBoxLayout,
QLabel, QFrame, QToolBar, QSize, pyqtSignal, QDialogButtonBox, QLabel, QFrame, QToolBar, QSize, pyqtSignal, QDialogButtonBox,
QHBoxLayout, QDialog, QSizePolicy, QPainter, QTextLayout, QPointF, QHBoxLayout, QDialog, QSizePolicy, QPainter, QTextLayout, QPointF,
QStatusTipEvent, QApplication) QStatusTipEvent, QApplication, QTabWidget)
from calibre.constants import __appname__, __version__, islinux from calibre.constants import __appname__, __version__, islinux
from calibre.gui2 import (gprefs, min_available_height, available_width, from calibre.gui2 import (gprefs, min_available_height, available_width,
@ -259,10 +259,19 @@ class Preferences(QDialog):
l.addWidget(self.title_bar), l.addWidget(self.stack), l.addWidget(self.bb) l.addWidget(self.title_bar), l.addWidget(self.stack), l.addWidget(self.bb)
if initial_plugin is not None: if initial_plugin is not None:
category, name = initial_plugin category, name = initial_plugin[:2]
plugin = get_plugin(category, name) plugin = get_plugin(category, name)
if plugin is not None: if plugin is not None:
self.show_plugin(plugin) self.show_plugin(plugin)
if len(initial_plugin) > 2:
w = self.findChild(QWidget, initial_plugin[2])
if w is not None:
for c in self.showing_widget.children():
if isinstance(c, QTabWidget):
idx = c.indexOf(w)
if idx > -1:
c.setCurrentIndex(idx)
break
else: else:
self.hide_plugin() self.hide_plugin()

View File

@ -959,6 +959,7 @@ class LayoutButton(QToolButton):
self.label = text self.label = text
self.setIcon(QIcon(icon)) self.setIcon(QIcon(icon))
self.setCheckable(True) self.setCheckable(True)
self.icname = os.path.basename(icon).rpartition('.')[0]
self.splitter = splitter self.splitter = splitter
if splitter is not None: if splitter is not None:
@ -987,6 +988,18 @@ class LayoutButton(QToolButton):
else: else:
self.set_state_to_hide() self.set_state_to_hide()
def mouseReleaseEvent(self, ev):
if ev.button() == Qt.RightButton:
tab_name = {'book':'book_details', 'grid':'cover_grid', 'cover_flow':'cover_browser', 'tags':'tag_browser'}.get(self.icname)
if tab_name:
ev.accept()
from calibre.gui2.ui import get_gui
gui = get_gui()
if gui is not None:
gui.iactions['Preferences'].do_config(initial_plugin=('Interface', 'Look & Feel', tab_name+'_tab'), close_after_initial=True)
return
return QToolButton.mouseReleaseEvent(self, ev)
class Splitter(QSplitter): class Splitter(QSplitter):