mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 10:08:40 -05:00
far better image icon, thanks to Neil Wallace
This commit is contained in:
parent
f3bf6f2b21
commit
ea311c1ae4
2 changed files with 17 additions and 10 deletions
7
todo
7
todo
|
|
@ -1,6 +1,6 @@
|
||||||
==========================================
|
==========================================
|
||||||
todo app wise
|
todo app wise
|
||||||
- implement threading
|
- implement threading => http://diotavelli.net/PyQtWiki/Threading,_Signals_and_Slots
|
||||||
- errors need to go to standarderror
|
- errors need to go to standarderror
|
||||||
- add file icon to table view
|
- add file icon to table view
|
||||||
|
|
||||||
|
|
@ -19,6 +19,11 @@ jpgegoptim 1.2.2
|
||||||
advancecomp 1.15
|
advancecomp 1.15
|
||||||
===========================================
|
===========================================
|
||||||
later versions:
|
later versions:
|
||||||
|
allow selection/deletion of rows from table (and subsequently the imagelist)
|
||||||
pnypng api? http://www.gracepointafterfive.com/punypng/api
|
pnypng api? http://www.gracepointafterfive.com/punypng/api
|
||||||
imagemagick/graphicmagick?
|
imagemagick/graphicmagick?
|
||||||
|
|
||||||
|
|
||||||
|
thanks to:
|
||||||
|
Neil Wallace
|
||||||
|
|
||||||
|
|
|
||||||
20
trimage.py
20
trimage.py
|
|
@ -145,8 +145,6 @@ class StartQT4(QMainWindow):
|
||||||
if runfile == 0:
|
if runfile == 0:
|
||||||
#gather new file data
|
#gather new file data
|
||||||
newfile = QFile(filename)
|
newfile = QFile(filename)
|
||||||
provider = QFileIconProvider()
|
|
||||||
newfileicon = provider.icon(QFileInfo(filename))
|
|
||||||
newfilesize = newfile.size()
|
newfilesize = newfile.size()
|
||||||
newfilesizestr = size(newfilesize, system=alternative)
|
newfilesizestr = size(newfilesize, system=alternative)
|
||||||
|
|
||||||
|
|
@ -156,8 +154,7 @@ class StartQT4(QMainWindow):
|
||||||
|
|
||||||
# append current image to list
|
# append current image to list
|
||||||
self.imagelist.append(
|
self.imagelist.append(
|
||||||
(newfileicon, name, oldfilesizestr, newfilesizestr, ratiostr,
|
(name, oldfilesizestr, newfilesizestr, ratiostr, filename))
|
||||||
filename))
|
|
||||||
self.update_table()
|
self.update_table()
|
||||||
|
|
||||||
if self.showapp != True:
|
if self.showapp != True:
|
||||||
|
|
@ -175,7 +172,7 @@ class StartQT4(QMainWindow):
|
||||||
|
|
||||||
# set table model
|
# set table model
|
||||||
tmodel = TriTableModel(self, self.imagelist,
|
tmodel = TriTableModel(self, self.imagelist,
|
||||||
["", "Filename", "Old Size", "New Size", "Compressed"])
|
["Filename", "Old Size", "New Size", "Compressed"])
|
||||||
tview.setModel(tmodel)
|
tview.setModel(tmodel)
|
||||||
|
|
||||||
# set minimum size of table
|
# set minimum size of table
|
||||||
|
|
@ -192,8 +189,7 @@ class StartQT4(QMainWindow):
|
||||||
tview.setRowHeight(row, 25)
|
tview.setRowHeight(row, 25)
|
||||||
|
|
||||||
# set the second column to be longest
|
# set the second column to be longest
|
||||||
tview.setColumnWidth(0, 30)
|
tview.setColumnWidth(0, 300)
|
||||||
tview.setColumnWidth(1, 280)
|
|
||||||
|
|
||||||
# enable recompress button
|
# enable recompress button
|
||||||
self.enable_recompress()
|
self.enable_recompress()
|
||||||
|
|
@ -223,9 +219,15 @@ class TriTableModel(QAbstractTableModel):
|
||||||
"""Get data."""
|
"""Get data."""
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return QVariant()
|
return QVariant()
|
||||||
elif role != Qt.DisplayRole and role != Qt.DecorationRole:
|
elif role == Qt.DisplayRole:
|
||||||
|
data = self.imagelist[index.row()][index.column()]
|
||||||
|
return QVariant(data)
|
||||||
|
elif index.column()==0 and role == Qt.DecorationRole:
|
||||||
|
# decorate column 0 with an icon of the image itself
|
||||||
|
f_icon = QIcon( self.imagelist[index.row()][4] )
|
||||||
|
return QVariant(f_icon)
|
||||||
|
else:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
return QVariant(self.imagelist[index.row()][index.column()])
|
|
||||||
|
|
||||||
def headerData(self, col, orientation, role):
|
def headerData(self, col, orientation, role):
|
||||||
"""Get header data."""
|
"""Get header data."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue