1#!/usr/local/bin/python3.8
2# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
3
4
5__license__   = 'GPL v3'
6__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
7__docformat__ = 'restructuredtext en'
8
9from qt.core import QWidget, QHBoxLayout, QLabel, QLineEdit
10
11from calibre.utils.config import JSONConfig
12
13# This is where all preferences for this plugin will be stored
14# Remember that this name (i.e. plugins/interface_demo) is also
15# in a global namespace, so make it as unique as possible.
16# You should always prefix your config file name with plugins/,
17# so as to ensure you dont accidentally clobber a calibre config file
18prefs = JSONConfig('plugins/interface_demo')
19
20# Set defaults
21prefs.defaults['hello_world_msg'] = 'Hello, World!'
22
23
24class ConfigWidget(QWidget):
25
26    def __init__(self):
27        QWidget.__init__(self)
28        self.l = QHBoxLayout()
29        self.setLayout(self.l)
30
31        self.label = QLabel('Hello world &message:')
32        self.l.addWidget(self.label)
33
34        self.msg = QLineEdit(self)
35        self.msg.setText(prefs['hello_world_msg'])
36        self.l.addWidget(self.msg)
37        self.label.setBuddy(self.msg)
38
39    def save_settings(self):
40        prefs['hello_world_msg'] = self.msg.text()
41