mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Highlight splitter when collapsed
This commit is contained in:
parent
98fa71af77
commit
be814cda27
@ -288,7 +288,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="vertical_splitter">
|
<widget class="Splitter" name="vertical_splitter">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -311,7 +311,7 @@
|
|||||||
<widget class="QWidget" name="library">
|
<widget class="QWidget" name="library">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="horizontal_splitter">
|
<widget class="Splitter" name="horizontal_splitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -826,6 +826,12 @@
|
|||||||
<header>calibre/gui2/status.h</header>
|
<header>calibre/gui2/status.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Splitter</class>
|
||||||
|
<extends>QSplitter</extends>
|
||||||
|
<header>calibre/gui2/widgets.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../resources/images.qrc"/>
|
<include location="../../../resources/images.qrc"/>
|
||||||
|
@ -679,6 +679,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
bi_state = dynamic.get('book_info_state', None)
|
bi_state = dynamic.get('book_info_state', None)
|
||||||
if bi_state is not None:
|
if bi_state is not None:
|
||||||
self.vertical_splitter.restoreState(bi_state)
|
self.vertical_splitter.restoreState(bi_state)
|
||||||
|
self.horizontal_splitter.initialize()
|
||||||
|
self.vertical_splitter.initialize()
|
||||||
|
|
||||||
self._add_filesystem_book = Dispatcher(self.__add_filesystem_book)
|
self._add_filesystem_book = Dispatcher(self.__add_filesystem_book)
|
||||||
v = self.library_view
|
v = self.library_view
|
||||||
|
@ -7,9 +7,9 @@ import re, os, traceback
|
|||||||
from PyQt4.Qt import QListView, QIcon, QFont, QLabel, QListWidget, \
|
from PyQt4.Qt import QListView, QIcon, QFont, QLabel, QListWidget, \
|
||||||
QListWidgetItem, QTextCharFormat, QApplication, \
|
QListWidgetItem, QTextCharFormat, QApplication, \
|
||||||
QSyntaxHighlighter, QCursor, QColor, QWidget, \
|
QSyntaxHighlighter, QCursor, QColor, QWidget, \
|
||||||
QPixmap, QPalette, QTimer, QDialog, \
|
QPixmap, QPalette, QTimer, QDialog, QSplitterHandle, \
|
||||||
QAbstractListModel, QVariant, Qt, SIGNAL, \
|
QAbstractListModel, QVariant, Qt, SIGNAL, \
|
||||||
QRegExp, QSettings, QSize, QModelIndex, \
|
QRegExp, QSettings, QSize, QModelIndex, QSplitter, \
|
||||||
QAbstractButton, QPainter, QLineEdit, QComboBox, \
|
QAbstractButton, QPainter, QLineEdit, QComboBox, \
|
||||||
QMenu, QStringListModel, QCompleter, QStringList
|
QMenu, QStringListModel, QCompleter, QStringList
|
||||||
|
|
||||||
@ -951,3 +951,35 @@ class PythonHighlighter(QSyntaxHighlighter):
|
|||||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||||
QSyntaxHighlighter.rehighlight(self)
|
QSyntaxHighlighter.rehighlight(self)
|
||||||
QApplication.restoreOverrideCursor()
|
QApplication.restoreOverrideCursor()
|
||||||
|
|
||||||
|
class SplitterHandle(QSplitterHandle):
|
||||||
|
|
||||||
|
def __init__(self, orientation, splitter):
|
||||||
|
QSplitterHandle.__init__(self, orientation, splitter)
|
||||||
|
splitter.splitterMoved.connect(self.splitter_moved,
|
||||||
|
type=Qt.QueuedConnection)
|
||||||
|
self.highlight = False
|
||||||
|
|
||||||
|
def splitter_moved(self, *args):
|
||||||
|
oh = self.highlight
|
||||||
|
self.highlight = 0 in self.splitter().sizes()
|
||||||
|
if oh != self.highlight:
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def paintEvent(self, ev):
|
||||||
|
QSplitterHandle.paintEvent(self, ev)
|
||||||
|
if self.highlight:
|
||||||
|
painter = QPainter(self)
|
||||||
|
painter.setClipRect(ev.rect())
|
||||||
|
painter.fillRect(self.rect(), Qt.yellow)
|
||||||
|
|
||||||
|
class Splitter(QSplitter):
|
||||||
|
|
||||||
|
def createHandle(self):
|
||||||
|
return SplitterHandle(self.orientation(), self)
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
for i in range(self.count()):
|
||||||
|
h = self.handle(i)
|
||||||
|
if h is not None:
|
||||||
|
h.splitter_moved()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user