mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Add quick start guide on first run
This commit is contained in:
parent
ee561de271
commit
e12253ff15
@ -10,11 +10,12 @@ from PyQt4.QtGui import QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
|
|||||||
ORG_NAME = 'KovidsBrain'
|
ORG_NAME = 'KovidsBrain'
|
||||||
APP_UID = 'libprs500'
|
APP_UID = 'libprs500'
|
||||||
from calibre import islinux, iswindows, isosx
|
from calibre import islinux, iswindows, isosx
|
||||||
from calibre.utils.config import Config, ConfigProxy, dynamic
|
from calibre.utils.config import Config, ConfigProxy, dynamic, JSONConfig
|
||||||
from calibre.utils.localization import set_qt_translator
|
from calibre.utils.localization import set_qt_translator
|
||||||
from calibre.ebooks.metadata.meta import get_metadata, metadata_from_formats
|
from calibre.ebooks.metadata.meta import get_metadata, metadata_from_formats
|
||||||
from calibre.ebooks.metadata import MetaInformation
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
|
|
||||||
|
gprefs = JSONConfig('gui')
|
||||||
|
|
||||||
NONE = QVariant() #: Null value to return from the data function of item models
|
NONE = QVariant() #: Null value to return from the data function of item models
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ from calibre.utils.ipc.server import Server
|
|||||||
from calibre.gui2 import warning_dialog, choose_files, error_dialog, \
|
from calibre.gui2 import warning_dialog, choose_files, error_dialog, \
|
||||||
question_dialog,\
|
question_dialog,\
|
||||||
pixmap_to_data, choose_dir, \
|
pixmap_to_data, choose_dir, \
|
||||||
Dispatcher, \
|
Dispatcher, gprefs, \
|
||||||
available_height, \
|
available_height, \
|
||||||
max_available_height, config, info_dialog, \
|
max_available_height, config, info_dialog, \
|
||||||
available_width, GetMetadata
|
available_width, GetMetadata
|
||||||
@ -518,7 +518,21 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.connect(self.library_view.model(), SIGNAL('count_changed(int)'),
|
self.connect(self.library_view.model(), SIGNAL('count_changed(int)'),
|
||||||
self.tags_view.recount)
|
self.tags_view.recount)
|
||||||
self.connect(self.search, SIGNAL('cleared()'), self.tags_view.clear)
|
self.connect(self.search, SIGNAL('cleared()'), self.tags_view.clear)
|
||||||
|
if not gprefs.get('quick_start_guide_added', False):
|
||||||
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
|
mi = MetaInformation(_('Calibre Quick Start Guide'), ['John Schember'])
|
||||||
|
mi.author_sort = 'Schember, John'
|
||||||
|
mi.comments = "A guide to get you up an running with calibre"
|
||||||
|
mi.publisher = 'calibre'
|
||||||
|
self.library_view.model().add_books([P('quick_start.epub')], ['epub'],
|
||||||
|
[mi])
|
||||||
|
gprefs['quick_start_guide_added'] = True
|
||||||
|
self.library_view.model().books_added(1)
|
||||||
|
if hasattr(self, 'db_images'):
|
||||||
|
self.db_images.reset()
|
||||||
|
|
||||||
self.library_view.model().count_changed()
|
self.library_view.model().count_changed()
|
||||||
|
|
||||||
########################### Cover Flow ################################
|
########################### Cover Flow ################################
|
||||||
self.cover_flow = None
|
self.cover_flow = None
|
||||||
if CoverFlow is not None:
|
if CoverFlow is not None:
|
||||||
@ -1008,7 +1022,6 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
return
|
return
|
||||||
self._add_books(books, to_device)
|
self._add_books(books, to_device)
|
||||||
|
|
||||||
|
|
||||||
def _add_books(self, paths, to_device, on_card=None):
|
def _add_books(self, paths, to_device, on_card=None):
|
||||||
if on_card is None:
|
if on_card is None:
|
||||||
on_card = 'carda' if self.stack.currentIndex() == 2 else 'cardb' if self.stack.currentIndex() == 3 else None
|
on_card = 'carda' if self.stack.currentIndex() == 2 else 'cardb' if self.stack.currentIndex() == 3 else None
|
||||||
|
@ -6,7 +6,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
'''
|
'''
|
||||||
Manage application-wide preferences.
|
Manage application-wide preferences.
|
||||||
'''
|
'''
|
||||||
import os, re, cPickle, textwrap, traceback, plistlib
|
import os, re, cPickle, textwrap, traceback, plistlib, json
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from optparse import OptionParser as _OptionParser
|
from optparse import OptionParser as _OptionParser
|
||||||
@ -564,23 +564,31 @@ class XMLConfig(dict):
|
|||||||
data types.
|
data types.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
EXTENSION = '.plist'
|
||||||
|
|
||||||
def __init__(self, rel_path_to_cf_file):
|
def __init__(self, rel_path_to_cf_file):
|
||||||
dict.__init__(self)
|
dict.__init__(self)
|
||||||
self.file_path = os.path.join(config_dir,
|
self.file_path = os.path.join(config_dir,
|
||||||
*(rel_path_to_cf_file.split('/')))
|
*(rel_path_to_cf_file.split('/')))
|
||||||
self.file_path = os.path.abspath(self.file_path)
|
self.file_path = os.path.abspath(self.file_path)
|
||||||
if not self.file_path.endswith('.plist'):
|
if not self.file_path.endswith(self.EXTENSION):
|
||||||
self.file_path += '.plist'
|
self.file_path += self.EXTENSION
|
||||||
|
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
|
def raw_to_object(self, raw):
|
||||||
|
return plistlib.readPlistFromString(raw)
|
||||||
|
|
||||||
|
def to_raw(self):
|
||||||
|
return plistlib.writePlistToString(self)
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
d = {}
|
d = {}
|
||||||
if os.path.exists(self.file_path):
|
if os.path.exists(self.file_path):
|
||||||
with ExclusiveFile(self.file_path) as f:
|
with ExclusiveFile(self.file_path) as f:
|
||||||
raw = f.read()
|
raw = f.read()
|
||||||
try:
|
try:
|
||||||
d = plistlib.readPlistFromString(raw) if raw.strip() else {}
|
d = self.raw_to_object(raw) if raw.strip() else {}
|
||||||
except SystemError:
|
except SystemError:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
@ -618,11 +626,21 @@ class XMLConfig(dict):
|
|||||||
if not os.path.exists(dpath):
|
if not os.path.exists(dpath):
|
||||||
os.makedirs(dpath, mode=CONFIG_DIR_MODE)
|
os.makedirs(dpath, mode=CONFIG_DIR_MODE)
|
||||||
with ExclusiveFile(self.file_path) as f:
|
with ExclusiveFile(self.file_path) as f:
|
||||||
raw = plistlib.writePlistToString(self)
|
raw = self.to_raw()
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
f.truncate()
|
f.truncate()
|
||||||
f.write(raw)
|
f.write(raw)
|
||||||
|
|
||||||
|
class JSONConfig(XMLConfig):
|
||||||
|
|
||||||
|
EXTENSION = '.json'
|
||||||
|
|
||||||
|
def raw_to_object(self, raw):
|
||||||
|
return json.loads(raw.decode('utf-8'))
|
||||||
|
|
||||||
|
def to_raw(self):
|
||||||
|
return json.dumps(self, indent=2)
|
||||||
|
|
||||||
|
|
||||||
def _prefs():
|
def _prefs():
|
||||||
c = Config('global', 'calibre wide preferences')
|
c = Config('global', 'calibre wide preferences')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user