Adjust widgets to screen size
Delete key for the library
This commit is contained in:
@@ -275,6 +275,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.ksCloseTab.setContext(QtCore.Qt.ApplicationShortcut)
|
self.ksCloseTab.setContext(QtCore.Qt.ApplicationShortcut)
|
||||||
self.ksCloseTab.activated.connect(self.tab_close)
|
self.ksCloseTab.activated.connect(self.tab_close)
|
||||||
|
|
||||||
|
self.ksDeletePressed = QtWidgets.QShortcut(QtGui.QKeySequence('Delete'), self)
|
||||||
|
self.ksDeletePressed.setContext(QtCore.Qt.ApplicationShortcut)
|
||||||
|
self.ksDeletePressed.activated.connect(self.delete_pressed)
|
||||||
|
|
||||||
self.listView.setFocus()
|
self.listView.setFocus()
|
||||||
self.open_books_at_startup()
|
self.open_books_at_startup()
|
||||||
|
|
||||||
@@ -451,11 +455,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def add_books(self):
|
def add_books(self):
|
||||||
# TODO
|
|
||||||
# Remember file addition modality
|
|
||||||
# If a file is added from here, it should not be removed
|
|
||||||
# from the libary in case of a database refresh
|
|
||||||
|
|
||||||
dialog_prompt = self._translate('Main_UI', 'Add books to database')
|
dialog_prompt = self._translate('Main_UI', 'Add books to database')
|
||||||
ebooks_string = self._translate('Main_UI', 'eBooks')
|
ebooks_string = self._translate('Main_UI', 'eBooks')
|
||||||
opened_files = QtWidgets.QFileDialog.getOpenFileNames(
|
opened_files = QtWidgets.QFileDialog.getOpenFileNames(
|
||||||
@@ -540,6 +539,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
confirm_deletion.show()
|
confirm_deletion.show()
|
||||||
confirm_deletion.exec_()
|
confirm_deletion.exec_()
|
||||||
|
|
||||||
|
def delete_pressed(self):
|
||||||
|
if self.tabWidget.currentIndex() == 0:
|
||||||
|
self.delete_books()
|
||||||
|
|
||||||
def move_on(self):
|
def move_on(self):
|
||||||
self.settingsDialog.okButton.setEnabled(True)
|
self.settingsDialog.okButton.setEnabled(True)
|
||||||
self.settingsDialog.okButton.setToolTip(
|
self.settingsDialog.okButton.setToolTip(
|
||||||
|
@@ -296,8 +296,6 @@ class Library:
|
|||||||
# All files in unselected directories will have to be removed
|
# All files in unselected directories will have to be removed
|
||||||
# from both of the models
|
# from both of the models
|
||||||
# They will also have to be deleted from the library
|
# They will also have to be deleted from the library
|
||||||
# valid_paths = set(valid_paths)
|
|
||||||
|
|
||||||
invalid_paths = []
|
invalid_paths = []
|
||||||
deletable_persistent_indexes = []
|
deletable_persistent_indexes = []
|
||||||
|
|
||||||
@@ -306,7 +304,11 @@ class Library:
|
|||||||
|
|
||||||
item_metadata = item.data(QtCore.Qt.UserRole + 3)
|
item_metadata = item.data(QtCore.Qt.UserRole + 3)
|
||||||
book_path = item_metadata['path']
|
book_path = item_metadata['path']
|
||||||
addition_mode = item_metadata['addition_mode']
|
try:
|
||||||
|
addition_mode = item_metadata['addition_mode']
|
||||||
|
except KeyError:
|
||||||
|
addition_mode = 'automatic'
|
||||||
|
print('Libary: Error setting addition mode for prune')
|
||||||
|
|
||||||
if (book_path not in valid_paths and
|
if (book_path not in valid_paths and
|
||||||
(addition_mode != 'manual' or addition_mode is None)):
|
(addition_mode != 'manual' or addition_mode is None)):
|
||||||
|
@@ -439,17 +439,22 @@ class LibraryToolBar(QtWidgets.QToolBar):
|
|||||||
class FixedComboBox(QtWidgets.QComboBox):
|
class FixedComboBox(QtWidgets.QComboBox):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(FixedComboBox, self).__init__(parent)
|
super(FixedComboBox, self).__init__(parent)
|
||||||
|
screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
|
||||||
|
self.adjusted_size = screen_width // 4.8
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
return QtCore.QSize(400, 22)
|
# This and the one below should adjust to screen size
|
||||||
|
return QtCore.QSize(self.adjusted_size, 22)
|
||||||
|
|
||||||
|
|
||||||
class FixedLineEdit(QtWidgets.QLineEdit):
|
class FixedLineEdit(QtWidgets.QLineEdit):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(FixedLineEdit, self).__init__(parent)
|
super(FixedLineEdit, self).__init__(parent)
|
||||||
|
screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
|
||||||
|
self.adjusted_size = screen_width // 4.8
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
return QtCore.QSize(400, 22)
|
return QtCore.QSize(self.adjusted_size, 22)
|
||||||
|
|
||||||
def keyReleaseEvent(self, event):
|
def keyReleaseEvent(self, event):
|
||||||
if event.key() == QtCore.Qt.Key_Escape:
|
if event.key() == QtCore.Qt.Key_Escape:
|
||||||
|
Reference in New Issue
Block a user