summaryrefslogtreecommitdiffstats
path: root/libkonq/konq_settings.h
blob: 8f3d981fcd788b50b7625580339faec343e68515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* This file is part of the KDE project
   Copyright (C) 1999 David Faure <[email protected]>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef __konq_settings_h__
#define __konq_settings_h__

class KConfig;
#include <qcolor.h>
#include <qstring.h>
#include <qfont.h>
#include <qmap.h>

#include <libkonq_export.h>

/**
 * The class KonqFMSettings holds the general settings for the
 * icon/tree views in konqueror/kdesktop.
 * There is no 'local' (per-URL) instance of it.
 * All those settings can only be changed in kcmkonq.
 *
 * Using this class from konqueror and from kdesktop return
 * different settings, since the config file is different.
 * konquerorrc, group "FMSettings", and kdesktoprc, group "FMSettings"
 * The kcontrol modules handles both files, depending where
 * it's called from.
 */

class LIBKONQ_EXPORT KonqFMSettings
{
protected:
  /**
   * @internal
   * Constructs a KonqFMSettings instance from a config file.
   */
  KonqFMSettings( KConfig * config );

  /** Destructor. Don't delete any instance by yourself. */
  virtual ~KonqFMSettings();

public:

  /**
   * The static instance of KonqFMSettings
   */
  static KonqFMSettings * settings();

  /**
   * Reparse the configuration to update the already-created instances
   *
   * Warning : you need to call KGlobal::config()->reparseConfiguration()
   * first (This is not done here so that the caller can avoid too much
   * reparsing if having several classes from the same config file)
   */
  static void reparseConfiguration();

  // Use settings (and mimetype definition files)
  // to find whether to embed a certain service type or not
  // Only makes sense in konqueror.
  bool shouldEmbed( const QString & serviceType ) const;

  // Behaviour settings
  bool wordWrapText() const { return m_bWordWrapText; }
  int iconTextHeight() const { return m_iconTextHeight; }
  int iconTextWidth() const;
  bool underlineLink() const { return m_underlineLink; }
  bool fileSizeInBytes() const { return m_fileSizeInBytes; }
  bool alwaysNewWin() const { return m_alwaysNewWin; }
  const QString & homeURL() const { return m_homeURL; }

  bool showFileTips() const {return m_showFileTips; }
  bool showPreviewsInFileTips() const;
  int numFileTips() const {return m_numFileTips; }
    bool renameIconDirectly() const;

  // Font settings
  const QFont& standardFont() const { return m_standardFont; }

  // Color settings
  const QColor& normalTextColor() const { return m_normalTextColor; }
  const QColor& highlightedTextColor() const { return m_highlightedTextColor; }
  const QColor& itemTextBackground() const { return m_itemTextBackground; }

  int textPreviewIconTransparency() const { return m_iconTransparency; }

  int caseSensitiveCompare( const QString& a, const QString& b ) const;

private:

  static KonqFMSettings * s_pSettings;

  bool m_underlineLink;
  bool m_fileSizeInBytes;
  bool m_alwaysNewWin;
  bool m_bTreeFollow;

  QMap<QString, QString> m_embedMap;

  QFont m_standardFont;

  QColor m_normalTextColor;
  QColor m_highlightedTextColor;
  QColor m_itemTextBackground;

  bool m_bWordWrapText;
  int m_iconTextHeight;

  QString m_homeURL;
  bool m_showFileTips;
  int  m_numFileTips;

  // used for the textpreview
  int m_iconTransparency;

  /** Called by constructor and reparseConfiguration */
  void init( KConfig * config );

  struct KonqFMSettingsPrivate * d;

  // There is no default constructor. Use the provided ones.
  KonqFMSettings();
  // No copy constructor either. What for ?
  KonqFMSettings( const KonqFMSettings &);
};

#endif