Unimplemented icon resize function
This commit is contained in:
44
__main__.py
44
__main__.py
@@ -23,6 +23,7 @@
|
|||||||
Information dialog widget
|
Information dialog widget
|
||||||
Check file hashes upon restart
|
Check file hashes upon restart
|
||||||
Recursive file addition
|
Recursive file addition
|
||||||
|
Library context menu: Cache, Read, Edit database, delete
|
||||||
Set context menu for definitions and the like
|
Set context menu for definitions and the like
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -37,7 +38,6 @@ import book_parser
|
|||||||
|
|
||||||
|
|
||||||
class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||||
#pylint: disable-msg=E1101
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(self.__class__, self).__init__()
|
super(self.__class__, self).__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
@@ -85,7 +85,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
|
|
||||||
# ListView
|
# ListView
|
||||||
self.listView.setSpacing(15)
|
self.listView.setSpacing(15)
|
||||||
self.listView.verticalScrollBar().setSingleStep(6)
|
self.listView.verticalScrollBar().setSingleStep(7)
|
||||||
self.reload_listview()
|
self.reload_listview()
|
||||||
self.listView.doubleClicked.connect(self.list_doubleclick)
|
self.listView.doubleClicked.connect(self.list_doubleclick)
|
||||||
|
|
||||||
@@ -202,6 +202,46 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
Settings(self).save_settings()
|
Settings(self).save_settings()
|
||||||
QtWidgets.qApp.exit()
|
QtWidgets.qApp.exit()
|
||||||
|
|
||||||
|
def resizeEventNotConnected(self, event=None):
|
||||||
|
# Extraordinarily hackish
|
||||||
|
# Even by my standards
|
||||||
|
# This works-ish
|
||||||
|
# But the implementation sucks hard
|
||||||
|
# Ignore this for now
|
||||||
|
listview_width = self.listView.size().width()
|
||||||
|
default_margins = 20
|
||||||
|
x_default_size = 160
|
||||||
|
y_x_suggested_ratio = 1.5625
|
||||||
|
# y_new_size = x_new_size * y_x_suggested_ratio
|
||||||
|
|
||||||
|
space_per_thumb = x_default_size + default_margins
|
||||||
|
space_occupied = listview_width / space_per_thumb
|
||||||
|
# At n thumbs per row, space occupied is ~ 1.2n * space_per_thumb
|
||||||
|
# If listView width is more than this, a new thumb gets added to the row
|
||||||
|
# If it's less, a thumb gets taken away i.e.
|
||||||
|
# @ n thumbnails / row, space required >(n + .2) and <(n + 1.2)
|
||||||
|
# I want smaller thumbnails that get bigger
|
||||||
|
# Therefore, 3 thumbnails will be made to fit in a space of >2.2 and <3.2
|
||||||
|
# 6 in a space of >5.2 and <6.2
|
||||||
|
# Since I'm not touching the margins, this will mean adjusting the
|
||||||
|
# x_default_size and multiplying that by the y_x_suggested ratio for
|
||||||
|
# the image height
|
||||||
|
rem = space_occupied - int(space_occupied)
|
||||||
|
if rem > .24:
|
||||||
|
thumbs_per_row = int(space_occupied)
|
||||||
|
reqd_thumbs = thumbs_per_row + 1
|
||||||
|
if rem < .15:
|
||||||
|
reqd_thumbs = int(space_occupied)
|
||||||
|
else:
|
||||||
|
reqd_thumbs = int(space_occupied)
|
||||||
|
|
||||||
|
new_space_per_thumb = listview_width / reqd_thumbs
|
||||||
|
x_new_size = new_space_per_thumb - default_margins - 20
|
||||||
|
y_new_size = x_new_size * y_x_suggested_ratio
|
||||||
|
|
||||||
|
s = QtCore.QSize(x_new_size, y_new_size)
|
||||||
|
self.listView.setIconSize(s)
|
||||||
|
|
||||||
|
|
||||||
class Library:
|
class Library:
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
|
Reference in New Issue
Block a user