Adjust widgets to screen size

Delete key for the library
This commit is contained in:
BasioMeusPuga
2018-03-21 15:28:58 +05:30
parent a1dba753e8
commit c783e44444
3 changed files with 20 additions and 10 deletions

View File

@@ -275,6 +275,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.ksCloseTab.setContext(QtCore.Qt.ApplicationShortcut)
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.open_books_at_startup()
@@ -451,11 +455,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
return
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')
ebooks_string = self._translate('Main_UI', 'eBooks')
opened_files = QtWidgets.QFileDialog.getOpenFileNames(
@@ -540,6 +539,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
confirm_deletion.show()
confirm_deletion.exec_()
def delete_pressed(self):
if self.tabWidget.currentIndex() == 0:
self.delete_books()
def move_on(self):
self.settingsDialog.okButton.setEnabled(True)
self.settingsDialog.okButton.setToolTip(

View File

@@ -296,8 +296,6 @@ class Library:
# All files in unselected directories will have to be removed
# from both of the models
# They will also have to be deleted from the library
# valid_paths = set(valid_paths)
invalid_paths = []
deletable_persistent_indexes = []
@@ -306,7 +304,11 @@ class Library:
item_metadata = item.data(QtCore.Qt.UserRole + 3)
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
(addition_mode != 'manual' or addition_mode is None)):

View File

@@ -439,17 +439,22 @@ class LibraryToolBar(QtWidgets.QToolBar):
class FixedComboBox(QtWidgets.QComboBox):
def __init__(self, parent=None):
super(FixedComboBox, self).__init__(parent)
screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
self.adjusted_size = screen_width // 4.8
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):
def __init__(self, parent=None):
super(FixedLineEdit, self).__init__(parent)
screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
self.adjusted_size = screen_width // 4.8
def sizeHint(self):
return QtCore.QSize(400, 22)
return QtCore.QSize(self.adjusted_size, 22)
def keyReleaseEvent(self, event):
if event.key() == QtCore.Qt.Key_Escape: