UI improvements, Start of settings folder traversal

This commit is contained in:
BasioMeusPuga
2017-11-29 00:59:19 +05:30
parent 4cf842b070
commit 8cd8ec4ccd
7 changed files with 104 additions and 47 deletions

View File

@@ -67,7 +67,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.libraryToolBar.addButton.triggered.connect(self.add_books) self.libraryToolBar.addButton.triggered.connect(self.add_books)
self.libraryToolBar.deleteButton.triggered.connect(self.delete_books) self.libraryToolBar.deleteButton.triggered.connect(self.delete_books)
self.libraryToolBar.coverViewButton.triggered.connect(self.switch_library_view) self.libraryToolBar.coverViewButton.triggered.connect(self.switch_library_view)
# self.libraryToolBar.coverViewButton.setChecked(True)
self.libraryToolBar.tableViewButton.triggered.connect(self.switch_library_view) self.libraryToolBar.tableViewButton.triggered.connect(self.switch_library_view)
self.libraryToolBar.settingsButton.triggered.connect(self.show_settings) self.libraryToolBar.settingsButton.triggered.connect(self.show_settings)
self.libraryToolBar.searchBar.textChanged.connect(self.lib_ref.update_proxymodel) self.libraryToolBar.searchBar.textChanged.connect(self.lib_ref.update_proxymodel)
@@ -84,7 +83,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# Book toolbar # Book toolbar
self.bookToolBar = BookToolBar(self) self.bookToolBar = BookToolBar(self)
self.bookToolBar.fullscreenButton.triggered.connect(self.set_fullscreen) self.bookToolBar.fullscreenButton.triggered.connect(self.set_fullscreen)
self.bookToolBar.settingsButton.triggered.connect(self.show_settings)
for count, i in enumerate(self.display_profiles): for count, i in enumerate(self.display_profiles):
self.bookToolBar.profileBox.setItemData(count, i, QtCore.Qt.UserRole) self.bookToolBar.profileBox.setItemData(count, i, QtCore.Qt.UserRole)

View File

@@ -140,7 +140,10 @@ class Library:
self.table_proxy_model = TableProxyModel() self.table_proxy_model = TableProxyModel()
self.table_proxy_model.setSourceModel(self.table_model) self.table_proxy_model.setSourceModel(self.table_model)
self.table_proxy_model.setSortCaseSensitivity(False) self.table_proxy_model.setSortCaseSensitivity(False)
self.table_proxy_model.sort(0, QtCore.Qt.AscendingOrder)
self.parent_window.tableView.setModel(self.table_proxy_model) self.parent_window.tableView.setModel(self.table_proxy_model)
self.parent_window.tableView.horizontalHeader().setSortIndicator(
0, QtCore.Qt.AscendingOrder)
def update_table_proxy_model(self): def update_table_proxy_model(self):
self.table_proxy_model.invalidateFilter() self.table_proxy_model.invalidateFilter()

View File

@@ -23,11 +23,40 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout"> <widget class="QTableView" name="tableView">
<item> <property name="frameShape">
<widget class="QTableView" name="tableView"/> <enum>QFrame::NoFrame</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="gridStyle">
<enum>Qt::NoPen</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item> </item>
<item> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLineEdit" name="lineEdit"> <widget class="QLineEdit" name="lineEdit">
@@ -60,8 +89,6 @@
</layout> </layout>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>

View File

@@ -20,11 +20,19 @@ class Ui_Dialog(object):
self.groupBox_2.setObjectName("groupBox_2") self.groupBox_2.setObjectName("groupBox_2")
self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox_2) self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox_2)
self.gridLayout_2.setObjectName("gridLayout_2") self.gridLayout_2.setObjectName("gridLayout_2")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.tableView = QtWidgets.QTableView(self.groupBox_2) self.tableView = QtWidgets.QTableView(self.groupBox_2)
self.tableView.setFrameShape(QtWidgets.QFrame.NoFrame)
self.tableView.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContentsOnFirstShow)
self.tableView.setEditTriggers(QtWidgets.QAbstractItemView.DoubleClicked|QtWidgets.QAbstractItemView.EditKeyPressed)
self.tableView.setAlternatingRowColors(True)
self.tableView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.tableView.setGridStyle(QtCore.Qt.NoPen)
self.tableView.setSortingEnabled(True)
self.tableView.setWordWrap(False)
self.tableView.setObjectName("tableView") self.tableView.setObjectName("tableView")
self.verticalLayout.addWidget(self.tableView) self.tableView.horizontalHeader().setVisible(True)
self.tableView.verticalHeader().setVisible(False)
self.gridLayout_2.addWidget(self.tableView, 0, 0, 1, 1)
self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setObjectName("horizontalLayout")
self.lineEdit = QtWidgets.QLineEdit(self.groupBox_2) self.lineEdit = QtWidgets.QLineEdit(self.groupBox_2)
@@ -39,8 +47,7 @@ class Ui_Dialog(object):
self.refreshButton = QtWidgets.QPushButton(self.groupBox_2) self.refreshButton = QtWidgets.QPushButton(self.groupBox_2)
self.refreshButton.setObjectName("refreshButton") self.refreshButton.setObjectName("refreshButton")
self.horizontalLayout.addWidget(self.refreshButton) self.horizontalLayout.addWidget(self.refreshButton)
self.verticalLayout.addLayout(self.horizontalLayout) self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1)
self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
self.verticalLayout_2.addWidget(self.groupBox_2) self.verticalLayout_2.addWidget(self.groupBox_2)
self.groupBox = QtWidgets.QGroupBox(Dialog) self.groupBox = QtWidgets.QGroupBox(Dialog)
self.groupBox.setObjectName("groupBox") self.groupBox.setObjectName("groupBox")

View File

@@ -7,6 +7,7 @@ from PyQt5 import QtWidgets, QtGui, QtCore
import database import database
from resources import settingswindow from resources import settingswindow
from threaded import BackGroundBookSearch, BackGroundBookAddition
class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog): class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
@@ -21,6 +22,8 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
self.database_data = collections.OrderedDict() self.database_data = collections.OrderedDict()
self.database_modification = False self.database_modification = False
self.thread = None
self.addButton.clicked.connect(self.add_directories) self.addButton.clicked.connect(self.add_directories)
def generate_table(self): def generate_table(self):
@@ -58,3 +61,11 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
# Whatever code you write to recurse through directories will # Whatever code you write to recurse through directories will
# have to go into the threaded module # have to go into the threaded module
# Traverse directories looking for files
self.thread = BackGroundBookSearch(self, add_directory)
self.thread.finished.connect(self.do_something)
self.thread.start()
def do_something(self):
print('Book search completed')

View File

@@ -1,10 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os
from PyQt5 import QtCore
import sorter import sorter
import database import database
from PyQt5 import QtCore
class BackGroundTabUpdate(QtCore.QThread): class BackGroundTabUpdate(QtCore.QThread):
def __init__(self, database_path, all_metadata, parent=None): def __init__(self, database_path, all_metadata, parent=None):
@@ -38,3 +39,19 @@ class BackGroundBookAddition(QtCore.QThread):
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)
class BackGroundBookSearch(QtCore.QThread):
def __init__(self, parent_window, root_directory, parent=None):
super(BackGroundBookSearch, self).__init__(parent)
self.parent_window = parent_window
self.root_directory = root_directory
self.valid_files = []
def run(self):
for directory, subdir, files in os.walk(self.root_directory):
for filename in files:
if os.path.splitext(filename)[1][1:] in sorter.available_parsers:
self.valid_files.append(os.path.join(directory, filename))
print(self.valid_files)

View File

@@ -31,9 +31,6 @@ class BookToolBar(QtWidgets.QToolBar):
self.fullscreenButton = QtWidgets.QAction( self.fullscreenButton = QtWidgets.QAction(
QtGui.QIcon.fromTheme('view-fullscreen'), QtGui.QIcon.fromTheme('view-fullscreen'),
'Fullscreen', self) 'Fullscreen', self)
self.settingsButton = QtWidgets.QAction(
QtGui.QIcon.fromTheme('settings'),
'Settings', self)
self.resetProfile = QtWidgets.QAction( self.resetProfile = QtWidgets.QAction(
QtGui.QIcon.fromTheme('view-refresh'), QtGui.QIcon.fromTheme('view-refresh'),
'Reset profile', self) 'Reset profile', self)
@@ -44,8 +41,6 @@ class BookToolBar(QtWidgets.QToolBar):
self.fontButton.triggered.connect(self.toggle_font_settings) self.fontButton.triggered.connect(self.toggle_font_settings)
self.addSeparator() self.addSeparator()
self.addAction(self.fullscreenButton) self.addAction(self.fullscreenButton)
self.addAction(self.settingsButton)
self.settingsButton.setCheckable(True)
# Font modification # Font modification
font_sizes = [str(i) for i in range(8, 48, 2)] font_sizes = [str(i) for i in range(8, 48, 2)]
@@ -197,7 +192,6 @@ class BookToolBar(QtWidgets.QToolBar):
self.bookActions = [ self.bookActions = [
self.fullscreenButton, self.fullscreenButton,
self.settingsButton,
self.tocBoxAction, self.tocBoxAction,
self.searchBarAction] self.searchBarAction]