diff --git a/osx_installer.py b/osx_installer.py
index 79e363618f..22d95f4dba 100644
--- a/osx_installer.py
+++ b/osx_installer.py
@@ -99,7 +99,7 @@ _check_symlinks_prescript()
includes=list(self.includes) + main_modules['console'],
packages=self.packages,
excludes=self.excludes,
- debug=debug,
+ debug=debug
)
@classmethod
@@ -277,13 +277,7 @@ sys.frameworks_dir = os.path.join(os.path.dirname(os.environ['RESOURCEPATH']), '
def main():
-# auto = '--auto' in sys.argv
-# if auto:
-# sys.argv.remove('--auto')
-# if auto and not os.path.exists('dist/auto'):
-# print '%s does not exist'%os.path.abspath('dist/auto')
-# return 1
-#
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
sys.argv[1:2] = ['py2app']
setup(
name = APPNAME,
diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py
index 6145c68f35..73e43264d1 100644
--- a/src/calibre/__init__.py
+++ b/src/calibre/__init__.py
@@ -447,15 +447,14 @@ class Settings(QSettings):
self.setValue(str(key), QVariant(QByteArray(val)))
_settings = Settings()
+
if not _settings.get('rationalized'):
__settings = Settings(name='calibre')
dbpath = os.path.join(os.path.expanduser('~'), 'library1.db').decode(sys.getfilesystemencoding())
dbpath = unicode(__settings.value('database path',
QVariant(QString.fromUtf8(dbpath.encode('utf-8')))).toString())
cmdline = __settings.value('LRF conversion defaults', QVariant(QByteArray(''))).toByteArray().data()
-
- _settings.set('database path', dbpath)
if cmdline:
cmdline = cPickle.loads(cmdline)
_settings.set('LRF conversion defaults', cmdline)
@@ -464,6 +463,7 @@ if not _settings.get('rationalized'):
os.unlink(unicode(__settings.fileName()))
except:
pass
+ _settings.set('database path', dbpath)
_spat = re.compile(r'^the\s+|^a\s+|^an\s+', re.IGNORECASE)
def english_sort(x, y):
diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py
index afea0aa190..f60ace4c5e 100644
--- a/src/calibre/gui2/library.py
+++ b/src/calibre/gui2/library.py
@@ -9,7 +9,7 @@ from itertools import repeat
from PyQt4.QtGui import QTableView, QProgressDialog, QAbstractItemView, QColor, \
QItemDelegate, QPainterPath, QLinearGradient, QBrush, \
QPen, QStyle, QPainter, QLineEdit, QApplication, \
- QPalette, QImage
+ QPalette, QImage, QStyleOptionFocusRect, QApplication
from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt, QString, \
QCoreApplication, SIGNAL, QObject, QSize, QModelIndex, \
QTimer
@@ -55,9 +55,8 @@ class LibraryDelegate(QItemDelegate):
painter.restore()
painter.save()
+ QApplication.style().drawControl(QStyle.CE_ItemViewItem, option, painter)
try:
- if option.state & QStyle.State_Selected:
- painter.fillRect(option.rect, option.palette.highlight())
painter.setRenderHint(QPainter.Antialiasing)
y = option.rect.center().y()-self.SIZE/2.
x = option.rect.right() - self.SIZE
diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py
index b3a00c4415..06c4eaff19 100644
--- a/src/calibre/gui2/main.py
+++ b/src/calibre/gui2/main.py
@@ -4,7 +4,7 @@ import os, sys, textwrap, collections, traceback, shutil, time
from xml.parsers.expat import ExpatError
from functools import partial
from PyQt4.QtCore import Qt, SIGNAL, QObject, QCoreApplication, \
- QVariant, QThread, QSize, QUrl
+ QVariant, QThread, QUrl, QSize
from PyQt4.QtGui import QPixmap, QColor, QPainter, QMenu, QIcon, QMessageBox, \
QToolButton, QDialog, QDesktopServices
from PyQt4.QtSvg import QSvgRenderer
@@ -1190,4 +1190,14 @@ def main(args=sys.argv):
if __name__ == '__main__':
- sys.exit(main())
+ try:
+ sys.exit(main())
+ except:
+ if not iswindows: raise
+ from PyQt4.QtGui import QErrorMessage
+ logfile = os.path.expanduser('~/calibre.log')
+ if os.path.exists(logfile):
+ log = open(logfile).read()
+ if log.strip():
+ d = QErrorMessage()
+ d.showMessage(log)
diff --git a/src/calibre/gui2/main.ui b/src/calibre/gui2/main.ui
index c53f89b3ec..e38b3833f6 100644
--- a/src/calibre/gui2/main.ui
+++ b/src/calibre/gui2/main.ui
@@ -27,9 +27,9 @@
0
- 86
+ 79
865
- 712
+ 716
@@ -44,7 +44,7 @@
-
-
+
0
0
@@ -52,19 +52,25 @@
10000
- 100
+ 110
Qt::ScrollBarAlwaysOff
- Qt::ScrollBarAlwaysOff
+ Qt::ScrollBarAsNeeded
+
+
+ true
+
+
+ true
- 32
- 32
+ 40
+ 40
@@ -77,14 +83,11 @@
false
- 20
+ 10
QListView::IconMode
-
- true
-
-
@@ -332,8 +335,8 @@
0
0
- 847
- 553
+ 857
+ 552
@@ -380,7 +383,7 @@
0
0
865
- 86
+ 79
@@ -425,9 +428,9 @@
0
- 798
+ 795
865
- 24
+ 27
diff --git a/src/calibre/gui2/pictureflow/PyQt/configure.py b/src/calibre/gui2/pictureflow/PyQt/configure.py
index 04c7c8fe91..e24e9a8405 100644
--- a/src/calibre/gui2/pictureflow/PyQt/configure.py
+++ b/src/calibre/gui2/pictureflow/PyQt/configure.py
@@ -1,4 +1,4 @@
-import os, sys, glob
+import os, sys, glob, shutil
import sipconfig
if os.environ.get('PYQT4PATH', None):
print os.environ['PYQT4PATH']
@@ -37,7 +37,7 @@ makefile = pyqtconfig.QtGuiModuleMakefile (
# ".dll" extension on Windows).
if 'linux' in sys.platform:
for f in glob.glob('../../.build/libpictureflow.a'):
- os.link(f, './'+os.path.basename(f))
+ shutil.copyfile(f, os.path.basename(f))
makefile.extra_lib_dirs = ['.']
else:
makefile.extra_lib_dirs = ['..\\..\\.build\\release', '../../.build', '.']
diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py
index 408b8329e5..efdf4bb237 100644
--- a/src/calibre/gui2/widgets.py
+++ b/src/calibre/gui2/widgets.py
@@ -7,9 +7,9 @@ import re, os
from PyQt4.QtGui import QListView, QIcon, QFont, QLabel, QListWidget, \
QListWidgetItem, QTextCharFormat, QApplication, \
QSyntaxHighlighter, QCursor, QColor, QWidget, \
- QAbstractItemDelegate, QPixmap
+ QAbstractItemDelegate, QPixmap, QStyle
from PyQt4.QtCore import QAbstractListModel, QVariant, Qt, QRect, SIGNAL, \
- QObject, QRegExp, QRectF
+ QObject, QRegExp, QRectF, QString
from calibre.gui2.jobs import DetailView
from calibre.gui2 import human_readable, NONE, TableView, qstring_to_unicode, error_dialog
@@ -123,28 +123,42 @@ class LocationDelegate(QAbstractItemDelegate):
def __init__(self):
QAbstractItemDelegate.__init__(self)
- self.icon_rect = QRect(0, 10, 150, 45)
- self.buffer = 5
+ self.pixmap = QPixmap(40, 40)
+ self.text = QString('Reader\n999.9 MB Available202')
- def get_rects(self, index, option):
- row = index.row()
- irect = QRect(self.icon_rect)
- irect.translate(row*(irect.width()+self.buffer), 0)
- trect = irect.translated(0, irect.height())
- trect.adjust(0, 7, 0, 0)
- return irect.adjusted(50, 0, -50, 0), trect
+ def rects(self, option):
+ style = QApplication.style()
+ irect = style.itemPixmapRect(option.rect, Qt.AlignHCenter|Qt.AlignTop, self.pixmap)
+ trect = style.itemTextRect(option.fontMetrics, option.rect,
+ Qt.AlignHCenter|Qt.AlignTop, True, self.text)
+ trect.moveTop(irect.bottom())
+ return irect, trect
def sizeHint(self, option, index):
- irect, trect = self.get_rects(index, option)
+ irect, trect = self.rects(option)
return irect.united(trect).size()
def paint(self, painter, option, index):
- font = QFont()
- font.setPointSize(9)
- icon = QIcon(index.model().data(index, Qt.DecorationRole))
- highlight = getattr(index.model(), 'highlight_row', -1) == index.row()
- text = index.model().data(index, Qt.DisplayRole).toString()
+ style = QApplication.style()
painter.save()
+ QApplication.style().drawControl(QStyle.CE_ItemViewItem, option, painter)
+ highlight = getattr(index.model(), 'highlight_row', -1) == index.row()
+ mode = QIcon.Active if highlight else QIcon.Normal
+ pixmap = QIcon(index.model().data(index, Qt.DecorationRole)).pixmap(self.pixmap.size())
+ pixmap = style.generatedIconPixmap(mode, pixmap, option)
+ text = index.model().data(index, Qt.DisplayRole).toString()
+ irect, trect = self.rects(option)
+ style.drawItemPixmap(painter, irect, Qt.AlignHCenter|Qt.AlignTop, pixmap)
+ painter.setFont(option.font)
+ style.drawItemText(painter, trect, Qt.AlignHCenter|Qt.AlignBottom,
+ option.palette, True, text)
+ painter.restore()
+ return
+ #font = QFont()
+ #font.setPointSize(9)
+
+
+ text = index.model().data(index, Qt.DisplayRole).toString()
irect, trect = self.get_rects(index, option)
mode = QIcon.Normal
diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst
index 34872cbdb3..9a12253b62 100644
--- a/src/calibre/manual/faq.rst
+++ b/src/calibre/manual/faq.rst
@@ -131,7 +131,7 @@ Why does |app| show only some of my fonts on OS X?
The graphical user interface of |app| is not starting on Windows?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If you've never used the graphical user interface before, try deleting the file library1.db (it will be somewhere under :file:`C:\\Documents and Settings` on Windows XP and :file:`C:\\Users` on Windows Vista. If that doesn't fix the problem, locate the file libprs500.log (in the same places as library1.db) and post its contents in a help message on the `Forums `_.
+If you've never used the graphical user interface before, try deleting the file library1.db (it will be somewhere under :file:`C:\\Documents and Settings` on Windows XP and :file:`C:\\Users` on Windows Vista. If that doesn't fix the problem, locate the file calibre.log (in the same places as library1.db) and post its contents in a help message on the `Forums `_.
I want some feature added to |app|. What can I do?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/windows_installer.py b/windows_installer.py
index da53aa7f7e..c38ee3487b 100644
--- a/windows_installer.py
+++ b/windows_installer.py
@@ -1,7 +1,7 @@
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
''' Create a windows installer '''
-import sys, re, os, shutil, subprocess
+import sys, re, os, shutil, subprocess, zipfile
from setup import VERSION, APPNAME, entry_points, scripts, basenames
from distutils.core import setup
from distutils.filelist import FileList
@@ -508,7 +508,11 @@ class BuildEXE(build_exe):
shutil.rmtree(tg)
shutil.copytree(imfd, tg)
-
+ print
+ print 'Adding GUI main.py'
+ f = zipfile.ZipFile(os.path.join('build', 'py2exe', 'library.zip'), 'a', zipfile.ZIP_DEFLATED)
+ f.write('src\\calibre\\gui2\\main.py', 'calibre\\gui2\\main.py')
+ f.close()
print
print
@@ -525,18 +529,11 @@ class BuildEXE(build_exe):
def main():
- auto = '--auto' in sys.argv
- if auto:
- sys.argv.remove('--auto')
sys.argv[1:2] = ['py2exe']
- if '--verbose' not in sys.argv:
- sys.argv.append('--quiet') #py2exe produces too much output by default
- if auto and not os.path.exists('dist\\auto'):
- print os.path.abspath('dist\\auto'), 'does not exist'
- return 1
+
console = [dict(dest_base=basenames['console'][i], script=scripts['console'][i])
for i in range(len(scripts['console']))]
-
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
setup(
cmdclass = {'py2exe': BuildEXE},
windows = [
@@ -572,8 +569,6 @@ def main():
},
)
- if auto:
- subprocess.call(('shutdown', '-s', '-f', '-t', '01'))
return 0
if __name__ == '__main__':