Dialog background color

Definition language
Mouse cursor hiding
This commit is contained in:
BasioMeusPuga
2018-03-08 11:21:42 +05:30
parent 411b4445c6
commit 6bf8c14dda
12 changed files with 177 additions and 58 deletions

View File

@@ -770,6 +770,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
signal_sender = self.sender().objectName() signal_sender = self.sender().objectName()
# Special cases that don't affect (comic)book display
if signal_sender == 'libraryBackground': if signal_sender == 'libraryBackground':
current_color = self.settings['listview_background'] current_color = self.settings['listview_background']
new_color = open_color_dialog(current_color) new_color = open_color_dialog(current_color)
@@ -778,6 +779,12 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.settings['listview_background'] = new_color self.settings['listview_background'] = new_color
return return
if signal_sender == 'dialogBackground':
current_color = self.settings['dialog_background']
new_color = open_color_dialog(current_color)
self.settings['dialog_background'] = new_color
return new_color
profile_index = self.bookToolBar.profileBox.currentIndex() profile_index = self.bookToolBar.profileBox.currentIndex()
current_profile = self.bookToolBar.profileBox.itemData( current_profile = self.bookToolBar.profileBox.itemData(
profile_index, QtCore.Qt.UserRole) profile_index, QtCore.Qt.UserRole)

View File

@@ -27,6 +27,8 @@ class DefinitionsUI(QtWidgets.QDialog, definitions.Ui_Dialog):
super(DefinitionsUI, self).__init__() super(DefinitionsUI, self).__init__()
self.setupUi(self) self.setupUi(self)
self.parent = parent
self.setWindowFlags( self.setWindowFlags(
QtCore.Qt.Popup | QtCore.Qt.Popup |
QtCore.Qt.FramelessWindowHint) QtCore.Qt.FramelessWindowHint)
@@ -37,32 +39,20 @@ class DefinitionsUI(QtWidgets.QDialog, definitions.Ui_Dialog):
mask = QtGui.QRegion(path.toFillPolygon().toPolygon()) mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
self.setMask(mask) self.setMask(mask)
foreground = QtGui.QColor().fromRgb(230, 230, 230)
background = QtGui.QColor().fromRgb(0, 0, 0)
self.setStyleSheet(
"QDialog {{background-color: {0}}}".format(background.name()))
self.definitionView.setStyleSheet(
"QTextBrowser {{color: {0}; background-color: {1}}}".format(
foreground.name(), background.name()))
self.app_id = 'bb7a91f9' self.app_id = 'bb7a91f9'
self.app_key = 'fefacdf6775c347b52e9efa2efe642ef' self.app_key = 'fefacdf6775c347b52e9efa2efe642ef'
self.language = 'en'
self.root_url = 'https://od-api.oxforddictionaries.com:443/api/v1/inflections/' self.root_url = 'https://od-api.oxforddictionaries.com:443/api/v1/inflections/'
self.define_url = 'https://od-api.oxforddictionaries.com:443/api/v1/entries/' self.define_url = 'https://od-api.oxforddictionaries.com:443/api/v1/entries/'
self.root_url += self.language + '/'
self.define_url += self.language + '/'
self.pronunciation_mp3 = None self.pronunciation_mp3 = None
self.okButton.clicked.connect(self.hide) self.okButton.clicked.connect(self.hide)
self.pronounceButton.clicked.connect(self.play_pronunciation) self.pronounceButton.clicked.connect(self.play_pronunciation)
def api_call(self, url, word): def api_call(self, url, word):
url = url + word.lower() language = self.parent.settings['dictionary_language']
url = url + language + '/' + word.lower()
r = requests.get( r = requests.get(
url, url,
@@ -119,7 +109,8 @@ class DefinitionsUI(QtWidgets.QDialog, definitions.Ui_Dialog):
html_string += f'<h2><em><strong>{word}</strong></em></h2>\n' html_string += f'<h2><em><strong>{word}</strong></em></h2>\n'
if nothing_found: if nothing_found:
html_string += f'<p><em>No definitions found<em></p>\n' language = self.parent.settings['dictionary_language'].upper()
html_string += f'<p><em>No definitions found in {language}<em></p>\n'
else: else:
# Word root # Word root
html_string += f'<p><em>Word root: <em>{word_root}</p>\n' html_string += f'<p><em>Word root: <em>{word_root}</p>\n'
@@ -137,6 +128,21 @@ class DefinitionsUI(QtWidgets.QDialog, definitions.Ui_Dialog):
self.definitionView.setHtml(html_string) self.definitionView.setHtml(html_string)
self.show() self.show()
def color_background(self, set_initial=False):
if set_initial:
background = self.parent.settings['dialog_background']
else:
self.previous_position = self.pos()
background = self.parent.get_color()
self.setStyleSheet(
"QDialog {{background-color: {0}}}".format(background.name()))
self.definitionView.setStyleSheet(
"QTextBrowser {{background-color: {0}}}".format(background.name()))
if not set_initial:
self.show()
def play_pronunciation(self): def play_pronunciation(self):
if not self.pronunciation_mp3: if not self.pronunciation_mp3:
return return
@@ -147,3 +153,12 @@ class DefinitionsUI(QtWidgets.QDialog, definitions.Ui_Dialog):
player = QtMultimedia.QMediaPlayer(self) player = QtMultimedia.QMediaPlayer(self)
player.setMedia(media_content) player.setMedia(media_content)
player.play() player.play()
def showEvent(self, event):
self.color_background(True)
size = self.size()
desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
top = (desktop_size.height() / 2) - (size.height() / 2)
left = (desktop_size.width() / 2) - (size.width() / 2)
self.move(left, top)

View File

@@ -33,21 +33,14 @@ class MetadataUI(QtWidgets.QDialog, metadata.Ui_Dialog):
QtCore.Qt.Popup | QtCore.Qt.Popup |
QtCore.Qt.FramelessWindowHint) QtCore.Qt.FramelessWindowHint)
self.parent = parent
radius = 15 radius = 15
path = QtGui.QPainterPath() path = QtGui.QPainterPath()
path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius) path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
mask = QtGui.QRegion(path.toFillPolygon().toPolygon()) mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
self.setMask(mask) self.setMask(mask)
foreground = QtGui.QColor().fromRgb(230, 230, 230)
background = QtGui.QColor().fromRgb(0, 0, 0)
self.setStyleSheet(
"QDialog {{color: {0}; background-color: {1}}}".format(
foreground.name(), background.name()))
self.coverView.setStyleSheet(
"QGraphicsView {{color: {0}; background-color: {1}}}".format(
foreground.name(), background.name()))
self.parent = parent self.parent = parent
self.database_path = self.parent.database_path self.database_path = self.parent.database_path
@@ -61,7 +54,7 @@ class MetadataUI(QtWidgets.QDialog, metadata.Ui_Dialog):
self.okButton.clicked.connect(self.ok_pressed) self.okButton.clicked.connect(self.ok_pressed)
self.cancelButton.clicked.connect(self.cancel_pressed) self.cancelButton.clicked.connect(self.cancel_pressed)
self.colorButton.clicked.connect(self.color_background) self.dialogBackground.clicked.connect(self.color_background)
self.titleLine.returnPressed.connect(self.ok_pressed) self.titleLine.returnPressed.connect(self.ok_pressed)
self.authorLine.returnPressed.connect(self.ok_pressed) self.authorLine.returnPressed.connect(self.ok_pressed)
@@ -148,8 +141,20 @@ class MetadataUI(QtWidgets.QDialog, metadata.Ui_Dialog):
return QtCore.QPoint(display_x, display_y) return QtCore.QPoint(display_x, display_y)
def color_background(self): def color_background(self, set_initial=False):
pass if set_initial:
background = self.parent.settings['dialog_background']
else:
self.previous_position = self.pos()
background = self.parent.get_color()
self.setStyleSheet(
"QDialog {{background-color: {0}}}".format(background.name()))
self.coverView.setStyleSheet(
"QGraphicsView {{background-color: {0}}}".format(background.name()))
if not set_initial:
self.show()
def showEvent(self, event): def showEvent(self, event):
if self.previous_position: if self.previous_position:
@@ -159,3 +164,4 @@ class MetadataUI(QtWidgets.QDialog, metadata.Ui_Dialog):
self.move(display_position) self.move(display_position)
self.titleLine.setFocus() self.titleLine.setFocus()
self.color_background(True)

View File

@@ -45,6 +45,15 @@ class Ui_Dialog(object):
self.horizontalLayout.addWidget(self.pronounceButton) self.horizontalLayout.addWidget(self.pronounceButton)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1) self.horizontalLayout.addItem(spacerItem1)
self.dialogBackground = QtWidgets.QPushButton(Dialog)
self.dialogBackground.setText("")
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/images/color.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.dialogBackground.setIcon(icon2)
self.dialogBackground.setIconSize(QtCore.QSize(27, 27))
self.dialogBackground.setFlat(True)
self.dialogBackground.setObjectName("dialogBackground")
self.horizontalLayout.addWidget(self.dialogBackground)
self.verticalLayout.addLayout(self.horizontalLayout) self.verticalLayout.addLayout(self.horizontalLayout)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)

View File

@@ -67,15 +67,15 @@ class Ui_Dialog(object):
self.horizontalLayout_2.addWidget(self.cancelButton) self.horizontalLayout_2.addWidget(self.cancelButton)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1) self.horizontalLayout_2.addItem(spacerItem1)
self.colorButton = QtWidgets.QPushButton(Dialog) self.dialogBackground = QtWidgets.QPushButton(Dialog)
self.colorButton.setText("") self.dialogBackground.setText("")
icon2 = QtGui.QIcon() icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/images/color.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon2.addPixmap(QtGui.QPixmap(":/images/color.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.colorButton.setIcon(icon2) self.dialogBackground.setIcon(icon2)
self.colorButton.setIconSize(QtCore.QSize(27, 27)) self.dialogBackground.setIconSize(QtCore.QSize(27, 27))
self.colorButton.setFlat(True) self.dialogBackground.setFlat(True)
self.colorButton.setObjectName("colorButton") self.dialogBackground.setObjectName("dialogBackground")
self.horizontalLayout_2.addWidget(self.colorButton) self.horizontalLayout_2.addWidget(self.dialogBackground)
self.verticalLayout.addLayout(self.horizontalLayout_2) self.verticalLayout.addLayout(self.horizontalLayout_2)
self.horizontalLayout.addLayout(self.verticalLayout) self.horizontalLayout.addLayout(self.verticalLayout)
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)

View File

@@ -100,6 +100,26 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="dialogBackground">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/color.svg</normaloff>:/images/color.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>27</width>
<height>27</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@@ -170,7 +170,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="colorButton"> <widget class="QPushButton" name="dialogBackground">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>929</width> <width>1009</width>
<height>638</height> <height>658</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -93,11 +93,27 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="text"> <item>
<string>OCPD</string> <widget class="QLabel" name="languageLabel">
</property> <property name="sizePolicy">
</widget> <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Dictionary:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="languageBox"/>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>

View File

@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'raw/settings.ui' # Form implementation generated from reading ui file 'raw/settings.ui'
# #
# Created by: PyQt5 UI code generator 5.10 # Created by: PyQt5 UI code generator 5.10.1
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@@ -11,7 +11,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object): class Ui_Dialog(object):
def setupUi(self, Dialog): def setupUi(self, Dialog):
Dialog.setObjectName("Dialog") Dialog.setObjectName("Dialog")
Dialog.resize(929, 638) Dialog.resize(1009, 658)
self.gridLayout_3 = QtWidgets.QGridLayout(Dialog) self.gridLayout_3 = QtWidgets.QGridLayout(Dialog)
self.gridLayout_3.setObjectName("gridLayout_3") self.gridLayout_3.setObjectName("gridLayout_3")
self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2 = QtWidgets.QVBoxLayout()
@@ -56,9 +56,21 @@ class Ui_Dialog(object):
self.performCulling = QtWidgets.QCheckBox(self.groupBox) self.performCulling = QtWidgets.QCheckBox(self.groupBox)
self.performCulling.setObjectName("performCulling") self.performCulling.setObjectName("performCulling")
self.horizontalLayout.addWidget(self.performCulling) self.horizontalLayout.addWidget(self.performCulling)
self.checkBox = QtWidgets.QCheckBox(self.groupBox) self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.checkBox.setObjectName("checkBox") self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.horizontalLayout.addWidget(self.checkBox) self.languageLabel = QtWidgets.QLabel(self.groupBox)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.languageLabel.sizePolicy().hasHeightForWidth())
self.languageLabel.setSizePolicy(sizePolicy)
self.languageLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.languageLabel.setObjectName("languageLabel")
self.horizontalLayout_3.addWidget(self.languageLabel)
self.languageBox = QtWidgets.QComboBox(self.groupBox)
self.languageBox.setObjectName("languageBox")
self.horizontalLayout_3.addWidget(self.languageBox)
self.horizontalLayout.addLayout(self.horizontalLayout_3)
self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1) self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1)
self.verticalLayout_2.addWidget(self.groupBox) self.verticalLayout_2.addWidget(self.groupBox)
self.gridLayout_3.addLayout(self.verticalLayout_2, 0, 0, 1, 1) self.gridLayout_3.addLayout(self.verticalLayout_2, 0, 0, 1, 1)
@@ -90,7 +102,7 @@ class Ui_Dialog(object):
self.coverShadows.setText(_translate("Dialog", "Cover shadows")) self.coverShadows.setText(_translate("Dialog", "Cover shadows"))
self.performCulling.setToolTip(_translate("Dialog", "Enabling reduces startup time and memory usage")) self.performCulling.setToolTip(_translate("Dialog", "Enabling reduces startup time and memory usage"))
self.performCulling.setText(_translate("Dialog", "Load covers only when needed")) self.performCulling.setText(_translate("Dialog", "Load covers only when needed"))
self.checkBox.setText(_translate("Dialog", "OCPD")) self.languageLabel.setText(_translate("Dialog", "Dictionary:"))
self.okButton.setText(_translate("Dialog", "Scan Library")) self.okButton.setText(_translate("Dialog", "Scan Library"))
self.cancelButton.setText(_translate("Dialog", "Close")) self.cancelButton.setText(_translate("Dialog", "Close"))
self.aboutButton.setText(_translate("Dialog", "About")) self.aboutButton.setText(_translate("Dialog", "About"))

View File

@@ -96,6 +96,13 @@ class Settings:
'rememberFiles', 'True').capitalize()) 'rememberFiles', 'True').capitalize())
self.parent.settings['perform_culling'] = literal_eval(self.settings.value( self.parent.settings['perform_culling'] = literal_eval(self.settings.value(
'performCulling', 'True').capitalize()) 'performCulling', 'True').capitalize())
self.parent.settings['dictionary_language'] = self.settings.value(
'dictionaryLanguage', 'en')
self.settings.endGroup()
self.settings.beginGroup('dialogSettings')
self.parent.settings['dialog_background'] = self.settings.value(
'dialogBackground', QtGui.QColor().fromRgb(0, 0, 0))
self.settings.endGroup() self.settings.endGroup()
def save_settings(self): def save_settings(self):
@@ -157,4 +164,9 @@ class Settings:
self.settings.setValue('autoTags', current_settings['auto_tags']) self.settings.setValue('autoTags', current_settings['auto_tags'])
self.settings.setValue('scanLibraryAtStart', current_settings['scan_library']) self.settings.setValue('scanLibraryAtStart', current_settings['scan_library'])
self.settings.setValue('performCulling', current_settings['perform_culling']) self.settings.setValue('performCulling', current_settings['perform_culling'])
self.settings.setValue('dictionaryLanguage', current_settings['dictionary_language'])
self.settings.endGroup()
self.settings.beginGroup('dialogSettings')
self.settings.setValue('dialogBackground', current_settings['dialog_background'])
self.settings.endGroup() self.settings.endGroup()

View File

@@ -41,7 +41,8 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
self.move(self.parent.settings['settings_dialog_position']) self.move(self.parent.settings['settings_dialog_position'])
self.aboutBox.setVisible(False) self.aboutBox.setVisible(False)
with open('resources/about.html') as about_html: aboutfile_path = os.path.join('resources', 'about.html')
with open(aboutfile_path) as about_html:
self.aboutBox.setHtml(about_html.read()) self.aboutBox.setHtml(about_html.read())
self.paths = None self.paths = None
@@ -49,6 +50,17 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
self.filesystem_model = None self.filesystem_model = None
self.tag_data_copy = None self.tag_data_copy = None
languages = ['English', 'Spanish', 'Hindi']
self.languageBox.addItems(languages)
current_language = self.parent.settings['dictionary_language']
if current_language == 'en':
self.languageBox.setCurrentIndex(0)
elif current_language == 'es':
self.languageBox.setCurrentIndex(1)
else:
self.languageBox.setCurrentIndex(2)
self.languageBox.activated.connect(self.change_dictionary_language)
self.okButton.setToolTip('Save changes and start library scan') self.okButton.setToolTip('Save changes and start library scan')
self.okButton.clicked.connect(self.start_library_scan) self.okButton.clicked.connect(self.start_library_scan)
self.cancelButton.clicked.connect(self.cancel_pressed) self.cancelButton.clicked.connect(self.cancel_pressed)
@@ -101,7 +113,8 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
# Check and see # Check and see
root_directory = QtCore.QDir().rootPath() root_directory = QtCore.QDir().rootPath()
self.treeView.setRootIndex(self.filesystem_model.setRootPath(root_directory)) self.treeView.setRootIndex(
self.filesystem_model.setRootPath(root_directory))
# Set the treeView and QFileSystemModel to its desired state # Set the treeView and QFileSystemModel to its desired state
selected_paths = [ selected_paths = [
@@ -230,6 +243,13 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
table_headers.append(self.treeView.columnWidth(i)) table_headers.append(self.treeView.columnWidth(i))
self.parent.settings['settings_dialog_headers'] = table_headers self.parent.settings['settings_dialog_headers'] = table_headers
def change_dictionary_language(self, event):
language_dict = {
0: 'en',
1: 'es',
2: 'hi'}
self.parent.settings['dictionary_language'] = language_dict[self.languageBox.currentIndex()]
def manage_checkboxes(self, event=None): def manage_checkboxes(self, event=None):
sender = self.sender().objectName() sender = self.sender().objectName()

View File

@@ -410,7 +410,7 @@ class Tab(QtWidgets.QWidget):
self.bookmark_model.removeRow(index.row()) self.bookmark_model.removeRow(index.row())
def hide_mouse(self): def hide_mouse(self):
self.contentView.setCursor(QtCore.Qt.BlankCursor) self.contentView.viewport().setCursor(QtCore.Qt.BlankCursor)
def sneaky_change(self): def sneaky_change(self):
direction = -1 direction = -1
@@ -434,6 +434,7 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
self.ignore_wheel_event = False self.ignore_wheel_event = False
self.ignore_wheel_event_number = 0 self.ignore_wheel_event_number = 0
self.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag) self.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)
self.viewport().setCursor(QtCore.Qt.ArrowCursor)
self.common_functions = PliantWidgetsCommonFunctions( self.common_functions = PliantWidgetsCommonFunctions(
self, self.main_window) self, self.main_window)
self.setMouseTracking(True) self.setMouseTracking(True)
@@ -560,7 +561,7 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
self.verticalScrollBar().setValue(vertical + scroll_increment) self.verticalScrollBar().setValue(vertical + scroll_increment)
def mouseMoveEvent(self, *args): def mouseMoveEvent(self, *args):
self.setCursor(QtCore.Qt.ArrowCursor) self.viewport().setCursor(QtCore.Qt.ArrowCursor)
self.parent.mouse_hide_timer.start(3000) self.parent.mouse_hide_timer.start(3000)
def closeEvent(self, *args): def closeEvent(self, *args):
@@ -582,6 +583,7 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect( self.customContextMenuRequested.connect(
self.generate_textbrowser_context_menu) self.generate_textbrowser_context_menu)
self.viewport().setCursor(QtCore.Qt.IBeamCursor)
def wheelEvent(self, event): def wheelEvent(self, event):
self.record_scroll_position() self.record_scroll_position()
@@ -600,6 +602,8 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
QtWidgets.QTextEdit.keyPressEvent(self, event) QtWidgets.QTextEdit.keyPressEvent(self, event)
def record_scroll_position(self, return_as_bookmark=False): def record_scroll_position(self, return_as_bookmark=False):
self.parent.metadata['position']['is_read'] = False
vertical = self.verticalScrollBar().value() vertical = self.verticalScrollBar().value()
maximum = self.verticalScrollBar().maximum() maximum = self.verticalScrollBar().maximum()
@@ -648,12 +652,10 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
def closeEvent(self, *args): def closeEvent(self, *args):
self.main_window.closeEvent() self.main_window.closeEvent()
# def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
# TODO event.accept()
# This does not work as expected self.viewport().setCursor(QtCore.Qt.IBeamCursor)
# event.accept() self.parent.mouse_hide_timer.start(3000)
# self.setCursor(QtCore.Qt.ArrowCursor)
# self.parent.mouse_hide_timer.start(3000)
class PliantWidgetsCommonFunctions(): class PliantWidgetsCommonFunctions():