Progressbar for addition
File duplication fixed Settings UI evolving Library tab widget
This commit is contained in:
74
__main__.py
74
__main__.py
@@ -70,18 +70,21 @@ from PyQt5 import QtWidgets, QtGui, QtCore
|
|||||||
import sorter
|
import sorter
|
||||||
import database
|
import database
|
||||||
|
|
||||||
from resources import mainwindow, settingswindow
|
from resources import mainwindow
|
||||||
from widgets import LibraryToolBar, BookToolBar, Tab
|
from widgets import LibraryToolBar, BookToolBar, Tab
|
||||||
from widgets import LibraryDelegate, BackGroundTabUpdate, BackGroundBookAddition
|
from widgets import LibraryDelegate, BackGroundTabUpdate, BackGroundBookAddition
|
||||||
from library import Library
|
from library import Library
|
||||||
from settings import Settings
|
from settings import Settings
|
||||||
|
|
||||||
|
from settingsdialog import SettingsUI
|
||||||
|
|
||||||
|
|
||||||
class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MainUI, self).__init__()
|
super(MainUI, self).__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
|
# Initialize settings dialog
|
||||||
self.settings_dialog = SettingsUI()
|
self.settings_dialog = SettingsUI()
|
||||||
|
|
||||||
# Empty variables that will be infested soon
|
# 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.current_contentView = None # For fullscreening purposes
|
||||||
self.display_profiles = None
|
self.display_profiles = None
|
||||||
self.current_profile_index = None
|
self.current_profile_index = None
|
||||||
# self.comic_profile = None
|
self.database_path = None
|
||||||
|
|
||||||
# Initialize application
|
# Initialize application
|
||||||
Settings(self).read_settings() # This should populate all variables that need
|
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
|
# Create the database in case it doesn't exist
|
||||||
database.DatabaseInit(self.database_path)
|
database.DatabaseInit(self.database_path)
|
||||||
|
self.settings_dialog.database_path = self.database_path
|
||||||
|
|
||||||
# Create and right align the statusbar label widget
|
# Create and right align the statusbar label widget
|
||||||
self.statusMessage = QtWidgets.QLabel()
|
self.statusMessage = QtWidgets.QLabel()
|
||||||
self.statusMessage.setObjectName('statusMessage')
|
self.statusMessage.setObjectName('statusMessage')
|
||||||
self.statusBar.addPermanentWidget(self.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
|
# Init the QListView
|
||||||
self.lib_ref = Library(self)
|
self.lib_ref = Library(self)
|
||||||
@@ -158,9 +166,15 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
|
|
||||||
# Tab closing
|
# Tab closing
|
||||||
self.tabWidget.setTabsClosable(True)
|
self.tabWidget.setTabsClosable(True)
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# It's possible to add a widget to the Library tab here
|
# Associate this with the library switcher
|
||||||
self.tabWidget.tabBar().setTabButton(0, QtWidgets.QTabBar.RightSide, None)
|
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)
|
self.tabWidget.tabCloseRequested.connect(self.tab_close)
|
||||||
|
|
||||||
# ListView
|
# ListView
|
||||||
@@ -181,6 +195,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.ks_exit_all.setContext(QtCore.Qt.ApplicationShortcut)
|
self.ks_exit_all.setContext(QtCore.Qt.ApplicationShortcut)
|
||||||
self.ks_exit_all.activated.connect(self.closeEvent)
|
self.ks_exit_all.activated.connect(self.closeEvent)
|
||||||
|
|
||||||
|
self.listView.setFocus()
|
||||||
|
|
||||||
# Open last... open books.
|
# Open last... open books.
|
||||||
self.open_files(self.last_open_books)
|
self.open_files(self.last_open_books)
|
||||||
self.last_open_books = None
|
self.last_open_books = None
|
||||||
@@ -377,6 +393,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
file_paths,
|
file_paths,
|
||||||
'reading',
|
'reading',
|
||||||
self.database_path,
|
self.database_path,
|
||||||
|
self,
|
||||||
self.temp_dir.path()).initiate_threads()
|
self.temp_dir.path()).initiate_threads()
|
||||||
|
|
||||||
found_a_focusable_tab = False
|
found_a_focusable_tab = False
|
||||||
@@ -393,32 +410,42 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
if not found_a_focusable_tab:
|
if not found_a_focusable_tab:
|
||||||
self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1)
|
self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1)
|
||||||
|
|
||||||
|
self.format_contentView()
|
||||||
|
|
||||||
def get_color(self):
|
def get_color(self):
|
||||||
signal_sender = self.sender().objectName()
|
signal_sender = self.sender().objectName()
|
||||||
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)
|
||||||
|
|
||||||
colorDialog = QtWidgets.QColorDialog()
|
# Retain current values on opening a new dialog
|
||||||
new_color = colorDialog.getColor()
|
def open_color_dialog(current_color):
|
||||||
if not new_color:
|
color_dialog = QtWidgets.QColorDialog()
|
||||||
return
|
new_color = color_dialog.getColor(current_color)
|
||||||
|
if new_color.isValid(): # Returned in case cancel is pressed
|
||||||
color_name = new_color.name()
|
return new_color
|
||||||
|
else:
|
||||||
|
return current_color
|
||||||
|
|
||||||
if signal_sender == 'fgColor':
|
if signal_sender == 'fgColor':
|
||||||
|
current_color = current_profile['foreground']
|
||||||
|
new_color = open_color_dialog(current_color)
|
||||||
self.bookToolBar.colorBoxFG.setStyleSheet(
|
self.bookToolBar.colorBoxFG.setStyleSheet(
|
||||||
'background-color: %s' % color_name)
|
'background-color: %s' % new_color.name())
|
||||||
current_profile['foreground'] = color_name
|
current_profile['foreground'] = new_color
|
||||||
|
|
||||||
elif signal_sender == 'bgColor':
|
elif signal_sender == 'bgColor':
|
||||||
|
current_color = current_profile['background']
|
||||||
|
new_color = open_color_dialog(current_color)
|
||||||
self.bookToolBar.colorBoxBG.setStyleSheet(
|
self.bookToolBar.colorBoxBG.setStyleSheet(
|
||||||
'background-color: %s' % color_name)
|
'background-color: %s' % new_color.name())
|
||||||
current_profile['background'] = color_name
|
current_profile['background'] = new_color
|
||||||
|
|
||||||
elif signal_sender == 'comicBGColor':
|
elif signal_sender == 'comicBGColor':
|
||||||
|
current_color = self.comic_profile['background']
|
||||||
|
new_color = open_color_dialog(current_color)
|
||||||
self.bookToolBar.comicBGColor.setStyleSheet(
|
self.bookToolBar.comicBGColor.setStyleSheet(
|
||||||
'background-color: %s' % color_name)
|
'background-color: %s' % new_color.name())
|
||||||
self.comic_profile['background'] = new_color
|
self.comic_profile['background'] = new_color
|
||||||
|
|
||||||
self.bookToolBar.profileBox.setItemData(
|
self.bookToolBar.profileBox.setItemData(
|
||||||
@@ -506,6 +533,14 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
if current_metadata['images_only']:
|
if current_metadata['images_only']:
|
||||||
background = self.comic_profile['background']
|
background = self.comic_profile['background']
|
||||||
padding = self.comic_profile['padding']
|
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(
|
self.bookToolBar.comicBGColor.setStyleSheet(
|
||||||
'background-color: %s' % background.name())
|
'background-color: %s' % background.name())
|
||||||
@@ -533,9 +568,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.bookToolBar.fontSizeBox.blockSignals(False)
|
self.bookToolBar.fontSizeBox.blockSignals(False)
|
||||||
|
|
||||||
self.bookToolBar.colorBoxFG.setStyleSheet(
|
self.bookToolBar.colorBoxFG.setStyleSheet(
|
||||||
'background-color: %s' % foreground)
|
'background-color: %s' % foreground.name())
|
||||||
self.bookToolBar.colorBoxBG.setStyleSheet(
|
self.bookToolBar.colorBoxBG.setStyleSheet(
|
||||||
'background-color: %s' % background)
|
'background-color: %s' % background.name())
|
||||||
|
|
||||||
current_tab.format_view(
|
current_tab.format_view(
|
||||||
font, font_size, foreground, background, padding)
|
font, font_size, foreground, background, padding)
|
||||||
@@ -580,11 +615,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
QtWidgets.qApp.exit()
|
QtWidgets.qApp.exit()
|
||||||
|
|
||||||
|
|
||||||
class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
|
|
||||||
def __init__(self):
|
|
||||||
super(SettingsUI, self).__init__()
|
|
||||||
self.setupUi(self)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = QtWidgets.QApplication(sys.argv)
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
@@ -19,6 +19,8 @@ class DatabaseInit:
|
|||||||
"CREATE TABLE books \
|
"CREATE TABLE books \
|
||||||
(id INTEGER PRIMARY KEY, Title TEXT, Author TEXT, Year INTEGER, \
|
(id INTEGER PRIMARY KEY, Title TEXT, Author TEXT, Year INTEGER, \
|
||||||
Path TEXT, Position BLOB, ISBN TEXT, Tags TEXT, Hash TEXT, CoverImage BLOB)")
|
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.commit()
|
||||||
self.database.close()
|
self.database.close()
|
||||||
|
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>550</width>
|
<width>879</width>
|
||||||
<height>627</height>
|
<height>673</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -25,25 +25,13 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableWidget" name="tableWidget">
|
<widget class="QTableView" name="tableView"/>
|
||||||
<property name="alternatingRowColors">
|
</item>
|
||||||
<bool>true</bool>
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Search for Paths, Names, Tags...</string>
|
||||||
</property>
|
</property>
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Path</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Auto Tag</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@@ -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(550, 627)
|
Dialog.resize(879, 673)
|
||||||
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()
|
||||||
@@ -22,18 +22,12 @@ class Ui_Dialog(object):
|
|||||||
self.gridLayout_2.setObjectName("gridLayout_2")
|
self.gridLayout_2.setObjectName("gridLayout_2")
|
||||||
self.verticalLayout = QtWidgets.QVBoxLayout()
|
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
self.tableWidget = QtWidgets.QTableWidget(self.groupBox_2)
|
self.tableView = QtWidgets.QTableView(self.groupBox_2)
|
||||||
self.tableWidget.setAlternatingRowColors(True)
|
self.tableView.setObjectName("tableView")
|
||||||
self.tableWidget.setObjectName("tableWidget")
|
self.verticalLayout.addWidget(self.tableView)
|
||||||
self.tableWidget.setColumnCount(3)
|
self.lineEdit = QtWidgets.QLineEdit(self.groupBox_2)
|
||||||
self.tableWidget.setRowCount(0)
|
self.lineEdit.setObjectName("lineEdit")
|
||||||
item = QtWidgets.QTableWidgetItem()
|
self.verticalLayout.addWidget(self.lineEdit)
|
||||||
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.horizontalLayout = QtWidgets.QHBoxLayout()
|
self.horizontalLayout = QtWidgets.QHBoxLayout()
|
||||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||||
self.addButton = QtWidgets.QPushButton(self.groupBox_2)
|
self.addButton = QtWidgets.QPushButton(self.groupBox_2)
|
||||||
@@ -83,12 +77,7 @@ class Ui_Dialog(object):
|
|||||||
_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_2.setTitle(_translate("Dialog", "Library"))
|
||||||
item = self.tableWidget.horizontalHeaderItem(0)
|
self.lineEdit.setPlaceholderText(_translate("Dialog", "Search for Paths, Names, Tags..."))
|
||||||
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.addButton.setText(_translate("Dialog", "Add"))
|
self.addButton.setText(_translate("Dialog", "Add"))
|
||||||
self.removeButton.setText(_translate("Dialog", "Remove"))
|
self.removeButton.setText(_translate("Dialog", "Remove"))
|
||||||
self.refreshButton.setText(_translate("Dialog", "Refresh"))
|
self.refreshButton.setText(_translate("Dialog", "Refresh"))
|
||||||
|
16
settings.py
16
settings.py
@@ -11,24 +11,24 @@ class Settings:
|
|||||||
|
|
||||||
default_profile1 = {
|
default_profile1 = {
|
||||||
'font': 'Noto Sans',
|
'font': 'Noto Sans',
|
||||||
'foreground': '#000000',
|
'foreground': QtGui.QColor().fromRgb(0, 0, 0),
|
||||||
'background': '#d8d8d8',
|
'background': QtGui.QColor().fromRgb(216, 216, 216),
|
||||||
'padding': 140,
|
'padding': 140,
|
||||||
'font_size': 20,
|
'font_size': 20,
|
||||||
'line_spacing': 1.5}
|
'line_spacing': 1.5}
|
||||||
|
|
||||||
default_profile2 = {
|
default_profile2 = {
|
||||||
'font': 'Roboto',
|
'font': 'Roboto',
|
||||||
'foreground': '#c2c2c2',
|
'foreground': QtGui.QColor().fromRgb(194, 194, 194),
|
||||||
'background': '#161616',
|
'background': QtGui.QColor().fromRgb(22, 22, 22),
|
||||||
'padding': 140,
|
'padding': 140,
|
||||||
'font_size': 20,
|
'font_size': 20,
|
||||||
'line_spacing': 1.5}
|
'line_spacing': 1.5}
|
||||||
|
|
||||||
default_profile3 = {
|
default_profile3 = {
|
||||||
'font': 'Clear Sans',
|
'font': 'Clear Sans',
|
||||||
'foreground': '#657b83',
|
'foreground': QtGui.QColor().fromRgb(101, 123, 131),
|
||||||
'background': '#002b36',
|
'background': QtGui.QColor().fromRgb(0, 43, 54),
|
||||||
'padding': 140,
|
'padding': 140,
|
||||||
'font_size': 30,
|
'font_size': 30,
|
||||||
'line_spacing': 1.5}
|
'line_spacing': 1.5}
|
||||||
@@ -68,6 +68,8 @@ class Settings:
|
|||||||
self.settings.beginGroup('lastOpen')
|
self.settings.beginGroup('lastOpen')
|
||||||
self.parent_window.last_open_books = self.settings.value('lastOpenFiles', [])
|
self.parent_window.last_open_books = self.settings.value('lastOpenFiles', [])
|
||||||
self.parent_window.last_open_tab = self.settings.value('lastOpenTab', 'library')
|
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()
|
self.settings.endGroup()
|
||||||
|
|
||||||
def save_settings(self):
|
def save_settings(self):
|
||||||
@@ -105,4 +107,6 @@ class Settings:
|
|||||||
self.settings.beginGroup('lastOpen')
|
self.settings.beginGroup('lastOpen')
|
||||||
self.settings.setValue('lastOpenFiles', self.parent_window.last_open_books)
|
self.settings.setValue('lastOpenFiles', self.parent_window.last_open_books)
|
||||||
self.settings.setValue('lastOpenTab', last_open_tab)
|
self.settings.setValue('lastOpenTab', last_open_tab)
|
||||||
|
self.settings.setValue(
|
||||||
|
'settingsLastOpenDirectory', self.parent_window.settings_dialog.last_open_directory)
|
||||||
self.settings.endGroup()
|
self.settings.endGroup()
|
||||||
|
49
settingsdialog.py
Normal file
49
settingsdialog.py
Normal file
@@ -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
|
||||||
|
|
22
sorter.py
22
sorter.py
@@ -27,7 +27,7 @@ from parsers.cbr import ParseCBR
|
|||||||
|
|
||||||
|
|
||||||
class BookSorter:
|
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
|
# Have the GUI pass a list of files straight to here
|
||||||
# Then, on the basis of what is needed, pass the
|
# Then, on the basis of what is needed, pass the
|
||||||
# filenames to the requisite functions
|
# filenames to the requisite functions
|
||||||
@@ -41,9 +41,21 @@ class BookSorter:
|
|||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.database_path = database_path
|
self.database_path = database_path
|
||||||
self.temp_dir = temp_dir
|
self.temp_dir = temp_dir
|
||||||
if database_path and self.mode == 'reading':
|
self.parent_window = parent_window
|
||||||
|
if database_path:
|
||||||
self.database_hashes()
|
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):
|
def database_hashes(self):
|
||||||
all_hashes = database.DatabaseFunctions(
|
all_hashes = database.DatabaseFunctions(
|
||||||
self.database_path).fetch_data(
|
self.database_path).fetch_data(
|
||||||
@@ -79,8 +91,8 @@ class BookSorter:
|
|||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# Make use of this
|
# Make use of this
|
||||||
# self.statistics[0] += 1
|
self.statistics[0] += 1
|
||||||
# print(self.statistics)
|
self.progressbar.setValue(self.statistics[0])
|
||||||
|
|
||||||
# IF the file is NOT being loaded into the reader,
|
# IF the file is NOT being loaded into the reader,
|
||||||
# Do not allow addition in case the file is dupicated in the directory
|
# Do not allow addition in case the file is dupicated in the directory
|
||||||
@@ -165,4 +177,6 @@ class BookSorter:
|
|||||||
_pool.close()
|
_pool.close()
|
||||||
_pool.join()
|
_pool.join()
|
||||||
|
|
||||||
|
self.progressbar.hide()
|
||||||
|
self.statuslabel.setText('Populating table...')
|
||||||
return self.all_books
|
return self.all_books
|
||||||
|
@@ -467,7 +467,7 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.contentView.setViewportMargins(padding, 0, padding, 0)
|
self.contentView.setViewportMargins(padding, 0, padding, 0)
|
||||||
self.contentView.setStyleSheet(
|
self.contentView.setStyleSheet(
|
||||||
"QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format(
|
"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):
|
def sneaky_change(self):
|
||||||
direction = -1
|
direction = -1
|
||||||
@@ -726,7 +726,8 @@ class BackGroundBookAddition(QtCore.QThread):
|
|||||||
books = sorter.BookSorter(
|
books = sorter.BookSorter(
|
||||||
self.file_list,
|
self.file_list,
|
||||||
'addition',
|
'addition',
|
||||||
self.database_path)
|
self.database_path,
|
||||||
|
self.parent_window)
|
||||||
parsed_books = books.initiate_threads()
|
parsed_books = books.initiate_threads()
|
||||||
database.DatabaseFunctions(self.database_path).add_to_database(parsed_books)
|
database.DatabaseFunctions(self.database_path).add_to_database(parsed_books)
|
||||||
self.parent_window.lib_ref.generate_model('addition', parsed_books)
|
self.parent_window.lib_ref.generate_model('addition', parsed_books)
|
||||||
|
Reference in New Issue
Block a user