source: trunk/tools/assistant/compat/config.h@ 235

Last change on this file since 235 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the Qt Assistant of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef CONFIG_H
43#define CONFIG_H
44
45#include "profile.h"
46
47#include <QString>
48#include <QStringList>
49#include <QPixmap>
50#include <QMap>
51
52#include <QtGui/QFont>
53#include <QtGui/QFontDatabase>
54
55QT_BEGIN_NAMESPACE
56
57class Profile;
58
59struct FontSettings
60{
61 FontSettings() : useWindowFont(false), useBrowserFont(false),
62 windowWritingSystem(QFontDatabase::Latin), browserWritingSystem(QFontDatabase::Latin)
63 { }
64
65 QFont windowFont;
66 QFont browserFont;
67
68 bool useWindowFont;
69 bool useBrowserFont;
70
71 QFontDatabase::WritingSystem windowWritingSystem;
72 QFontDatabase::WritingSystem browserWritingSystem;
73};
74
75class Config
76{
77public:
78
79 Config();
80
81 void load();
82 void save();
83 Profile *profile() const { return profil; }
84 QString profileName() const { return profil->props[QLatin1String("name")]; }
85 bool validProfileName() const;
86 void hideSideBar( bool b );
87 bool sideBarHidden() const;
88 QStringList mimePaths();
89
90 // From profile, read only
91 QStringList docFiles() const;
92 QStringList docTitles() const;
93 QString indexPage( const QString &title ) const;
94 QString docImageDir( const QString &title ) const;
95 QPixmap docIcon( const QString &title ) const;
96
97 QStringList profiles() const;
98 QString title() const;
99 QString aboutApplicationMenuText() const;
100 QString aboutURL() const;
101 QPixmap applicationIcon() const;
102
103 // From QSettings, read / write
104 QString homePage() const;
105 void setHomePage( const QString &hom ) { home = hom; }
106
107 QStringList source() const;
108 void setSource( const QStringList &s ) { src = s; }
109
110 int sideBarPage() const { return sideBar; }
111 void setSideBarPage( int sbp ) { sideBar = sbp; }
112
113 QByteArray windowGeometry() const { return winGeometry; }
114 void setWindowGeometry( const QByteArray &geometry ) { winGeometry = geometry; }
115
116 QByteArray mainWindowState() const { return mainWinState; }
117 void setMainWindowState( const QByteArray &state ) { mainWinState = state; }
118
119 qreal fontPointSize() const { return pointFntSize; }
120 void setFontPointSize(qreal size)
121 {
122 pointFntSize = size;
123 m_fontSettings.useBrowserFont = true;
124 m_fontSettings.browserFont.setPointSizeF(size);
125 }
126
127 FontSettings fontSettings() { return m_fontSettings; }
128 void setFontSettings(const FontSettings &settings) { m_fontSettings = settings; }
129
130 QString assistantDocPath() const;
131
132 bool docRebuild() const { return rebuildDocs; }
133 void setDocRebuild( bool rb ) { rebuildDocs = rb; }
134
135 void saveProfile( Profile *profile );
136 void loadDefaultProfile();
137 bool defaultProfileExists();
138
139 static Config *configuration();
140 static Config *loadConfig(const QString &profileFileName);
141
142private:
143 Config( const Config &c );
144 Config& operator=( const Config &c );
145
146 void saveSettings();
147
148private:
149 Profile *profil;
150
151 QStringList profileNames;
152 QString home;
153 QStringList src;
154 QByteArray mainWinState;
155 QByteArray winGeometry;
156 qreal pointFntSize;
157 int sideBar;
158 bool hideSidebar;
159 bool rebuildDocs;
160 FontSettings m_fontSettings;
161};
162
163QT_END_NAMESPACE
164
165#endif // CONFIG_H
Note: See TracBrowser for help on using the repository browser.