tools/assistant/compat/config.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Assistant of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    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 
       
    55 QT_BEGIN_NAMESPACE
       
    56 
       
    57 class Profile;
       
    58 
       
    59 struct 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 
       
    75 class Config
       
    76 {
       
    77 public:
       
    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 
       
   142 private:
       
   143     Config( const Config &c );
       
   144     Config& operator=( const Config &c );
       
   145 
       
   146     void saveSettings();
       
   147     
       
   148 private:
       
   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 
       
   163 QT_END_NAMESPACE
       
   164 
       
   165 #endif // CONFIG_H