Redesign settings dialog

Remove dependency on requests
This commit is contained in:
BasioMeusPuga
2018-03-23 23:56:01 +05:30
parent 6ffa6934ed
commit 5e53d40e68
6 changed files with 409 additions and 297 deletions

View File

@@ -16,7 +16,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import requests import json
import urllib.request
from PyQt5 import QtWidgets, QtCore, QtGui, QtMultimedia from PyQt5 import QtWidgets, QtCore, QtGui, QtMultimedia
from lector.resources import definitions from lector.resources import definitions
@@ -57,18 +58,21 @@ class DefinitionsUI(QtWidgets.QDialog, definitions.Ui_Dialog):
language = self.parent.settings['dictionary_language'] language = self.parent.settings['dictionary_language']
url = url + language + '/' + word.lower() url = url + language + '/' + word.lower()
r = requests.get( req = urllib.request.Request(url)
url, req.add_header('app_id', self.app_id)
headers={'app_id': self.app_id, 'app_key': self.app_key}) req.add_header('app_key', self.app_key)
if r.status_code != 200: try:
print('A firm nope on the dictionary finding thing') response = urllib.request.urlopen(req)
if response.getcode() == 200:
return_json = json.loads(response.read())
return return_json
except urllib.error.HTTPError:
return None return None
return r.json()
def find_definition(self, word): def find_definition(self, word):
word_root_json = self.api_call(self.root_url, word) word_root_json = self.api_call(self.root_url, word)
print(word_root_json)
if not word_root_json: if not word_root_json:
self.set_text(word, None, None, True) self.set_text(word, None, None, True)
return return
@@ -78,6 +82,7 @@ class DefinitionsUI(QtWidgets.QDialog, definitions.Ui_Dialog):
definition_json = self.api_call(self.define_url, word_root) definition_json = self.api_call(self.define_url, word_root)
if not definition_json: if not definition_json:
self.set_text(word, None, None, True)
return return
definitions = {} definitions = {}

View File

@@ -6,206 +6,264 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1216</width> <width>1022</width>
<height>658</height> <height>513</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Settings</string> <string>Settings</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QListView" name="listView">
<item> <property name="sizePolicy">
<widget class="QGroupBox" name="groupBox_2"> <sizepolicy hsizetype="Maximum" vsizetype="Expanding">
<property name="title"> <horstretch>0</horstretch>
<string>Library</string> <verstretch>0</verstretch>
</property> </sizepolicy>
<layout class="QGridLayout" name="gridLayout_2"> </property>
<item row="0" column="0"> </widget>
<widget class="QTreeView" name="treeView"/>
</item>
<item row="1" column="0">
<widget class="QTextBrowser" name="aboutBox">
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="openLinks">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Switches</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="refreshLibrary">
<property name="text">
<string>Startup: Refresh library</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fileRemember">
<property name="text">
<string>Remember open files</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="performCulling">
<property name="toolTip">
<string>Enabling reduces startup time and memory usage</string>
</property>
<property name="text">
<string>Load covers only when needed</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="coverShadows">
<property name="text">
<string>Cover shadows</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoTags">
<property name="text">
<string>Generate tags from files</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cachingEnabled">
<property name="toolTip">
<string>Greatly reduces page transition time at the cost of more memory</string>
</property>
<property name="text">
<string>Cache comic / pdf pages</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="languageLabel">
<property name="sizePolicy">
<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>
<widget class="QCheckBox" name="hideScrollBars">
<property name="toolTip">
<string>Horizontal scrolling with Alt + Scroll
Reopen book to see changes</string>
</property>
<property name="text">
<string>Hide scrollbars when reading</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Restart application to see changes</string>
</property>
<property name="text">
<string>Icon theme: </string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="darkIconsRadio">
<property name="toolTip">
<string>Restart application to see changes</string>
</property>
<property name="text">
<string>Dar&amp;k</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="lightIconsRadio">
<property name="toolTip">
<string>Restart application to see changes</string>
</property>
<property name="text">
<string>&amp;Light</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item> </item>
<item row="1" column="0"> <item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="QPushButton" name="okButton"> <widget class="QStackedWidget" name="stackedWidget">
<property name="text"> <widget class="QWidget" name="treeViewPage">
<string>Scan Library</string> <layout class="QGridLayout" name="gridLayout_5">
</property> <item row="0" column="0">
<widget class="QTreeView" name="treeView"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="switchPage">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Library</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="refreshLibrary">
<property name="text">
<string>Startup: Refresh library</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fileRemember">
<property name="text">
<string>Remember open files</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="coverShadows">
<property name="text">
<string>Cover shadows</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="performCulling">
<property name="toolTip">
<string>Enabling reduces startup time and memory usage</string>
</property>
<property name="text">
<string>Load covers only when needed</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QCheckBox" name="autoTags">
<property name="text">
<string>Generate tags from files</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Restart application to see changes</string>
</property>
<property name="text">
<string>Icon theme: </string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="darkIconsRadio">
<property name="toolTip">
<string>Restart application to see changes</string>
</property>
<property name="text">
<string>&amp;Dark</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="lightIconsRadio">
<property name="toolTip">
<string>Restart application to see changes</string>
</property>
<property name="text">
<string>L&amp;ight</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Reading</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="hideScrollBars">
<property name="toolTip">
<string>Horizontal scrolling with Alt + Scroll
Reopen book to see changes</string>
</property>
<property name="text">
<string>Hide scrollbars when reading</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cachingEnabled">
<property name="toolTip">
<string>Greatly reduces page transition time at the cost of more memory</string>
</property>
<property name="text">
<string>Cache comic / pdf pages</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="languageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Dictionary language:</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>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="aboutPage">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QTextBrowser" name="aboutBox">
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="openLinks">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="cancelButton"> <layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="text"> <item>
<string>Close</string> <spacer name="horizontalSpacer">
</property> <property name="orientation">
</widget> <enum>Qt::Horizontal</enum>
</item> </property>
<item> <property name="sizeHint" stdset="0">
<widget class="QPushButton" name="aboutButton"> <size>
<property name="text"> <width>40</width>
<string>About</string> <height>20</height>
</property> </size>
<property name="checkable"> </property>
<bool>true</bool> </spacer>
</property> </item>
</widget> <item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>Scan Library</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'raw/settings.ui' # Form implementation generated from reading ui file 'raw/settings2.ui'
# #
# Created by: PyQt5 UI code generator 5.10.1 # Created by: PyQt5 UI code generator 5.10.1
# #
@@ -11,30 +11,41 @@ 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(1216, 658) Dialog.resize(1022, 513)
self.gridLayout_3 = QtWidgets.QGridLayout(Dialog) self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout_3.setObjectName("gridLayout_3")
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.groupBox_2 = QtWidgets.QGroupBox(Dialog)
self.groupBox_2.setObjectName("groupBox_2")
self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox_2)
self.gridLayout_2.setObjectName("gridLayout_2")
self.treeView = QtWidgets.QTreeView(self.groupBox_2)
self.treeView.setObjectName("treeView")
self.gridLayout_2.addWidget(self.treeView, 0, 0, 1, 1)
self.aboutBox = QtWidgets.QTextBrowser(self.groupBox_2)
self.aboutBox.setOpenExternalLinks(True)
self.aboutBox.setOpenLinks(False)
self.aboutBox.setObjectName("aboutBox")
self.gridLayout_2.addWidget(self.aboutBox, 1, 0, 1, 1)
self.verticalLayout_2.addWidget(self.groupBox_2)
self.groupBox = QtWidgets.QGroupBox(Dialog)
self.groupBox.setObjectName("groupBox")
self.gridLayout = QtWidgets.QGridLayout(self.groupBox)
self.gridLayout.setObjectName("gridLayout") self.gridLayout.setObjectName("gridLayout")
self.listView = QtWidgets.QListView(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.listView.sizePolicy().hasHeightForWidth())
self.listView.setSizePolicy(sizePolicy)
self.listView.setObjectName("listView")
self.gridLayout.addWidget(self.listView, 0, 0, 1, 1)
self.verticalLayout_4 = QtWidgets.QVBoxLayout()
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.stackedWidget = QtWidgets.QStackedWidget(Dialog)
self.stackedWidget.setObjectName("stackedWidget")
self.treeViewPage = QtWidgets.QWidget()
self.treeViewPage.setObjectName("treeViewPage")
self.gridLayout_5 = QtWidgets.QGridLayout(self.treeViewPage)
self.gridLayout_5.setObjectName("gridLayout_5")
self.treeView = QtWidgets.QTreeView(self.treeViewPage)
self.treeView.setObjectName("treeView")
self.gridLayout_5.addWidget(self.treeView, 0, 0, 1, 1)
self.stackedWidget.addWidget(self.treeViewPage)
self.switchPage = QtWidgets.QWidget()
self.switchPage.setObjectName("switchPage")
self.gridLayout_2 = QtWidgets.QGridLayout(self.switchPage)
self.gridLayout_2.setObjectName("gridLayout_2")
self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout.setObjectName("verticalLayout")
self.groupBox = QtWidgets.QGroupBox(self.switchPage)
self.groupBox.setObjectName("groupBox")
self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBox)
self.gridLayout_4.setObjectName("gridLayout_4")
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout() self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.refreshLibrary = QtWidgets.QCheckBox(self.groupBox) self.refreshLibrary = QtWidgets.QCheckBox(self.groupBox)
@@ -43,28 +54,56 @@ class Ui_Dialog(object):
self.fileRemember = QtWidgets.QCheckBox(self.groupBox) self.fileRemember = QtWidgets.QCheckBox(self.groupBox)
self.fileRemember.setObjectName("fileRemember") self.fileRemember.setObjectName("fileRemember")
self.horizontalLayout_4.addWidget(self.fileRemember) self.horizontalLayout_4.addWidget(self.fileRemember)
self.performCulling = QtWidgets.QCheckBox(self.groupBox) self.verticalLayout_2.addLayout(self.horizontalLayout_4)
self.performCulling.setObjectName("performCulling")
self.horizontalLayout_4.addWidget(self.performCulling)
self.verticalLayout.addLayout(self.horizontalLayout_4)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.coverShadows = QtWidgets.QCheckBox(self.groupBox)
self.coverShadows.setObjectName("coverShadows")
self.horizontalLayout.addWidget(self.coverShadows)
self.autoTags = QtWidgets.QCheckBox(self.groupBox)
self.autoTags.setObjectName("autoTags")
self.horizontalLayout.addWidget(self.autoTags)
self.cachingEnabled = QtWidgets.QCheckBox(self.groupBox)
self.cachingEnabled.setObjectName("cachingEnabled")
self.horizontalLayout.addWidget(self.cachingEnabled)
self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1)
self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.languageLabel = QtWidgets.QLabel(self.groupBox) self.coverShadows = QtWidgets.QCheckBox(self.groupBox)
self.coverShadows.setObjectName("coverShadows")
self.horizontalLayout_3.addWidget(self.coverShadows)
self.performCulling = QtWidgets.QCheckBox(self.groupBox)
self.performCulling.setObjectName("performCulling")
self.horizontalLayout_3.addWidget(self.performCulling)
self.verticalLayout_2.addLayout(self.horizontalLayout_3)
self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
self.horizontalLayout_9.setObjectName("horizontalLayout_9")
self.autoTags = QtWidgets.QCheckBox(self.groupBox)
self.autoTags.setObjectName("autoTags")
self.horizontalLayout_9.addWidget(self.autoTags)
self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
self.label = QtWidgets.QLabel(self.groupBox)
self.label.setObjectName("label")
self.horizontalLayout_7.addWidget(self.label)
self.darkIconsRadio = QtWidgets.QRadioButton(self.groupBox)
self.darkIconsRadio.setObjectName("darkIconsRadio")
self.horizontalLayout_7.addWidget(self.darkIconsRadio)
self.lightIconsRadio = QtWidgets.QRadioButton(self.groupBox)
self.lightIconsRadio.setObjectName("lightIconsRadio")
self.horizontalLayout_7.addWidget(self.lightIconsRadio)
self.horizontalLayout_9.addLayout(self.horizontalLayout_7)
self.verticalLayout_2.addLayout(self.horizontalLayout_9)
self.gridLayout_4.addLayout(self.verticalLayout_2, 0, 0, 1, 1)
self.verticalLayout.addWidget(self.groupBox)
self.groupBox_2 = QtWidgets.QGroupBox(self.switchPage)
self.groupBox_2.setObjectName("groupBox_2")
self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBox_2)
self.gridLayout_3.setObjectName("gridLayout_3")
self.verticalLayout_3 = QtWidgets.QVBoxLayout()
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.hideScrollBars = QtWidgets.QCheckBox(self.groupBox_2)
self.hideScrollBars.setObjectName("hideScrollBars")
self.horizontalLayout_6.addWidget(self.hideScrollBars)
self.cachingEnabled = QtWidgets.QCheckBox(self.groupBox_2)
self.cachingEnabled.setObjectName("cachingEnabled")
self.horizontalLayout_6.addWidget(self.cachingEnabled)
self.verticalLayout_3.addLayout(self.horizontalLayout_6)
self.horizontalLayout_8 = QtWidgets.QHBoxLayout()
self.horizontalLayout_8.setObjectName("horizontalLayout_8")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.languageLabel = QtWidgets.QLabel(self.groupBox_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
@@ -72,42 +111,41 @@ class Ui_Dialog(object):
self.languageLabel.setSizePolicy(sizePolicy) self.languageLabel.setSizePolicy(sizePolicy)
self.languageLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) self.languageLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.languageLabel.setObjectName("languageLabel") self.languageLabel.setObjectName("languageLabel")
self.horizontalLayout_3.addWidget(self.languageLabel) self.horizontalLayout_5.addWidget(self.languageLabel)
self.languageBox = QtWidgets.QComboBox(self.groupBox) self.languageBox = QtWidgets.QComboBox(self.groupBox_2)
self.languageBox.setObjectName("languageBox") self.languageBox.setObjectName("languageBox")
self.horizontalLayout_3.addWidget(self.languageBox) self.horizontalLayout_5.addWidget(self.languageBox)
self.horizontalLayout_6.addLayout(self.horizontalLayout_3) self.horizontalLayout_8.addLayout(self.horizontalLayout_5)
self.hideScrollBars = QtWidgets.QCheckBox(self.groupBox) self.verticalLayout_3.addLayout(self.horizontalLayout_8)
self.hideScrollBars.setObjectName("hideScrollBars") self.gridLayout_3.addLayout(self.verticalLayout_3, 2, 0, 1, 1)
self.horizontalLayout_6.addWidget(self.hideScrollBars) self.verticalLayout.addWidget(self.groupBox_2)
self.horizontalLayout_5 = QtWidgets.QHBoxLayout() self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
self.horizontalLayout_5.setObjectName("horizontalLayout_5") spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.label = QtWidgets.QLabel(self.groupBox) self.gridLayout_2.addItem(spacerItem, 1, 0, 1, 1)
self.label.setObjectName("label") self.stackedWidget.addWidget(self.switchPage)
self.horizontalLayout_5.addWidget(self.label) self.aboutPage = QtWidgets.QWidget()
self.darkIconsRadio = QtWidgets.QRadioButton(self.groupBox) self.aboutPage.setObjectName("aboutPage")
self.darkIconsRadio.setObjectName("darkIconsRadio") self.gridLayout_6 = QtWidgets.QGridLayout(self.aboutPage)
self.horizontalLayout_5.addWidget(self.darkIconsRadio) self.gridLayout_6.setObjectName("gridLayout_6")
self.lightIconsRadio = QtWidgets.QRadioButton(self.groupBox) self.aboutBox = QtWidgets.QTextBrowser(self.aboutPage)
self.lightIconsRadio.setObjectName("lightIconsRadio") self.aboutBox.setOpenExternalLinks(True)
self.horizontalLayout_5.addWidget(self.lightIconsRadio) self.aboutBox.setOpenLinks(False)
self.horizontalLayout_6.addLayout(self.horizontalLayout_5) self.aboutBox.setObjectName("aboutBox")
self.gridLayout.addLayout(self.horizontalLayout_6, 2, 0, 1, 1) self.gridLayout_6.addWidget(self.aboutBox, 0, 0, 1, 1)
self.verticalLayout_2.addWidget(self.groupBox) self.stackedWidget.addWidget(self.aboutPage)
self.gridLayout_3.addLayout(self.verticalLayout_2, 0, 0, 1, 1) self.verticalLayout_4.addWidget(self.stackedWidget)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.horizontalLayout_10.setObjectName("horizontalLayout_10")
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_10.addItem(spacerItem1)
self.okButton = QtWidgets.QPushButton(Dialog) self.okButton = QtWidgets.QPushButton(Dialog)
self.okButton.setObjectName("okButton") self.okButton.setObjectName("okButton")
self.horizontalLayout_2.addWidget(self.okButton) self.horizontalLayout_10.addWidget(self.okButton)
self.cancelButton = QtWidgets.QPushButton(Dialog) self.cancelButton = QtWidgets.QPushButton(Dialog)
self.cancelButton.setObjectName("cancelButton") self.cancelButton.setObjectName("cancelButton")
self.horizontalLayout_2.addWidget(self.cancelButton) self.horizontalLayout_10.addWidget(self.cancelButton)
self.aboutButton = QtWidgets.QPushButton(Dialog) self.verticalLayout_4.addLayout(self.horizontalLayout_10)
self.aboutButton.setCheckable(True) self.gridLayout.addLayout(self.verticalLayout_4, 0, 1, 1, 1)
self.aboutButton.setObjectName("aboutButton")
self.horizontalLayout_2.addWidget(self.aboutButton)
self.gridLayout_3.addLayout(self.horizontalLayout_2, 1, 0, 1, 1)
self.retranslateUi(Dialog) self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
@@ -115,27 +153,26 @@ class Ui_Dialog(object):
def retranslateUi(self, Dialog): def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Settings")) Dialog.setWindowTitle(_translate("Dialog", "Settings"))
self.groupBox_2.setTitle(_translate("Dialog", "Library")) self.groupBox.setTitle(_translate("Dialog", "Library"))
self.groupBox.setTitle(_translate("Dialog", "Switches"))
self.refreshLibrary.setText(_translate("Dialog", "Startup: Refresh library")) self.refreshLibrary.setText(_translate("Dialog", "Startup: Refresh library"))
self.fileRemember.setText(_translate("Dialog", "Remember open files")) self.fileRemember.setText(_translate("Dialog", "Remember open files"))
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.coverShadows.setText(_translate("Dialog", "Cover shadows"))
self.autoTags.setText(_translate("Dialog", "Generate tags from files")) self.autoTags.setText(_translate("Dialog", "Generate tags from files"))
self.cachingEnabled.setToolTip(_translate("Dialog", "Greatly reduces page transition time at the cost of more memory"))
self.cachingEnabled.setText(_translate("Dialog", "Cache comic / pdf pages"))
self.languageLabel.setText(_translate("Dialog", "Dictionary:"))
self.hideScrollBars.setToolTip(_translate("Dialog", "Horizontal scrolling with Alt + Scroll\n"
"Reopen book to see changes"))
self.hideScrollBars.setText(_translate("Dialog", "Hide scrollbars when reading"))
self.label.setToolTip(_translate("Dialog", "Restart application to see changes")) self.label.setToolTip(_translate("Dialog", "Restart application to see changes"))
self.label.setText(_translate("Dialog", "Icon theme: ")) self.label.setText(_translate("Dialog", "Icon theme: "))
self.darkIconsRadio.setToolTip(_translate("Dialog", "Restart application to see changes")) self.darkIconsRadio.setToolTip(_translate("Dialog", "Restart application to see changes"))
self.darkIconsRadio.setText(_translate("Dialog", "Dar&k")) self.darkIconsRadio.setText(_translate("Dialog", "&Dark"))
self.lightIconsRadio.setToolTip(_translate("Dialog", "Restart application to see changes")) self.lightIconsRadio.setToolTip(_translate("Dialog", "Restart application to see changes"))
self.lightIconsRadio.setText(_translate("Dialog", "&Light")) self.lightIconsRadio.setText(_translate("Dialog", "L&ight"))
self.groupBox_2.setTitle(_translate("Dialog", "Reading"))
self.hideScrollBars.setToolTip(_translate("Dialog", "Horizontal scrolling with Alt + Scroll\n"
"Reopen book to see changes"))
self.hideScrollBars.setText(_translate("Dialog", "Hide scrollbars when reading"))
self.cachingEnabled.setToolTip(_translate("Dialog", "Greatly reduces page transition time at the cost of more memory"))
self.cachingEnabled.setText(_translate("Dialog", "Cache comic / pdf pages"))
self.languageLabel.setText(_translate("Dialog", "Dictionary language:"))
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"))

View File

@@ -22,7 +22,7 @@
import os import os
import copy import copy
import pathlib import pathlib
from PyQt5 import QtWidgets, QtCore from PyQt5 import QtWidgets, QtCore, QtGui
from lector import database from lector import database
from lector.models import MostExcellentFileSystemModel from lector.models import MostExcellentFileSystemModel
@@ -42,7 +42,6 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
self.resize(self.parent.settings['settings_dialog_size']) self.resize(self.parent.settings['settings_dialog_size'])
self.move(self.parent.settings['settings_dialog_position']) self.move(self.parent.settings['settings_dialog_position'])
self.aboutBox.setVisible(False)
install_dir = os.path.realpath(__file__) install_dir = os.path.realpath(__file__)
install_dir = pathlib.Path(install_dir).parents[1] install_dir = pathlib.Path(install_dir).parents[1]
aboutfile_path = os.path.join(install_dir, 'lector', 'resources', 'about.html') aboutfile_path = os.path.join(install_dir, 'lector', 'resources', 'about.html')
@@ -73,7 +72,6 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
self._translate('SettingsUI', 'Save changes and start library scan')) self._translate('SettingsUI', '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)
self.aboutButton.clicked.connect(self.about_pressed)
# Radio buttons # Radio buttons
if self.parent.settings['icon_theme'] == 'DarkIcons': if self.parent.settings['icon_theme'] == 'DarkIcons':
@@ -100,6 +98,21 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
self.cachingEnabled.clicked.connect(self.manage_checkboxes) self.cachingEnabled.clicked.connect(self.manage_checkboxes)
self.hideScrollBars.clicked.connect(self.manage_checkboxes) self.hideScrollBars.clicked.connect(self.manage_checkboxes)
# Generate the QStandardItemModel for the listView
self.listModel = QtGui.QStandardItemModel()
library_string = self._translate('SettingsUI', 'Library')
switches_string = self._translate('SettingsUI', 'Switches')
about_string = self._translate('SettingsUI', 'About')
list_options = [library_string, switches_string, about_string]
for i in list_options:
item = QtGui.QStandardItem()
item.setText(i)
self.listModel.appendRow(item)
self.listView.setModel(self.listModel)
self.listView.clicked.connect(self.page_switch)
# Generate the filesystem treeView # Generate the filesystem treeView
self.generate_tree() self.generate_tree()
@@ -237,6 +250,13 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
self.thread.finished.connect(self.parent.move_on) self.thread.finished.connect(self.parent.move_on)
self.thread.start() self.thread.start()
def page_switch(self, index):
self.stackedWidget.setCurrentIndex(index.row())
if index.row() == 0:
self.okButton.setVisible(True)
else:
self.okButton.setVisible(False)
def cancel_pressed(self): def cancel_pressed(self):
self.filesystem_model.tag_data = copy.deepcopy(self.tag_data_copy) self.filesystem_model.tag_data = copy.deepcopy(self.tag_data_copy)
self.hide() self.hide()
@@ -251,8 +271,6 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
def no_more_settings(self): def no_more_settings(self):
self.parent.libraryToolBar.settingsButton.setChecked(False) self.parent.libraryToolBar.settingsButton.setChecked(False)
self.aboutBox.hide()
self.treeView.show()
self.resizeEvent() self.resizeEvent()
def resizeEvent(self, event=None): def resizeEvent(self, event=None):
@@ -292,7 +310,3 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
if not self.performCulling.isChecked(): if not self.performCulling.isChecked():
self.parent.load_all_covers() self.parent.load_all_covers()
def about_pressed(self):
self.treeView.setVisible(not self.treeView.isVisible())
self.aboutBox.setVisible(not self.aboutBox.isVisible())

View File

@@ -890,9 +890,9 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
self.main_window.closeEvent() self.main_window.closeEvent()
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
event.accept()
self.viewport().setCursor(QtCore.Qt.IBeamCursor) self.viewport().setCursor(QtCore.Qt.IBeamCursor)
self.parent.mouse_hide_timer.start(3000) self.parent.mouse_hide_timer.start(3000)
QtWidgets.QTextBrowser.mouseMoveEvent(self, event)
class PliantWidgetsCommonFunctions(): class PliantWidgetsCommonFunctions():

View File

@@ -6,17 +6,15 @@ HERE = path.abspath(path.dirname(__file__))
MAJOR_VERSION = '0' MAJOR_VERSION = '0'
MINOR_VERSION = '3' MINOR_VERSION = '3'
MICRO_VERSION = '0' MICRO_VERSION = '2'
VERSION = "{}.{}.{}".format(MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION) VERSION = "{}.{}.{}".format(MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)
# Get the long description from the README file # Get the long description from the README file
with codecs.open(path.join(HERE, 'README.md'), encoding='utf-8') as f: with codecs.open(path.join(HERE, 'README.md'), encoding='utf-8') as f:
LONG_DESC = f.read() LONG_DESC = f.read()
INSTALL_DEPS = ['requests', INSTALL_DEPS = ['beautifulsoup4']
'beautifulsoup4'] TEST_DEPS = []
TEST_DEPS = ['pytest',
'unittest2']
DEV_DEPS = [] DEV_DEPS = []
setup( setup(