mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Show modified indicator in file tab
This commit is contained in:
parent
9b71d8ed9e
commit
9a96eea0e8
BIN
resources/images/modified.png
Normal file
BIN
resources/images/modified.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
@ -8,7 +8,7 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
from PyQt4.Qt import (
|
from PyQt4.Qt import (
|
||||||
QDockWidget, Qt, QLabel, QIcon, QAction, QApplication, QWidget,
|
QDockWidget, Qt, QLabel, QIcon, QAction, QApplication, QWidget,
|
||||||
QVBoxLayout, QStackedWidget, QTabWidget)
|
QVBoxLayout, QStackedWidget, QTabWidget, QImage, QPixmap)
|
||||||
|
|
||||||
from calibre.constants import __appname__, get_version
|
from calibre.constants import __appname__, get_version
|
||||||
from calibre.gui2.main_window import MainWindow
|
from calibre.gui2.main_window import MainWindow
|
||||||
@ -40,16 +40,31 @@ class Central(QStackedWidget):
|
|||||||
t.setDocumentMode(True)
|
t.setDocumentMode(True)
|
||||||
t.setTabsClosable(True)
|
t.setTabsClosable(True)
|
||||||
t.setMovable(True)
|
t.setMovable(True)
|
||||||
|
pal = self.palette()
|
||||||
|
if pal.color(pal.WindowText).lightness() > 128:
|
||||||
|
i = QImage(I('modified.png'))
|
||||||
|
i.invertPixels()
|
||||||
|
self.modified_icon = QIcon(QPixmap.fromImage(i))
|
||||||
|
else:
|
||||||
|
self.modified_icon = QIcon(I('modified.png'))
|
||||||
|
|
||||||
def add_editor(self, name, editor):
|
def add_editor(self, name, editor):
|
||||||
fname = name.rpartition('/')[2]
|
fname = name.rpartition('/')[2]
|
||||||
index = self.editor_tabs.addTab(editor, fname)
|
index = self.editor_tabs.addTab(editor, fname)
|
||||||
self.editor_tabs.setTabToolTip(index, name)
|
self.editor_tabs.setTabToolTip(index, _('Full path:') + ' ' + name)
|
||||||
|
editor.modification_state_changed.connect(self.editor_modified)
|
||||||
|
|
||||||
def show_editor(self, editor):
|
def show_editor(self, editor):
|
||||||
self.setCurrentIndex(1)
|
self.setCurrentIndex(1)
|
||||||
self.editor_tabs.setCurrentWidget(editor)
|
self.editor_tabs.setCurrentWidget(editor)
|
||||||
|
|
||||||
|
def editor_modified(self, *args):
|
||||||
|
tb = self.editor_tabs.tabBar()
|
||||||
|
for i in xrange(self.editor_tabs.count()):
|
||||||
|
editor = self.editor_tabs.widget(i)
|
||||||
|
modified = getattr(editor, 'is_modified', False)
|
||||||
|
tb.setTabIcon(i, self.modified_icon if modified else QIcon())
|
||||||
|
|
||||||
class Main(MainWindow):
|
class Main(MainWindow):
|
||||||
|
|
||||||
APP_NAME = _('Tweak Book')
|
APP_NAME = _('Tweak Book')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user