Thumbnailed listview
This commit is contained in:
45
__main__.py
45
__main__.py
@@ -5,12 +5,17 @@
|
|||||||
Override the keypress event of the textedit
|
Override the keypress event of the textedit
|
||||||
Goodreads API: Ratings, Read, Recommendations
|
Goodreads API: Ratings, Read, Recommendations
|
||||||
Get ISBN using python-isbnlib
|
Get ISBN using python-isbnlib
|
||||||
|
All ebooks should be returned as HTML
|
||||||
Theming
|
Theming
|
||||||
|
Search bar in toolbar
|
||||||
Pagination
|
Pagination
|
||||||
sqlite3 for storing metadata
|
sqlite3 for storing metadata
|
||||||
|
sqlite3 for caching files open @ time of exit
|
||||||
|
sqlite3 for cover images cache
|
||||||
|
Information dialog widget
|
||||||
|
Check file hashes upon restart
|
||||||
Drop down for TOC
|
Drop down for TOC
|
||||||
Recursive file addition
|
Recursive file addition
|
||||||
Get cover images
|
|
||||||
Set context menu for definitions and the like
|
Set context menu for definitions and the like
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -45,6 +50,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
settingsButton = QtWidgets.QAction(QtGui.QIcon.fromTheme('settings'), 'Settings', self)
|
settingsButton = QtWidgets.QAction(QtGui.QIcon.fromTheme('settings'), 'Settings', self)
|
||||||
addButton.triggered.connect(self.open_file)
|
addButton.triggered.connect(self.open_file)
|
||||||
settingsButton.triggered.connect(self.create_tab_class)
|
settingsButton.triggered.connect(self.create_tab_class)
|
||||||
|
deleteButton.triggered.connect(self.populatelist)
|
||||||
|
|
||||||
self.LibraryToolBar.addAction(addButton)
|
self.LibraryToolBar.addAction(addButton)
|
||||||
self.LibraryToolBar.addAction(deleteButton)
|
self.LibraryToolBar.addAction(deleteButton)
|
||||||
@@ -59,6 +65,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.tabWidget.tabBar().setTabButton(0, QtWidgets.QTabBar.RightSide, None)
|
self.tabWidget.tabBar().setTabButton(0, QtWidgets.QTabBar.RightSide, None)
|
||||||
self.tabWidget.tabCloseRequested.connect(self.close_tab_class)
|
self.tabWidget.tabCloseRequested.connect(self.close_tab_class)
|
||||||
|
|
||||||
|
self.listView.doubleClicked.connect(self.listclick)
|
||||||
|
|
||||||
def create_tab_class(self):
|
def create_tab_class(self):
|
||||||
# TODO
|
# TODO
|
||||||
# Shift focus to tab if it's already open instead of creating
|
# Shift focus to tab if it's already open instead of creating
|
||||||
@@ -107,6 +115,41 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.show()
|
self.show()
|
||||||
self.current_textEdit.show()
|
self.current_textEdit.show()
|
||||||
|
|
||||||
|
def populatelist(self):
|
||||||
|
self.listView.setWindowTitle('huh')
|
||||||
|
|
||||||
|
# The QlistView widget needs to be populated with a model that
|
||||||
|
# inherits from QStandardItemModel
|
||||||
|
model = QtGui.QStandardItemModel()
|
||||||
|
|
||||||
|
# Get the list of images from here
|
||||||
|
# Temp dir this out after getting the images from the
|
||||||
|
# database
|
||||||
|
my_dir = os.path.join(
|
||||||
|
os.path.dirname(os.path.realpath(__file__)), 'thumbnails')
|
||||||
|
image_list = [os.path.join(my_dir, i) for i in os.listdir('./thumbnails')]
|
||||||
|
|
||||||
|
# Generate image pixmap and then pass it to the widget
|
||||||
|
# as a QIcon
|
||||||
|
# Additional data can be set using an incrementing
|
||||||
|
# QtCore.Qt.UserRole
|
||||||
|
# QtCore.Qt.DisplayRole is the same as item.setText()
|
||||||
|
# The model is a single row and has no columns
|
||||||
|
for i in image_list:
|
||||||
|
img_pixmap = QtGui.QPixmap(i)
|
||||||
|
item = QtGui.QStandardItem(i.split('/')[-1:][0])
|
||||||
|
item.setData('Additional data for ' + i.split('/')[-1:][0], QtCore.Qt.UserRole)
|
||||||
|
item.setIcon(QtGui.QIcon(img_pixmap))
|
||||||
|
model.appendRow(item)
|
||||||
|
s = QtCore.QSize(200, 200) # Set icon sizing here
|
||||||
|
self.listView.setIconSize(s)
|
||||||
|
self.listView.setModel(model)
|
||||||
|
|
||||||
|
def listclick(self, myindex):
|
||||||
|
# print('selected item index found at %s with data: %s' % (myindex.row(), myindex.data()))
|
||||||
|
index = self.listView.model().index(myindex.row(), 0)
|
||||||
|
print(self.listView.model().data(index, QtCore.Qt.UserRole))
|
||||||
|
|
||||||
|
|
||||||
class Tabs:
|
class Tabs:
|
||||||
def __init__(self, parent, book_title):
|
def __init__(self, parent, book_title):
|
||||||
|
@@ -27,6 +27,13 @@ class Ui_MainWindow(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.listView = QtWidgets.QListView(self.tab)
|
||||||
|
self.listView.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
||||||
|
self.listView.setResizeMode(QtWidgets.QListView.Adjust)
|
||||||
|
self.listView.setViewMode(QtWidgets.QListView.IconMode)
|
||||||
|
self.listView.setUniformItemSizes(True)
|
||||||
|
self.listView.setObjectName("listView")
|
||||||
|
self.verticalLayout.addWidget(self.listView)
|
||||||
self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
|
self.gridLayout_2.addLayout(self.verticalLayout, 0, 0, 1, 1)
|
||||||
self.tabWidget.addTab(self.tab, "")
|
self.tabWidget.addTab(self.tab, "")
|
||||||
self.horizontalLayout.addWidget(self.tabWidget)
|
self.horizontalLayout.addWidget(self.tabWidget)
|
||||||
|
@@ -31,7 +31,24 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<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"/>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="listView">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="resizeMode">
|
||||||
|
<enum>QListView::Adjust</enum>
|
||||||
|
</property>
|
||||||
|
<property name="viewMode">
|
||||||
|
<enum>QListView::IconMode</enum>
|
||||||
|
</property>
|
||||||
|
<property name="uniformItemSizes">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Reference in New Issue
Block a user