mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add compact database button to config dialog
This commit is contained in:
parent
885cfdeb95
commit
e7a465ce6e
@ -53,6 +53,12 @@ def question_dialog(parent, title, msg):
|
|||||||
d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
|
d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def info_dialog(parent, title, msg):
|
||||||
|
d = QMessageBox(QMessageBox.Information, title, msg, QMessageBox.NoButton,
|
||||||
|
parent)
|
||||||
|
d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
|
||||||
|
return d
|
||||||
|
|
||||||
def qstring_to_unicode(q):
|
def qstring_to_unicode(q):
|
||||||
return unicode(q)
|
return unicode(q)
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt4.QtGui import QDialog
|
from PyQt4.QtGui import QDialog, QMessageBox
|
||||||
from PyQt4.QtCore import QSettings, QVariant, SIGNAL, QStringList
|
from PyQt4.QtCore import QSettings, QVariant, SIGNAL, QStringList, QTimer
|
||||||
|
|
||||||
from libprs500 import islinux
|
from libprs500 import islinux
|
||||||
from libprs500.gui2.dialogs.config_ui import Ui_Dialog
|
from libprs500.gui2.dialogs.config_ui import Ui_Dialog
|
||||||
@ -23,11 +23,12 @@ from libprs500.gui2 import qstring_to_unicode, choose_dir, error_dialog
|
|||||||
|
|
||||||
class ConfigDialog(QDialog, Ui_Dialog):
|
class ConfigDialog(QDialog, Ui_Dialog):
|
||||||
|
|
||||||
def __init__(self, window):
|
def __init__(self, window, db):
|
||||||
QDialog.__init__(self, window)
|
QDialog.__init__(self, window)
|
||||||
Ui_Dialog.__init__(self)
|
Ui_Dialog.__init__(self)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
|
self.db = db
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
path = qstring_to_unicode(\
|
path = qstring_to_unicode(\
|
||||||
settings.value("database path",
|
settings.value("database path",
|
||||||
@ -35,6 +36,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
self.location.setText(os.path.dirname(path))
|
self.location.setText(os.path.dirname(path))
|
||||||
self.connect(self.browse_button, SIGNAL('clicked(bool)'), self.browse)
|
self.connect(self.browse_button, SIGNAL('clicked(bool)'), self.browse)
|
||||||
|
self.connect(self.compact_button, SIGNAL('clicked(bool)'), self.compact)
|
||||||
|
|
||||||
dirs = settings.value('frequently used directories', QVariant(QStringList())).toStringList()
|
dirs = settings.value('frequently used directories', QVariant(QStringList())).toStringList()
|
||||||
rn = bool(settings.value('use roman numerals for series number',
|
rn = bool(settings.value('use roman numerals for series number',
|
||||||
@ -51,6 +53,10 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
|||||||
if not islinux:
|
if not islinux:
|
||||||
self.dirs_box.setVisible(False)
|
self.dirs_box.setVisible(False)
|
||||||
|
|
||||||
|
def compact(self, toggled):
|
||||||
|
d = Vacuum(self, self.db)
|
||||||
|
d.exec_()
|
||||||
|
|
||||||
def browse(self):
|
def browse(self):
|
||||||
dir = choose_dir(self, 'database location dialog', 'Select database location')
|
dir = choose_dir(self, 'database location dialog', 'Select database location')
|
||||||
if dir:
|
if dir:
|
||||||
@ -82,3 +88,16 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
|||||||
self.directories = [qstring_to_unicode(self.directory_list.item(i).text()) for i in range(self.directory_list.count())]
|
self.directories = [qstring_to_unicode(self.directory_list.item(i).text()) for i in range(self.directory_list.count())]
|
||||||
settings.setValue('frequently used directories', QVariant(self.directories))
|
settings.setValue('frequently used directories', QVariant(self.directories))
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
|
||||||
|
class Vacuum(QMessageBox):
|
||||||
|
|
||||||
|
def __init__(self, parent, db):
|
||||||
|
self.db = db
|
||||||
|
QMessageBox.__init__(self, QMessageBox.Information, 'Compacting...', 'Compacting database. This may take a while.',
|
||||||
|
QMessageBox.NoButton, parent)
|
||||||
|
QTimer.singleShot(200, self.vacuum)
|
||||||
|
|
||||||
|
def vacuum(self):
|
||||||
|
self.db.vacuum()
|
||||||
|
self.accept()
|
||||||
|
|
@ -19,8 +19,8 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedWidget" >
|
<widget class="QStackedWidget" name="stackedWidget" >
|
||||||
<widget class="QWidget" name="page" >
|
<widget class="QWidget" name="page" >
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QGridLayout" >
|
||||||
<item>
|
<item row="0" column="0" >
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label" >
|
<widget class="QLabel" name="label" >
|
||||||
@ -54,7 +54,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="0" >
|
||||||
<widget class="QCheckBox" name="roman_numerals" >
|
<widget class="QCheckBox" name="roman_numerals" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Use &Roman numerals for series number</string>
|
<string>Use &Roman numerals for series number</string>
|
||||||
@ -64,7 +64,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="2" column="0" >
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2" >
|
<widget class="QLabel" name="label_2" >
|
||||||
@ -97,13 +97,16 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="3" column="0" >
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3" >
|
<widget class="QLabel" name="label_3" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Priority for conversion jobs:</string>
|
<string>&Priority for conversion jobs:</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>priority</cstring>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -111,7 +114,47 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="4" column="0" >
|
||||||
|
<layout class="QHBoxLayout" >
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="compact_button" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Free unused diskspace from the database</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Compact database</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" >
|
||||||
<widget class="QGroupBox" name="dirs_box" >
|
<widget class="QGroupBox" name="dirs_box" >
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>Frequently used directories</string>
|
<string>Frequently used directories</string>
|
||||||
@ -206,7 +249,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="6" column="0" >
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
@ -676,7 +676,7 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
d = error_dialog(self, _('Cannot configure'), _('Cannot configure while there are running jobs.'))
|
d = error_dialog(self, _('Cannot configure'), _('Cannot configure while there are running jobs.'))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
return
|
return
|
||||||
d = ConfigDialog(self)
|
d = ConfigDialog(self, self.library_view.model().db)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
if d.result() == d.Accepted:
|
if d.result() == d.Accepted:
|
||||||
if os.path.dirname(self.database_path) != d.database_location:
|
if os.path.dirname(self.database_path) != d.database_location:
|
||||||
|
@ -1277,6 +1277,10 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
mi.libprs_id = id
|
mi.libprs_id = id
|
||||||
return mi
|
return mi
|
||||||
|
|
||||||
|
def vacuum(self):
|
||||||
|
self.conn.execute('VACUUM;')
|
||||||
|
self.conn.commit()
|
||||||
|
|
||||||
def export_to_dir(self, dir, indices, byauthor=False):
|
def export_to_dir(self, dir, indices, byauthor=False):
|
||||||
if not os.path.exists(dir):
|
if not os.path.exists(dir):
|
||||||
raise IOError('Target directory does not exist: '+dir)
|
raise IOError('Target directory does not exist: '+dir)
|
||||||
@ -1327,6 +1331,8 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
print 'Error setting metadata for book:', mi.title
|
print 'Error setting metadata for book:', mi.title
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SearchToken(object):
|
class SearchToken(object):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user