Import of original sources
[qcomicbook-oblomov] / src / cbsettings.h
1 /*
2  * This file is a part of QComicBook.
3  *
4  * Copyright (C) 2005-2006 Pawel Stolowski <yogin@linux.bydg.org>
5  *
6  * QComicBook is free software; you can redestribute it and/or modify it
7  * under terms of GNU General Public License by Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY. See GPL for more details.
11  */
12
13 #ifndef __SETTINGS_H
14 #define __SETTINGS_H
15
16 #include "imgview.h"
17 #include "history.h"
18 #include "enummap.h"
19 #include <qobject.h>
20 #include <qfont.h>
21
22 class QSettings;
23 class QRect;
24 class QColor;
25 class QMainWindow;
26
27 namespace QComicBook
28 {
29         using namespace Utility;
30
31         class ComicBookSettings: public QObject
32         {
33                 Q_OBJECT
34
35                 private:
36                         QSettings *cfg;
37                         bool smallcursor;
38                         bool twopages;
39                         bool twopagesstep;
40                         bool japanese;
41                         bool contscroll;
42                         bool scrollbars;
43                         bool preload;
44                         bool fscrhidemenu;
45                         bool fscrhidestatus;
46                         bool fscrhidetoolbar;
47                         Size pagesize;
48                         //Scaling scaling;
49                         int x, y, w, h;
50                         QString lastdir;
51                         QColor bgcolor;
52                         History recent;
53                         int cachesize;
54                         int thumbsage;
55                         bool cachethumbs;
56                         bool autoinfo;
57                         bool confirmexit;
58                         bool statusbar;
59                         bool editsupport;
60                         bool intbrowser;
61                         bool showsplash;
62                         QString extbrowser;
63                         QString docklayout;
64                         QString tmpdir;
65                         QFont font;
66
67                         static QString bkpath; //bookmarks path
68                         static QString thpath; //thumbnails cache path
69                         static bool dirsok; //is above dirs are ok
70
71                         static const EnumMap<Size> size2string[];
72                         //static const EnumMap<Scaling> scaling2string[];
73
74                 signals:
75                         void backgroundChanged(const QColor &color);
76                         //void scalingMethodChanged(Scaling s);
77                         void cursorChanged(bool f);
78
79                 private:
80                         ComicBookSettings();
81                         ~ComicBookSettings();
82
83                 public:
84                         void load();
85
86                         bool smallCursor() const;
87                         bool twoPagesMode() const;
88                         bool twoPagesStep() const;
89                         bool japaneseMode() const;
90                         bool continuousScrolling() const;
91                         bool scrollbarsVisible() const;
92                         QRect geometry() const;
93                         Size pageSize() const;
94                         //Scaling pageScaling() const;
95                         QString lastDir() const;
96                         const History& recentlyOpened() const;
97                         QColor background() const;
98                         int cacheSize() const;
99                         bool cacheThumbnails() const;
100                         int thumbnailsAge() const;
101                         bool preloadPages() const;
102                         bool confirmExit() const;
103                         bool autoInfo() const;
104                         bool fullScreenHideMenu() const;
105                         bool fullScreenHideStatusbar() const;
106                         bool fullScreenHideToolbar() const;
107                         bool showStatusbar() const;
108                         bool useInternalBrowser() const;
109                         const QFont& infoFont() const;
110                         QString externalBrowser() const;
111                         void restoreDockLayout(QMainWindow *w);
112                         bool editSupport() const;
113                         bool showSplash() const;
114                         QString tmpDir() const;
115
116                         void smallCursor(bool f);
117                         void twoPagesMode(bool f);
118                         void twoPagesStep(bool f);
119                         void japaneseMode(bool f);
120                         void continuousScrolling(bool f);
121                         void scrollbarsVisible(bool f);
122                         void geometry(const QRect g);
123                         void pageSize(Size s);
124                         //void pageScaling(Scaling s);
125                         void lastDir(const QString &d);
126                         void recentlyOpened(const History &hist);
127                         void background(const QColor &color);
128                         void cacheSize(int s);
129                         void cacheThumbnails(bool f);
130                         void thumbnailsAge(int n);
131                         void preloadPages(bool f);
132                         void confirmExit(bool f);
133                         void autoInfo(bool f);
134                         void fullScreenHideMenu(bool f);
135                         void fullScreenHideStatusbar(bool f);
136                         void fullScreenHideToolbar(bool f);
137                         void showStatusbar(bool f);
138                         void useInternalBrowser(bool f);
139                         void infoFont(const QFont &f);
140                         void externalBrowser(const QString &cmd);
141                         void saveDockLayout(QMainWindow *w);
142                         void editSupport(bool f);
143                         void showSplash(bool f);
144                         void tmpDir(const QString &dir);
145
146                         static ComicBookSettings& instance();
147
148                         //
149                         // checks and creates .qcomicbook/ and cache subdirectories if
150                         // necessary
151                         static bool checkDirs();
152                         static const QString& bookmarksDir();
153                         static const QString& thumbnailsDir();
154         };
155 }
156
157 #endif
158