~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/gui2/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090730124941-kviipg9ypwgppulc
Tags: upstream-0.6.3+dfsg
ImportĀ upstreamĀ versionĀ 0.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
NONE = QVariant() #: Null value to return from the data function of item models
21
21
 
22
 
ALL_COLUMNS = ['title', 'authors', 'size', 'timestamp', 'rating', 'publisher', 'tags', 'series']
 
22
ALL_COLUMNS = ['title', 'authors', 'size', 'timestamp', 'rating', 'publisher',
 
23
        'tags', 'series', 'pubdate']
23
24
 
24
25
def _config():
25
26
    c = Config('gui', 'preferences for the calibre GUI')
27
28
              help=_('Frequently used directories'))
28
29
    c.add_opt('send_to_storage_card_by_default', default=False,
29
30
              help=_('Send file to storage card instead of main memory by default'))
30
 
    c.add_opt('save_to_disk_single_format', default='lrf',
31
 
              help=_('The format to use when saving single files to disk'))
32
31
    c.add_opt('confirm_delete', default=False,
33
32
              help=_('Confirm before deleting'))
34
33
    c.add_opt('toolbar_icon_size', default=QSize(48, 48),
49
48
              help=_('Defaults for conversion to LRF'))
50
49
    c.add_opt('LRF_ebook_viewer_options', default=None,
51
50
              help=_('Options for the LRF ebook viewer'))
52
 
    c.add_opt('internally_viewed_formats', default=['LRF', 'EPUB', 'LIT', 'MOBI', 'PRC', 'HTML', 'FB2'],
 
51
    c.add_opt('internally_viewed_formats', default=['LRF', 'EPUB', 'LIT',
 
52
        'MOBI', 'PRC', 'HTML', 'FB2', 'PDB', 'RB'],
53
53
              help=_('Formats that are viewed using the internal viewer'))
54
54
    c.add_opt('column_map', default=ALL_COLUMNS,
55
55
              help=_('Columns to be displayed in the book list'))
71
71
            help='Show donation button')
72
72
    c.add_opt('asked_library_thing_password', default=False,
73
73
            help='Asked library thing password at least once.')
 
74
    c.add_opt('search_as_you_type', default=True,
 
75
            help='Start searching as you type. If this is disabled then search will '
 
76
            'only take place when the Enter or Return key is pressed.')
74
77
    return ConfigProxy(c)
75
78
 
76
79
config = _config()
100
103
def extension(path):
101
104
    return os.path.splitext(path)[1][1:].lower()
102
105
 
103
 
def warning_dialog(parent, title, msg):
 
106
def warning_dialog(parent, title, msg, det_msg='', show=False):
104
107
    d = QMessageBox(QMessageBox.Warning, 'WARNING: '+title, msg, QMessageBox.Ok,
105
108
                    parent)
 
109
    d.setDetailedText(det_msg)
106
110
    d.setIconPixmap(QPixmap(':/images/dialog_warning.svg'))
 
111
 
 
112
    if show:
 
113
        return d.exec_()
107
114
    return d
108
115
 
109
 
def error_dialog(parent, title, msg):
 
116
def error_dialog(parent, title, msg, det_msg='', show=False):
110
117
    d = QMessageBox(QMessageBox.Critical, 'ERROR: '+title, msg, QMessageBox.Ok,
111
118
                    parent)
 
119
    d.setDetailedText(det_msg)
112
120
    d.setIconPixmap(QPixmap(':/images/dialog_error.svg'))
 
121
    if show:
 
122
        return d.exec_()
113
123
    return d
114
124
 
115
 
def question_dialog(parent, title, msg):
 
125
def question_dialog(parent, title, msg, det_msg=''):
116
126
    d = QMessageBox(QMessageBox.Question, title, msg, QMessageBox.Yes|QMessageBox.No,
117
127
                    parent)
 
128
    d.setDetailedText(det_msg)
118
129
    d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
119
 
    return d
 
130
    return d.exec_() == QMessageBox.Yes
120
131
 
121
 
def info_dialog(parent, title, msg):
 
132
def info_dialog(parent, title, msg, det_msg='', show=False):
122
133
    d = QMessageBox(QMessageBox.Information, title, msg, QMessageBox.NoButton,
123
134
                    parent)
 
135
    d.setDetailedText(det_msg)
124
136
    d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
 
137
    if show:
 
138
        return d.exec_()
125
139
    return d
126
140
 
 
141
 
127
142
def qstring_to_unicode(q):
128
143
    return unicode(q)
129
144
 
327
342
                ftext += '%s (%s);;'%(text, ' '.join(extensions))
328
343
        if add_all_files_filter or not ftext:
329
344
            ftext += 'All files (*)'
 
345
        if ftext.endswith(';;'):
 
346
            ftext = ftext[:-2]
330
347
 
331
348
        self.dialog_name = name if name else 'dialog_' + title
332
349
        self.selected_files = None
451
468
        nw = min(self.width(), nw)
452
469
        self.resize(nw, nh)
453
470
 
454
 
try:
455
 
    from calibre.utils.single_qt_application import SingleApplication
456
 
    SingleApplication
457
 
except:
458
 
    SingleApplication = None
459
 
 
460
471
gui_thread = None
461
472
 
462
473
class Application(QApplication):