mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 10:08:40 -05:00
massive overhaul of directory to make it work nicer with .deb generation
This commit is contained in:
parent
41672b8a39
commit
8dcec263ff
31 changed files with 384 additions and 64 deletions
0
src/trimage/__init__.py
Normal file
0
src/trimage/__init__.py
Normal file
7
src/trimage/hurry/__init__.py
Normal file
7
src/trimage/hurry/__init__.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# this is a namespace package
|
||||
try:
|
||||
import pkg_resources
|
||||
pkg_resources.declare_namespace(__name__)
|
||||
except ImportError:
|
||||
import pkgutil
|
||||
__path__ = pkgutil.extend_path(__path__, __name__)
|
||||
47
src/trimage/hurry/filesize/README.txt
Normal file
47
src/trimage/hurry/filesize/README.txt
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
hurry.filesize
|
||||
==============
|
||||
|
||||
hurry.filesize a simple Python library that can take a number of bytes and
|
||||
returns a human-readable string with the size in it, in kilobytes (K),
|
||||
megabytes (M), etc.
|
||||
|
||||
The default system it uses is "traditional", where multipliers of 1024
|
||||
increase the unit size::
|
||||
|
||||
>>> from hurry.filesize import size
|
||||
>>> size(1024)
|
||||
'1K'
|
||||
|
||||
An alternative, slightly more verbose system::
|
||||
|
||||
>>> from hurry.filesize import alternative
|
||||
>>> size(1, system=alternative)
|
||||
'1 byte'
|
||||
>>> size(10, system=alternative)
|
||||
'10 bytes'
|
||||
>>> size(1024, system=alternative)
|
||||
'1 KB'
|
||||
|
||||
A verbose system::
|
||||
|
||||
>>> from hurry.filesize import verbose
|
||||
>>> size(10, system=verbose)
|
||||
'10 bytes'
|
||||
>>> size(1024, system=verbose)
|
||||
'1 kilobyte'
|
||||
>>> size(2000, system=verbose)
|
||||
'1 kilobyte'
|
||||
>>> size(3000, system=verbose)
|
||||
'2 kilobytes'
|
||||
>>> size(1024 * 1024, system=verbose)
|
||||
'1 megabyte'
|
||||
>>> size(1024 * 1024 * 3, system=verbose)
|
||||
'3 megabytes'
|
||||
|
||||
You can also use the SI system, where multipliers of 1000 increase the unit
|
||||
size::
|
||||
|
||||
>>> from hurry.filesize import si
|
||||
>>> size(1000, system=si)
|
||||
'1K'
|
||||
|
||||
4
src/trimage/hurry/filesize/__init__.py
Normal file
4
src/trimage/hurry/filesize/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from hurry.filesize.filesize import size
|
||||
from hurry.filesize.filesize import traditional, alternative, verbose, iec, si
|
||||
|
||||
|
||||
110
src/trimage/hurry/filesize/filesize.py
Normal file
110
src/trimage/hurry/filesize/filesize.py
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
|
||||
traditional = [
|
||||
(1024 ** 5, 'P'),
|
||||
(1024 ** 4, 'T'),
|
||||
(1024 ** 3, 'G'),
|
||||
(1024 ** 2, 'M'),
|
||||
(1024 ** 1, 'K'),
|
||||
(1024 ** 0, 'B'),
|
||||
]
|
||||
|
||||
alternative = [
|
||||
(1024 ** 5, ' PB'),
|
||||
(1024 ** 4, ' TB'),
|
||||
(1024 ** 3, ' GB'),
|
||||
(1024 ** 2, ' MB'),
|
||||
(1024 ** 1, ' KB'),
|
||||
(1024 ** 0, (' byte', ' bytes')),
|
||||
]
|
||||
|
||||
verbose = [
|
||||
(1024 ** 5, (' petabyte', ' petabytes')),
|
||||
(1024 ** 4, (' terabyte', ' terabytes')),
|
||||
(1024 ** 3, (' gigabyte', ' gigabytes')),
|
||||
(1024 ** 2, (' megabyte', ' megabytes')),
|
||||
(1024 ** 1, (' kilobyte', ' kilobytes')),
|
||||
(1024 ** 0, (' byte', ' bytes')),
|
||||
]
|
||||
|
||||
iec = [
|
||||
(1024 ** 5, 'Pi'),
|
||||
(1024 ** 4, 'Ti'),
|
||||
(1024 ** 3, 'Gi'),
|
||||
(1024 ** 2, 'Mi'),
|
||||
(1024 ** 1, 'Ki'),
|
||||
(1024 ** 0, ''),
|
||||
]
|
||||
|
||||
si = [
|
||||
(1000 ** 5, 'P'),
|
||||
(1000 ** 4, 'T'),
|
||||
(1000 ** 3, 'G'),
|
||||
(1000 ** 2, 'M'),
|
||||
(1000 ** 1, 'K'),
|
||||
(1000 ** 0, 'B'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
def size(bytes, system=traditional):
|
||||
"""Human-readable file size.
|
||||
|
||||
Using the traditional system, where a factor of 1024 is used::
|
||||
|
||||
>>> size(10)
|
||||
'10B'
|
||||
>>> size(100)
|
||||
'100B'
|
||||
>>> size(1000)
|
||||
'1000B'
|
||||
>>> size(2000)
|
||||
'1K'
|
||||
>>> size(10000)
|
||||
'9K'
|
||||
>>> size(20000)
|
||||
'19K'
|
||||
>>> size(100000)
|
||||
'97K'
|
||||
>>> size(200000)
|
||||
'195K'
|
||||
>>> size(1000000)
|
||||
'976K'
|
||||
>>> size(2000000)
|
||||
'1M'
|
||||
|
||||
Using the SI system, with a factor 1000::
|
||||
|
||||
>>> size(10, system=si)
|
||||
'10B'
|
||||
>>> size(100, system=si)
|
||||
'100B'
|
||||
>>> size(1000, system=si)
|
||||
'1K'
|
||||
>>> size(2000, system=si)
|
||||
'2K'
|
||||
>>> size(10000, system=si)
|
||||
'10K'
|
||||
>>> size(20000, system=si)
|
||||
'20K'
|
||||
>>> size(100000, system=si)
|
||||
'100K'
|
||||
>>> size(200000, system=si)
|
||||
'200K'
|
||||
>>> size(1000000, system=si)
|
||||
'1M'
|
||||
>>> size(2000000, system=si)
|
||||
'2M'
|
||||
|
||||
"""
|
||||
for factor, suffix in system:
|
||||
if bytes >= factor:
|
||||
break
|
||||
amount = int(bytes/factor)
|
||||
if isinstance(suffix, tuple):
|
||||
singular, multiple = suffix
|
||||
if amount == 1:
|
||||
suffix = singular
|
||||
else:
|
||||
suffix = multiple
|
||||
return str(amount) + suffix
|
||||
|
||||
7
src/trimage/hurry/filesize/tests.py
Normal file
7
src/trimage/hurry/filesize/tests.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import unittest, doctest
|
||||
|
||||
def test_suite():
|
||||
return unittest.TestSuite((
|
||||
doctest.DocFileSuite('README.txt'),
|
||||
doctest.DocTestSuite('hurry.filesize.filesize'),
|
||||
))
|
||||
BIN
src/trimage/pixmaps/compressing.gif
Normal file
BIN
src/trimage/pixmaps/compressing.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/trimage/pixmaps/list-add.png
Normal file
BIN
src/trimage/pixmaps/list-add.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 676 B |
BIN
src/trimage/pixmaps/trimage-icon.png
Normal file
BIN
src/trimage/pixmaps/trimage-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
BIN
src/trimage/pixmaps/view-refresh.png
Normal file
BIN
src/trimage/pixmaps/view-refresh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
370
src/trimage/trimage.py
Executable file
370
src/trimage/trimage.py
Executable file
|
|
@ -0,0 +1,370 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
from os import listdir
|
||||
from os import path
|
||||
from subprocess import call, PIPE
|
||||
from optparse import OptionParser
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from hurry.filesize import *
|
||||
|
||||
from ui import Ui_trimage
|
||||
|
||||
VERSION = "1.0.0b"
|
||||
|
||||
class StartQT4(QMainWindow):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self.ui = Ui_trimage()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.showapp = True
|
||||
self.verbose = True
|
||||
self.imagelist = []
|
||||
|
||||
# check if apps are installed
|
||||
if self.checkapps():
|
||||
quit()
|
||||
|
||||
#add quit shortcut
|
||||
if hasattr(QKeySequence, "Quit"):
|
||||
self.quit_shortcut = QShortcut(QKeySequence(QKeySequence.Quit),
|
||||
self)
|
||||
else:
|
||||
self.quit_shortcut = QShortcut(QKeySequence("Ctrl+Q"), self)
|
||||
|
||||
# disable recompress
|
||||
self.ui.recompress.setEnabled(False)
|
||||
#self.ui.recompress.hide()
|
||||
|
||||
# make a worker thread
|
||||
self.thread = Worker()
|
||||
|
||||
# connect signals with slots
|
||||
QObject.connect(self.ui.addfiles, SIGNAL("clicked()"),
|
||||
self.file_dialog)
|
||||
QObject.connect(self.ui.recompress, SIGNAL("clicked()"),
|
||||
self.recompress_files)
|
||||
QObject.connect(self.quit_shortcut, SIGNAL("activated()"),
|
||||
qApp, SLOT('quit()'))
|
||||
QObject.connect(self.ui.processedfiles, SIGNAL("fileDropEvent"),
|
||||
self.file_drop)
|
||||
QObject.connect(self.thread, SIGNAL("finished()"), self.update_table)
|
||||
QObject.connect(self.thread, SIGNAL("terminated()"), self.update_table)
|
||||
QObject.connect(self.thread, SIGNAL("updateUi"), self.update_table)
|
||||
|
||||
# activate command line options
|
||||
self.commandline_options()
|
||||
|
||||
def commandline_options(self):
|
||||
"""Set up the command line options."""
|
||||
parser = OptionParser(version="%prog " + VERSION,
|
||||
description="GUI front-end to compress png and jpg images via "
|
||||
"optipng, advpng and jpegoptim")
|
||||
|
||||
parser.set_defaults(verbose=True)
|
||||
parser.add_option("-v", "--verbose", action="store_true",
|
||||
dest="verbose", help="Verbose mode (default)")
|
||||
parser.add_option("-q", "--quiet", action="store_false",
|
||||
dest="verbose", help="Quiet mode")
|
||||
|
||||
parser.add_option("-f", "--file", action="store", type="string",
|
||||
dest="filename", help="compresses image and exit")
|
||||
parser.add_option("-d", "--directory", action="store", type="string",
|
||||
dest="directory", help="compresses images in directory and exit")
|
||||
|
||||
options, args = parser.parse_args()
|
||||
|
||||
# send to correct function
|
||||
if options.filename:
|
||||
self.file_from_cmd(options.filename)
|
||||
if options.directory:
|
||||
self.dir_from_cmd(options.directory)
|
||||
|
||||
self.verbose = options.verbose
|
||||
|
||||
"""
|
||||
Input functions
|
||||
"""
|
||||
|
||||
def dir_from_cmd(self, directory):
|
||||
"""
|
||||
Read the files in the directory and send all files to compress_file.
|
||||
"""
|
||||
self.showapp = False
|
||||
dirpath = path.abspath(path.dirname(directory))
|
||||
imagedir = listdir(directory)
|
||||
filelist = QStringList()
|
||||
for image in imagedir:
|
||||
image = QString(path.join(dirpath, image))
|
||||
filelist.append(image)
|
||||
self.delegator(filelist)
|
||||
|
||||
def file_from_cmd(self, image):
|
||||
"""Get the file and send it to compress_file"""
|
||||
self.showapp = False
|
||||
image = path.abspath(image)
|
||||
filecmdlist = QStringList()
|
||||
filecmdlist.append(image)
|
||||
self.delegator(filecmdlist)
|
||||
|
||||
def file_drop(self, images):
|
||||
"""
|
||||
Get a file from the drag and drop handler and send it to compress_file.
|
||||
"""
|
||||
self.delegator(images)
|
||||
|
||||
def file_dialog(self):
|
||||
"""Open a file dialog and send the selected images to compress_file."""
|
||||
fd = QFileDialog(self)
|
||||
images = fd.getOpenFileNames(self,
|
||||
"Select one or more image files to compress",
|
||||
"", # directory
|
||||
# this is a fix for file dialog differentiating between cases
|
||||
"Image files (*.png *.jpg *.jpeg *.PNG *.JPG *.JPEG)")
|
||||
self.delegator(images)
|
||||
|
||||
def recompress_files(self):
|
||||
"""Send each file in the current file list to compress_file again."""
|
||||
newimagelist = []
|
||||
for image in self.imagelist:
|
||||
newimagelist.append(image[4])
|
||||
self.imagelist = []
|
||||
self.delegator(newimagelist)
|
||||
|
||||
"""
|
||||
Compress functions
|
||||
"""
|
||||
|
||||
def delegator(self, images):
|
||||
"""
|
||||
Recieve all images, check them and send them to the worker thread.
|
||||
"""
|
||||
delegatorlist = []
|
||||
for image in images:
|
||||
if self.checkname(image):
|
||||
delegatorlist.append((image, QIcon(image)))
|
||||
self.imagelist.append(("Compressing...", "", "", "", image,
|
||||
QIcon(QPixmap(self.ui.get_image("pixmaps/compressing.gif")))))
|
||||
else:
|
||||
sys.stderr.write("[error] %s not an image file" % image)
|
||||
|
||||
self.update_table()
|
||||
self.thread.compress_file(delegatorlist, self.showapp, self.verbose,
|
||||
self.imagelist)
|
||||
|
||||
|
||||
"""
|
||||
UI Functions
|
||||
"""
|
||||
|
||||
def update_table(self):
|
||||
"""Update the table view with the latest file data."""
|
||||
tview = self.ui.processedfiles
|
||||
# set table model
|
||||
tmodel = TriTableModel(self, self.imagelist,
|
||||
["Filename", "Old Size", "New Size", "Compressed"])
|
||||
tview.setModel(tmodel)
|
||||
|
||||
# set minimum size of table
|
||||
vh = tview.verticalHeader()
|
||||
vh.setVisible(False)
|
||||
|
||||
# set horizontal header properties
|
||||
hh = tview.horizontalHeader()
|
||||
hh.setStretchLastSection(True)
|
||||
|
||||
# set all row heights
|
||||
nrows = len(self.imagelist)
|
||||
for row in range(nrows):
|
||||
tview.setRowHeight(row, 25)
|
||||
|
||||
# set the second column to be longest
|
||||
tview.setColumnWidth(0, 300)
|
||||
|
||||
# enable recompress button
|
||||
self.enable_recompress()
|
||||
|
||||
"""
|
||||
Helper functions
|
||||
"""
|
||||
|
||||
def checkname(self, name):
|
||||
"""Check if the file is a jpg or png."""
|
||||
return path.splitext(str(name))[1].lower() in [".jpg", ".jpeg", ".png"]
|
||||
|
||||
def enable_recompress(self):
|
||||
"""Enable the recompress button."""
|
||||
self.ui.recompress.setEnabled(True)
|
||||
|
||||
def checkapps(self):
|
||||
"""Check if the required command line apps exist."""
|
||||
status = False
|
||||
retcode = call("jpegoptim --version", shell=True, stdout=PIPE)
|
||||
if retcode != 0:
|
||||
status = True
|
||||
sys.stderr.write("[error] please install jpegoptim")
|
||||
|
||||
retcode = call("optipng -v", shell=True, stdout=PIPE)
|
||||
if retcode != 0:
|
||||
status = True
|
||||
sys.stderr.write("[error] please install optipng")
|
||||
|
||||
retcode = call("advpng --version", shell=True, stdout=PIPE)
|
||||
if retcode != 0:
|
||||
status = True
|
||||
sys.stderr.write("[error] please install advancecomp")
|
||||
return status
|
||||
|
||||
|
||||
class TriTableModel(QAbstractTableModel):
|
||||
|
||||
def __init__(self, parent, imagelist, header, *args):
|
||||
"""
|
||||
@param parent Qt parent object.
|
||||
@param imagelist A list of tuples.
|
||||
@param header A list of strings.
|
||||
"""
|
||||
QAbstractTableModel.__init__(self, parent, *args)
|
||||
self.imagelist = imagelist
|
||||
self.header = header
|
||||
|
||||
def rowCount(self, parent):
|
||||
"""Count the number of rows."""
|
||||
return len(self.imagelist)
|
||||
|
||||
def columnCount(self, parent):
|
||||
"""Count the number of columns."""
|
||||
return len(self.header)
|
||||
|
||||
def data(self, index, role):
|
||||
"""Fill the table with data."""
|
||||
if not index.isValid():
|
||||
return QVariant()
|
||||
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 = self.imagelist[index.row()][5]
|
||||
return QVariant(f_icon)
|
||||
else:
|
||||
return QVariant()
|
||||
|
||||
def headerData(self, col, orientation, role):
|
||||
"""Fill the table headers."""
|
||||
if orientation == Qt.Horizontal and (role == Qt.DisplayRole or
|
||||
role == Qt.DecorationRole):
|
||||
return QVariant(self.header[col])
|
||||
return QVariant()
|
||||
|
||||
|
||||
class Worker(QThread):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QThread.__init__(self, parent)
|
||||
self.exiting = False
|
||||
|
||||
def __del__(self):
|
||||
self.exiting = True
|
||||
self.wait()
|
||||
|
||||
def compress_file(self, images, showapp, verbose, imagelist):
|
||||
"""Start the worker thread."""
|
||||
self.images = images
|
||||
self.showapp = showapp
|
||||
self.verbose = verbose
|
||||
self.imagelist = imagelist
|
||||
self.start()
|
||||
|
||||
def run(self):
|
||||
"""Compress the given file, get data from it and call update_table."""
|
||||
for image in self.images:
|
||||
#gather old file data
|
||||
filename = str(image[0])
|
||||
icon = image[1]
|
||||
oldfile = QFileInfo(filename)
|
||||
name = oldfile.fileName()
|
||||
oldfilesize = oldfile.size()
|
||||
oldfilesizestr = size(oldfilesize, system=alternative)
|
||||
|
||||
# get extention
|
||||
extention = path.splitext(filename)[1]
|
||||
#decide with tool to use
|
||||
if extention in [".jpg", ".jpeg"]:
|
||||
runString = "jpegoptim -f --strip-all '%(file)s'"
|
||||
elif extention in [".png"]:
|
||||
runString = ("optipng -force -o7 '%(file)s';"
|
||||
"advpng -z4 '%(file)s'")
|
||||
else:
|
||||
sys.stderr.write("[error] %s not an image file" % filename)
|
||||
|
||||
try:
|
||||
retcode = call(runString % {"file": filename}, shell=True,
|
||||
stdout=PIPE)
|
||||
runfile = retcode
|
||||
except OSError as e:
|
||||
runfile = e
|
||||
|
||||
if runfile == 0:
|
||||
#gather new file data
|
||||
newfile = QFile(filename)
|
||||
newfilesize = newfile.size()
|
||||
newfilesizestr = size(newfilesize, system=alternative)
|
||||
|
||||
#calculate ratio and make a nice string
|
||||
ratio = 100 - (float(newfilesize) / float(oldfilesize) * 100)
|
||||
ratiostr = "%.1f%%" % ratio
|
||||
|
||||
# append current image to list
|
||||
for i, image in enumerate(self.imagelist):
|
||||
if image[4] == filename:
|
||||
self.imagelist.remove(image)
|
||||
self.imagelist.insert(i, (name, oldfilesizestr,
|
||||
newfilesizestr, ratiostr, filename, icon))
|
||||
|
||||
self.emit(SIGNAL("updateUi"))
|
||||
|
||||
if not self.showapp and self.verbose:
|
||||
# we work via the commandline
|
||||
print("File: " + filename + ", Old Size: "
|
||||
+ oldfilesizestr + ", New Size: " + newfilesizestr
|
||||
+ ", Ratio: " + ratiostr)
|
||||
else:
|
||||
sys.stderr.write("[error] %s" % runfile)
|
||||
|
||||
if not self.showapp:
|
||||
#make sure the app quits after all images are done
|
||||
quit()
|
||||
|
||||
class TrimageTableView(QTableView):
|
||||
"""Init the table drop event."""
|
||||
def __init__(self, parent=None):
|
||||
super(TrimageTableView, self).__init__(parent)
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
if event.mimeData().hasFormat("text/uri-list"):
|
||||
event.accept()
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
def dragMoveEvent(self, event):
|
||||
event.accept()
|
||||
|
||||
def dropEvent(self, event):
|
||||
files = str(event.mimeData().data("text/uri-list")).strip().split()
|
||||
for i, file in enumerate(files):
|
||||
files[i] = QUrl(QString(file)).toLocalFile()
|
||||
self.emit(SIGNAL("fileDropEvent"), (files))
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
myapp = StartQT4()
|
||||
|
||||
if myapp.showapp:
|
||||
myapp.show()
|
||||
sys.exit(app.exec_())
|
||||
159
src/trimage/ui.py
Normal file
159
src/trimage/ui.py
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from os import path
|
||||
|
||||
class TrimageTableView(QTableView):
|
||||
"""Init the table drop event."""
|
||||
def __init__(self, parent=None):
|
||||
super(TrimageTableView, self).__init__(parent)
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
if event.mimeData().hasFormat("text/uri-list"):
|
||||
event.accept()
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
def dragMoveEvent(self, event):
|
||||
event.accept()
|
||||
|
||||
def dropEvent(self, event):
|
||||
files = str(event.mimeData().data("text/uri-list")).strip().split()
|
||||
for i, file in enumerate(files):
|
||||
files[i] = QUrl(QString(file)).toLocalFile()
|
||||
self.emit(SIGNAL("fileDropEvent"), (files))
|
||||
|
||||
|
||||
class Ui_trimage(object):
|
||||
def get_image(self, image):
|
||||
imagelink = path.join(path.dirname(path.dirname(path.realpath(__file__))), "trimage/" + image)
|
||||
return imagelink
|
||||
|
||||
def setupUi(self, trimage):
|
||||
trimage.setObjectName("trimage")
|
||||
trimage.resize(600, 170)
|
||||
trimage.setWindowIcon(QIcon(self.get_image("pixmaps/trimage-icon.png")))
|
||||
|
||||
self.centralwidget = QWidget(trimage)
|
||||
self.centralwidget.setObjectName("centralwidget")
|
||||
|
||||
self.gridLayout_2 = QGridLayout(self.centralwidget)
|
||||
self.gridLayout_2.setMargin(0)
|
||||
self.gridLayout_2.setSpacing(0)
|
||||
self.gridLayout_2.setObjectName("gridLayout_2")
|
||||
|
||||
self.widget = QWidget(self.centralwidget)
|
||||
self.widget.setEnabled(True)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(1)
|
||||
sizePolicy.setVerticalStretch(1)
|
||||
sizePolicy.setHeightForWidth(
|
||||
self.widget.sizePolicy().hasHeightForWidth())
|
||||
self.widget.setSizePolicy(sizePolicy)
|
||||
self.widget.setObjectName("widget")
|
||||
|
||||
self.verticalLayout = QVBoxLayout(self.widget)
|
||||
self.verticalLayout.setSpacing(0)
|
||||
self.verticalLayout.setMargin(0)
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
|
||||
self.frame = QFrame(self.widget)
|
||||
self.frame.setObjectName("frame")
|
||||
|
||||
self.verticalLayout_2 = QVBoxLayout(self.frame)
|
||||
self.verticalLayout_2.setSpacing(0)
|
||||
self.verticalLayout_2.setMargin(0)
|
||||
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||
|
||||
self.horizontalLayout = QHBoxLayout()
|
||||
self.horizontalLayout.setSpacing(0)
|
||||
self.horizontalLayout.setMargin(10)
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
|
||||
self.addfiles = QPushButton(self.frame)
|
||||
font = QFont()
|
||||
font.setPointSize(9)
|
||||
self.addfiles.setFont(font)
|
||||
self.addfiles.setCursor(Qt.PointingHandCursor)
|
||||
icon = QIcon()
|
||||
icon.addPixmap(QPixmap(self.get_image("pixmaps/list-add.png")), QIcon.Normal, QIcon.Off)
|
||||
self.addfiles.setIcon(icon)
|
||||
self.addfiles.setObjectName("addfiles")
|
||||
self.addfiles.setAcceptDrops(True)
|
||||
self.horizontalLayout.addWidget(self.addfiles)
|
||||
|
||||
self.label = QLabel(self.frame)
|
||||
font = QFont()
|
||||
font.setPointSize(8)
|
||||
self.label.setFont(font)
|
||||
self.label.setFrameShadow(QFrame.Plain)
|
||||
self.label.setMargin(1)
|
||||
self.label.setIndent(10)
|
||||
self.label.setObjectName("label")
|
||||
self.horizontalLayout.addWidget(self.label)
|
||||
|
||||
spacerItem = QSpacerItem(498, 20, QSizePolicy.Expanding,
|
||||
QSizePolicy.Minimum)
|
||||
self.horizontalLayout.addItem(spacerItem)
|
||||
self.recompress = QPushButton(self.frame)
|
||||
font = QFont()
|
||||
font.setPointSize(9)
|
||||
self.recompress.setFont(font)
|
||||
self.recompress.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
icon1 = QIcon()
|
||||
icon1.addPixmap(QPixmap(self.get_image("pixmaps/view-refresh.png")), QIcon.Normal, QIcon.Off)
|
||||
|
||||
self.recompress.setIcon(icon1)
|
||||
self.recompress.setCheckable(False)
|
||||
self.recompress.setObjectName("recompress")
|
||||
self.horizontalLayout.addWidget(self.recompress)
|
||||
self.verticalLayout_2.addLayout(self.horizontalLayout)
|
||||
|
||||
self.processedfiles = TrimageTableView(self.frame)
|
||||
self.processedfiles.setEnabled(True)
|
||||
self.processedfiles.setFrameShape(QFrame.NoFrame)
|
||||
self.processedfiles.setFrameShadow(QFrame.Plain)
|
||||
self.processedfiles.setLineWidth(0)
|
||||
self.processedfiles.setMidLineWidth(0)
|
||||
self.processedfiles.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.processedfiles.setTabKeyNavigation(True)
|
||||
self.processedfiles.setAlternatingRowColors(True)
|
||||
self.processedfiles.setTextElideMode(Qt.ElideRight)
|
||||
self.processedfiles.setShowGrid(True)
|
||||
self.processedfiles.setGridStyle(Qt.NoPen)
|
||||
self.processedfiles.setSortingEnabled(False)
|
||||
self.processedfiles.setObjectName("processedfiles")
|
||||
self.processedfiles.resizeColumnsToContents()
|
||||
self.processedfiles.setSelectionMode(QAbstractItemView.NoSelection)
|
||||
self.verticalLayout_2.addWidget(self.processedfiles)
|
||||
self.verticalLayout.addWidget(self.frame)
|
||||
self.gridLayout_2.addWidget(self.widget, 0, 0, 1, 1)
|
||||
trimage.setCentralWidget(self.centralwidget)
|
||||
|
||||
self.retranslateUi(trimage)
|
||||
QMetaObject.connectSlotsByName(trimage)
|
||||
|
||||
def retranslateUi(self, trimage):
|
||||
trimage.setWindowTitle(QApplication.translate("trimage",
|
||||
"Trimage image compressor", None, QApplication.UnicodeUTF8))
|
||||
self.addfiles.setToolTip(QApplication.translate("trimage",
|
||||
"Add file to the compression list", None,
|
||||
QApplication.UnicodeUTF8))
|
||||
self.addfiles.setText(QApplication.translate("trimage",
|
||||
"&Add and compress", None, QApplication.UnicodeUTF8))
|
||||
self.addfiles.setShortcut(QApplication.translate("trimage",
|
||||
"Alt+A", None, QApplication.UnicodeUTF8))
|
||||
self.label.setText(QApplication.translate("trimage",
|
||||
"Drag and drop images onto the table", None,
|
||||
QApplication.UnicodeUTF8))
|
||||
self.recompress.setToolTip(QApplication.translate("trimage",
|
||||
"Recompress selected images", None, QApplication.UnicodeUTF8))
|
||||
self.recompress.setText(QApplication.translate("trimage",
|
||||
"&Recompress", None, QApplication.UnicodeUTF8))
|
||||
self.recompress.setShortcut(QApplication.translate("trimage",
|
||||
"Alt+R", None, QApplication.UnicodeUTF8))
|
||||
self.processedfiles.setToolTip(QApplication.translate("trimage",
|
||||
"Drag files in here", None, QApplication.UnicodeUTF8))
|
||||
self.processedfiles.setWhatsThis(QApplication.translate("trimage",
|
||||
"Drag files in here", None, QApplication.UnicodeUTF8))
|
||||
Loading…
Add table
Add a link
Reference in a new issue