diff --git a/installer/osx/freeze.py b/installer/osx/freeze.py index bfb78c98c6..78c4cd923b 100644 --- a/installer/osx/freeze.py +++ b/installer/osx/freeze.py @@ -247,6 +247,7 @@ _check_symlinks_prescript() f.close() os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\ |stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP) + shutil.copyfile('/usr/lib/libiconv.2.dylib', os.path.join(frameworks_dir, 'libiconv.2.dylib')) self.add_plugins() @@ -264,10 +265,15 @@ _check_symlinks_prescript() shutil.copytree('/usr/local/etc/fonts', dst, symlinks=False) print - print 'Adding libxml2' + print 'Adding lxml dependencies' + subprocess.check_call('install_name_tool -id @executable_path/../Frameworks/libiconv.2.dylib '+ os.path.join(frameworks_dir, 'libiconv.2.dylib'), shell=True) + deps = [] for f in glob.glob(os.path.expanduser('~/libxml2/*')): - shutil.copyfile(f, os.path.join(frameworks_dir, os.path.basename(f))) + tgt = os.path.join(frameworks_dir, os.path.basename(f)) + shutil.copyfile(f, tgt) + deps.append(tgt) self.fix_lxml_dependencies(resource_dir) + self.fix_misc_dependencies(deps) print print 'Adding IPython' diff --git a/src/calibre/gui2/dialogs/warning.ui b/src/calibre/gui2/dialogs/warning.ui new file mode 100644 index 0000000000..11c2e95cad --- /dev/null +++ b/src/calibre/gui2/dialogs/warning.ui @@ -0,0 +1,113 @@ + + Dialog + + + + 0 + 0 + 727 + 432 + + + + Dialog + + + + :/images/dialog_warning.svg:/images/dialog_warning.svg + + + + + + TextLabel + + + true + + + + + + + + + + + + + + :/images/dialog_warning.svg + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 5ae96b469f..6dfe69fcaa 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -49,6 +49,7 @@ from calibre.ebooks.lrf import preferred_source_formats as LRF_PREFERRED_SOURCE_ from calibre.library.database2 import LibraryDatabase2, CoverCache from calibre.parallel import JobKilled from calibre.utils.filenames import ascii_filename +from calibre.gui2.widgets import WarningDialog class Main(MainWindow, Ui_MainWindow): @@ -236,7 +237,7 @@ in which you want to store your books files. Any existing books will be automati os.remove(self.olddb.dbpath) self.olddb = None prefs['library_path'] = self.library_path - self.library_view.sortByColumn(3, Qt.DescendingOrder) + self.library_view.sortByColumn(*dynamic.get('sort_column', (3, Qt.DescendingOrder))) if not self.library_view.restore_column_widths(): self.library_view.resizeColumnsToContents() self.library_view.resizeRowsToContents() @@ -504,10 +505,10 @@ in which you want to store your books files. Any existing books will be automati files = _('

Books with the same title as the following already exist in the database. Add them anyway?

') - if d.exec_() == QMessageBox.Yes: + d = WarningDialog(_('Duplicates found!'), _('Duplicates found!'), files+'

', parent=self) + if d.exec_() == QDialog.Accepted: model.add_books(*duplicates, **dict(add_duplicates=True)) - model.resort() + self.library_view.sortByColumn(3, Qt.DescendingOrder) model.research() else: self.upload_books(paths, names, infos, on_card=on_card) @@ -1262,6 +1263,7 @@ in which you want to store your books files. Any existing books will be automati def write_settings(self): config.set('main_window_geometry', self.saveGeometry()) + dynamic.set('sort_column', self.library_view.model().sorted_on) self.library_view.write_settings() if self.device_connected: self.memory_view.write_settings() diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index ad89a08cb6..5a1bd756b3 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -6,7 +6,7 @@ Miscellaneous widgets used in the GUI import re, os from PyQt4.QtGui import QListView, QIcon, QFont, QLabel, QListWidget, \ QListWidgetItem, QTextCharFormat, QApplication, \ - QSyntaxHighlighter, QCursor, QColor, QWidget, \ + QSyntaxHighlighter, QCursor, QColor, QWidget, QDialog, \ QAbstractItemDelegate, QPixmap, QStyle, QFontMetrics from PyQt4.QtCore import QAbstractListModel, QVariant, Qt, SIGNAL, \ QObject, QRegExp, QString, QSettings @@ -19,8 +19,16 @@ from calibre import fit_image from calibre.utils.fontconfig import find_font_families from calibre.ebooks.metadata.meta import metadata_from_filename from calibre.utils.config import prefs +from calibre.gui2.dialogs.warning_ui import Ui_Dialog as Ui_WarningDialog - +class WarningDialog(QDialog, Ui_WarningDialog): + + def __init__(self, title, msg, details, parent=None): + QDialog.__init__(self, parent) + self.setupUi(self) + self.setWindowTitle(title) + self.msg.setText(msg) + self.details.setText(details) class FilenamePattern(QWidget, Ui_Form): diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index c40ebf75e7..1c980b7ac1 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -381,6 +381,9 @@ class LibraryDatabase2(LibraryDatabase): path = os.path.join(self.library_path, self.path(id, True)) if os.path.exists(path): shutil.rmtree(path) + parent = os.path.dirname(path) + if not os.listdir(parent): + shutil.rmtree(parent) self.conn.execute('DELETE FROM books WHERE id=?', (id,)) self.conn.commit() @@ -504,7 +507,8 @@ class LibraryDatabase2(LibraryDatabase): stream = open(path, 'rb') self.add_format(id, ext, stream, index_is_id=True) self.conn.commit() - + + def move_library_to(self, newloc): if not os.path.exists(newloc): os.makedirs(newloc)