diff --git a/__main__.py b/__main__.py
index 6752d93..a507df2 100755
--- a/__main__.py
+++ b/__main__.py
@@ -70,18 +70,21 @@ from PyQt5 import QtWidgets, QtGui, QtCore
import sorter
import database
-from resources import mainwindow, settingswindow
+from resources import mainwindow
from widgets import LibraryToolBar, BookToolBar, Tab
from widgets import LibraryDelegate, BackGroundTabUpdate, BackGroundBookAddition
from library import Library
from settings import Settings
+from settingsdialog import SettingsUI
+
class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def __init__(self):
super(MainUI, self).__init__()
self.setupUi(self)
+ # Initialize settings dialog
self.settings_dialog = SettingsUI()
# Empty variables that will be infested soon
@@ -93,7 +96,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.current_contentView = None # For fullscreening purposes
self.display_profiles = None
self.current_profile_index = None
- # self.comic_profile = None
+ self.database_path = None
# Initialize application
Settings(self).read_settings() # This should populate all variables that need
@@ -101,11 +104,16 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# Create the database in case it doesn't exist
database.DatabaseInit(self.database_path)
+ self.settings_dialog.database_path = self.database_path
# Create and right align the statusbar label widget
self.statusMessage = QtWidgets.QLabel()
self.statusMessage.setObjectName('statusMessage')
self.statusBar.addPermanentWidget(self.statusMessage)
+ self.sorterProgress = QtWidgets.QProgressBar()
+ self.sorterProgress.setObjectName('sorterProgress')
+ self.statusBar.addWidget(self.sorterProgress)
+ self.sorterProgress.hide()
# Init the QListView
self.lib_ref = Library(self)
@@ -158,9 +166,15 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# Tab closing
self.tabWidget.setTabsClosable(True)
+
# TODO
- # It's possible to add a widget to the Library tab here
- self.tabWidget.tabBar().setTabButton(0, QtWidgets.QTabBar.RightSide, None)
+ # Associate this with the library switcher
+ library_subclass = QtWidgets.QToolButton()
+ library_subclass.setIcon(QtGui.QIcon.fromTheme('view-readermode'))
+ library_subclass.setAutoRaise(True)
+ library_subclass.setPopupMode(QtWidgets.QToolButton.InstantPopup)
+
+ self.tabWidget.tabBar().setTabButton(0, QtWidgets.QTabBar.RightSide, library_subclass)
self.tabWidget.tabCloseRequested.connect(self.tab_close)
# ListView
@@ -181,6 +195,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.ks_exit_all.setContext(QtCore.Qt.ApplicationShortcut)
self.ks_exit_all.activated.connect(self.closeEvent)
+ self.listView.setFocus()
+
# Open last... open books.
self.open_files(self.last_open_books)
self.last_open_books = None
@@ -377,6 +393,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
file_paths,
'reading',
self.database_path,
+ self,
self.temp_dir.path()).initiate_threads()
found_a_focusable_tab = False
@@ -393,32 +410,42 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
if not found_a_focusable_tab:
self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1)
+ self.format_contentView()
+
def get_color(self):
signal_sender = self.sender().objectName()
profile_index = self.bookToolBar.profileBox.currentIndex()
current_profile = self.bookToolBar.profileBox.itemData(
profile_index, QtCore.Qt.UserRole)
- colorDialog = QtWidgets.QColorDialog()
- new_color = colorDialog.getColor()
- if not new_color:
- return
-
- color_name = new_color.name()
+ # Retain current values on opening a new dialog
+ def open_color_dialog(current_color):
+ color_dialog = QtWidgets.QColorDialog()
+ new_color = color_dialog.getColor(current_color)
+ if new_color.isValid(): # Returned in case cancel is pressed
+ return new_color
+ else:
+ return current_color
if signal_sender == 'fgColor':
+ current_color = current_profile['foreground']
+ new_color = open_color_dialog(current_color)
self.bookToolBar.colorBoxFG.setStyleSheet(
- 'background-color: %s' % color_name)
- current_profile['foreground'] = color_name
+ 'background-color: %s' % new_color.name())
+ current_profile['foreground'] = new_color
elif signal_sender == 'bgColor':
+ current_color = current_profile['background']
+ new_color = open_color_dialog(current_color)
self.bookToolBar.colorBoxBG.setStyleSheet(
- 'background-color: %s' % color_name)
- current_profile['background'] = color_name
+ 'background-color: %s' % new_color.name())
+ current_profile['background'] = new_color
elif signal_sender == 'comicBGColor':
+ current_color = self.comic_profile['background']
+ new_color = open_color_dialog(current_color)
self.bookToolBar.comicBGColor.setStyleSheet(
- 'background-color: %s' % color_name)
+ 'background-color: %s' % new_color.name())
self.comic_profile['background'] = new_color
self.bookToolBar.profileBox.setItemData(
@@ -506,6 +533,14 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
if current_metadata['images_only']:
background = self.comic_profile['background']
padding = self.comic_profile['padding']
+ zoom_mode = self.comic_profile['zoom_mode']
+
+ if zoom_mode == 'fitWidth':
+ self.bookToolBar.fitWidth.setChecked(True)
+ if zoom_mode == 'bestFit':
+ self.bookToolBar.bestFit.setChecked(True)
+ if zoom_mode == 'originalSize':
+ self.bookToolBar.originalSize.setChecked(True)
self.bookToolBar.comicBGColor.setStyleSheet(
'background-color: %s' % background.name())
@@ -533,9 +568,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.bookToolBar.fontSizeBox.blockSignals(False)
self.bookToolBar.colorBoxFG.setStyleSheet(
- 'background-color: %s' % foreground)
+ 'background-color: %s' % foreground.name())
self.bookToolBar.colorBoxBG.setStyleSheet(
- 'background-color: %s' % background)
+ 'background-color: %s' % background.name())
current_tab.format_view(
font, font_size, foreground, background, padding)
@@ -580,11 +615,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
QtWidgets.qApp.exit()
-class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
- def __init__(self):
- super(SettingsUI, self).__init__()
- self.setupUi(self)
-
def main():
app = QtWidgets.QApplication(sys.argv)
diff --git a/database.py b/database.py
index 531ea57..2154569 100644
--- a/database.py
+++ b/database.py
@@ -19,6 +19,8 @@ class DatabaseInit:
"CREATE TABLE books \
(id INTEGER PRIMARY KEY, Title TEXT, Author TEXT, Year INTEGER, \
Path TEXT, Position BLOB, ISBN TEXT, Tags TEXT, Hash TEXT, CoverImage BLOB)")
+ self.database.execute(
+ "CREATE TABLE directories (id INTEGER PRIMARY KEY, Path TEXT, Name TEXT, Tags TEXT)")
self.database.commit()
self.database.close()
diff --git a/resources/raw/settings.ui b/resources/raw/settings.ui
index 4e82241..a375d66 100644
--- a/resources/raw/settings.ui
+++ b/resources/raw/settings.ui
@@ -6,8 +6,8 @@
0
0
- 550
- 627
+ 879
+ 673
@@ -25,25 +25,13 @@
-
-
-
-
- true
+
+
+ -
+
+
+ Search for Paths, Names, Tags...
-
-
- Path
-
-
-
-
- Name
-
-
-
-
- Auto Tag
-
-
-
diff --git a/resources/settingswindow.py b/resources/settingswindow.py
index d6222c5..0150728 100644
--- a/resources/settingswindow.py
+++ b/resources/settingswindow.py
@@ -11,7 +11,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
- Dialog.resize(550, 627)
+ Dialog.resize(879, 673)
self.gridLayout_3 = QtWidgets.QGridLayout(Dialog)
self.gridLayout_3.setObjectName("gridLayout_3")
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
@@ -22,18 +22,12 @@ class Ui_Dialog(object):
self.gridLayout_2.setObjectName("gridLayout_2")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
- self.tableWidget = QtWidgets.QTableWidget(self.groupBox_2)
- self.tableWidget.setAlternatingRowColors(True)
- self.tableWidget.setObjectName("tableWidget")
- self.tableWidget.setColumnCount(3)
- self.tableWidget.setRowCount(0)
- item = QtWidgets.QTableWidgetItem()
- self.tableWidget.setHorizontalHeaderItem(0, item)
- item = QtWidgets.QTableWidgetItem()
- self.tableWidget.setHorizontalHeaderItem(1, item)
- item = QtWidgets.QTableWidgetItem()
- self.tableWidget.setHorizontalHeaderItem(2, item)
- self.verticalLayout.addWidget(self.tableWidget)
+ self.tableView = QtWidgets.QTableView(self.groupBox_2)
+ self.tableView.setObjectName("tableView")
+ self.verticalLayout.addWidget(self.tableView)
+ self.lineEdit = QtWidgets.QLineEdit(self.groupBox_2)
+ self.lineEdit.setObjectName("lineEdit")
+ self.verticalLayout.addWidget(self.lineEdit)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.addButton = QtWidgets.QPushButton(self.groupBox_2)
@@ -83,12 +77,7 @@ class Ui_Dialog(object):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Settings"))
self.groupBox_2.setTitle(_translate("Dialog", "Library"))
- item = self.tableWidget.horizontalHeaderItem(0)
- item.setText(_translate("Dialog", "Path"))
- item = self.tableWidget.horizontalHeaderItem(1)
- item.setText(_translate("Dialog", "Name"))
- item = self.tableWidget.horizontalHeaderItem(2)
- item.setText(_translate("Dialog", "Auto Tag"))
+ self.lineEdit.setPlaceholderText(_translate("Dialog", "Search for Paths, Names, Tags..."))
self.addButton.setText(_translate("Dialog", "Add"))
self.removeButton.setText(_translate("Dialog", "Remove"))
self.refreshButton.setText(_translate("Dialog", "Refresh"))
diff --git a/settings.py b/settings.py
index 77bf395..ff3443f 100644
--- a/settings.py
+++ b/settings.py
@@ -11,24 +11,24 @@ class Settings:
default_profile1 = {
'font': 'Noto Sans',
- 'foreground': '#000000',
- 'background': '#d8d8d8',
+ 'foreground': QtGui.QColor().fromRgb(0, 0, 0),
+ 'background': QtGui.QColor().fromRgb(216, 216, 216),
'padding': 140,
'font_size': 20,
'line_spacing': 1.5}
default_profile2 = {
'font': 'Roboto',
- 'foreground': '#c2c2c2',
- 'background': '#161616',
+ 'foreground': QtGui.QColor().fromRgb(194, 194, 194),
+ 'background': QtGui.QColor().fromRgb(22, 22, 22),
'padding': 140,
'font_size': 20,
'line_spacing': 1.5}
default_profile3 = {
'font': 'Clear Sans',
- 'foreground': '#657b83',
- 'background': '#002b36',
+ 'foreground': QtGui.QColor().fromRgb(101, 123, 131),
+ 'background': QtGui.QColor().fromRgb(0, 43, 54),
'padding': 140,
'font_size': 30,
'line_spacing': 1.5}
@@ -68,6 +68,8 @@ class Settings:
self.settings.beginGroup('lastOpen')
self.parent_window.last_open_books = self.settings.value('lastOpenFiles', [])
self.parent_window.last_open_tab = self.settings.value('lastOpenTab', 'library')
+ self.parent_window.settings_dialog.last_open_directory = self.settings.value(
+ 'settingsLastOpenDirectory', os.path.expanduser('~'))
self.settings.endGroup()
def save_settings(self):
@@ -105,4 +107,6 @@ class Settings:
self.settings.beginGroup('lastOpen')
self.settings.setValue('lastOpenFiles', self.parent_window.last_open_books)
self.settings.setValue('lastOpenTab', last_open_tab)
+ self.settings.setValue(
+ 'settingsLastOpenDirectory', self.parent_window.settings_dialog.last_open_directory)
self.settings.endGroup()
diff --git a/settingsdialog.py b/settingsdialog.py
new file mode 100644
index 0000000..2f5f8eb
--- /dev/null
+++ b/settingsdialog.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+
+import os
+import collections
+
+from PyQt5 import QtWidgets, QtGui, QtCore
+
+import database
+from resources import settingswindow
+
+
+class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
+ def __init__(self):
+ super(SettingsUI, self).__init__()
+ self.setupUi(self)
+
+ # Will be overwritten by settings
+ self.last_open_directory = None
+ self.database_path = None
+
+ self.database_data = collections.OrderedDict()
+ self.database_modification = False
+
+ self.addButton.clicked.connect(self.add_directories)
+
+ def generate_table(self):
+ # Fetch all directories in the database
+ paths = database.DatabaseFunctions(
+ self.database_path).fetch_data(
+ ('*',),
+ 'directories',
+ {'Path': ''},
+ 'LIKE')
+
+ if not paths:
+ print('Database returned no paths for settings...')
+ return
+
+ for i in paths:
+ pass
+
+
+ def add_directories(self):
+ add_directory = QtWidgets.QFileDialog.getExistingDirectory(
+ self, 'Select Directory', self.last_open_directory,
+ QtWidgets.QFileDialog.ShowDirsOnly)
+
+ # Directories will NOT be added recursively
+
diff --git a/sorter.py b/sorter.py
index 30bd2c7..ed74829 100644
--- a/sorter.py
+++ b/sorter.py
@@ -27,7 +27,7 @@ from parsers.cbr import ParseCBR
class BookSorter:
- def __init__(self, file_list, mode, database_path, temp_dir=None):
+ def __init__(self, file_list, mode, database_path, parent_window, temp_dir=None):
# Have the GUI pass a list of files straight to here
# Then, on the basis of what is needed, pass the
# filenames to the requisite functions
@@ -41,9 +41,21 @@ class BookSorter:
self.mode = mode
self.database_path = database_path
self.temp_dir = temp_dir
- if database_path and self.mode == 'reading':
+ self.parent_window = parent_window
+ if database_path:
self.database_hashes()
+ # Maybe check why this isn't working the usual way
+ for i in self.parent_window.statusBar.children():
+ if i.objectName() == 'sorterProgress':
+ self.progressbar = i
+ if i.objectName() == 'statusMessage':
+ self.statuslabel = i
+
+ self.progressbar.show()
+ self.statuslabel.setText('Adding books...')
+ self.progressbar.setMaximum(self.statistics[1])
+
def database_hashes(self):
all_hashes = database.DatabaseFunctions(
self.database_path).fetch_data(
@@ -79,8 +91,8 @@ class BookSorter:
# TODO
# Make use of this
- # self.statistics[0] += 1
- # print(self.statistics)
+ self.statistics[0] += 1
+ self.progressbar.setValue(self.statistics[0])
# IF the file is NOT being loaded into the reader,
# Do not allow addition in case the file is dupicated in the directory
@@ -165,4 +177,6 @@ class BookSorter:
_pool.close()
_pool.join()
+ self.progressbar.hide()
+ self.statuslabel.setText('Populating table...')
return self.all_books
diff --git a/widgets.py b/widgets.py
index 2a2f624..3dff533 100644
--- a/widgets.py
+++ b/widgets.py
@@ -467,7 +467,7 @@ class Tab(QtWidgets.QWidget):
self.contentView.setViewportMargins(padding, 0, padding, 0)
self.contentView.setStyleSheet(
"QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format(
- font, font_size, foreground, background))
+ font, font_size, foreground.name(), background.name()))
def sneaky_change(self):
direction = -1
@@ -726,7 +726,8 @@ class BackGroundBookAddition(QtCore.QThread):
books = sorter.BookSorter(
self.file_list,
'addition',
- self.database_path)
+ self.database_path,
+ self.parent_window)
parsed_books = books.initiate_threads()
database.DatabaseFunctions(self.database_path).add_to_database(parsed_books)
self.parent_window.lib_ref.generate_model('addition', parsed_books)