digiKam
thememanager_p.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2004-08-02
7  * Description : colors theme manager - private classes
8  *
9  * Copyright (C) 2006-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2007 by Matthew Woehlke <mw_triad at users dot sourceforge dot net>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_THEME_MANAGER_P_H
26 #define DIGIKAM_THEME_MANAGER_P_H
27 
28 #include "thememanager.h"
29 
30 // C++ includes
31 
32 #include <cmath>
33 
34 // Qt includes
35 
36 #include <QWidget>
37 #include <QPainter>
38 #include <QStringList>
39 #include <QFileInfo>
40 #include <QPalette>
41 #include <QColor>
42 #include <QPixmap>
43 #include <QApplication>
44 #include <QAction>
45 #include <QStandardPaths>
46 #include <QDirIterator>
47 #include <QMenu>
48 #include <QStyle>
49 #include <QExplicitlySharedDataPointer>
50 #include <QBrush>
51 #include <QBitmap>
52 #include <QActionGroup>
53 
54 // KDE includes
55 
56 #if !defined(Q_OS_DARWIN) && defined(Q_CC_GNU)
57 # pragma GCC diagnostic push
58 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
59 #endif
60 
61 #if defined(Q_CC_CLANG)
62 # pragma clang diagnostic push
63 # pragma clang diagnostic ignored "-Wdeprecated-declarations"
64 #endif
65 
66 #include <ksharedconfig.h>
67 #include <kactioncollection.h>
68 #include <kconfiggroup.h>
69 #include <klocalizedstring.h>
70 
71 // Restore warnings
72 #if !defined(Q_OS_DARWIN) && defined(Q_CC_GNU)
73 # pragma GCC diagnostic pop
74 #endif
75 
76 #if defined(Q_CC_CLANG)
77 # pragma clang diagnostic pop
78 #endif
79 
80 // Local includes
81 
82 #include "digikam_debug.h"
83 #include "dxmlguiwindow.h"
84 
85 namespace Digikam
86 {
87 
88 class SchemeManagerPrivate;
89 
120 class Q_DECL_HIDDEN SchemeManager
121 {
122 public:
123 
131  enum ColorSet
132  {
179  Complementary
180  };
181 
192  {
196  NormalBackground = 0,
203  AlternateBackground = 1,
213  ActiveBackground = 2,
222  LinkBackground = 3,
230  VisitedBackground = 4,
234  NegativeBackground = 5,
238  NeutralBackground = 6,
242  PositiveBackground = 7
243  };
244 
262  {
266  NormalText = 0,
273  InactiveText = 1,
278  ActiveText = 2,
284  LinkText = 3,
292  VisitedText = 4,
297  NegativeText = 5,
301  NeutralText = 6,
306  PositiveText = 7
307  };
308 
319  {
328  HoverColor
329  };
330 
340  {
362  ShadowShade
363  };
364 
365 public:
366 
371 
375  ~SchemeManager() = default;
376 
380  SchemeManager& operator=(const SchemeManager&);
381 
386  explicit SchemeManager(QPalette::ColorGroup state,
387  ColorSet set = View,
388  KSharedConfigPtr config = KSharedConfigPtr());
389 
393  QBrush background(BackgroundRole = NormalBackground) const;
394 
398  QBrush foreground(ForegroundRole = NormalText) const;
399 
403  QBrush decoration(DecorationRole) const;
404 
418  QColor shade(ShadeRole) const;
419 
425  static int contrast();
426 
434  static qreal contrastF(const KSharedConfigPtr& config = KSharedConfigPtr());
435 
446  static QColor shade(const QColor&, ShadeRole);
447 
465  static QColor shade(const QColor&,
466  ShadeRole,
467  qreal contrast,
468  qreal chromaAdjust = 0.0);
469 
479  static void adjustBackground(QPalette&,
480  BackgroundRole newRole = NormalBackground,
481  QPalette::ColorRole color = QPalette::Base,
482  ColorSet set = View,
483  const KSharedConfigPtr& config = KSharedConfigPtr());
484 
494  static void adjustForeground(QPalette&,
495  ForegroundRole newRole = NormalText,
496  QPalette::ColorRole color = QPalette::Text,
497  ColorSet set = View,
498  const KSharedConfigPtr& config = KSharedConfigPtr());
499 
508  static QPalette createApplicationPalette(const KSharedConfigPtr& config);
509 
510 private:
511 
512  QExplicitlySharedDataPointer<SchemeManagerPrivate> d;
513 };
514 
515 // --------------------------------------------------------------------------
516 
517 class Q_DECL_HIDDEN ThemeManager::Private
518 {
519 public:
520 
521  explicit Private();
522 
523  QPixmap createSchemePreviewIcon(const KSharedConfigPtr& config) const;
524 
525 public:
526 
527  const QString defaultThemeName;
528  QMap<QString, QString> themeMap;
529 
530  QActionGroup* themeMenuActionGroup;
532 };
533 
534 } // namespace Digikam
535 
536 #endif // DIGIKAM_THEME_MANAGER_P_H
Definition: thememanager_p.h:121
ColorSet
Definition: thememanager_p.h:132
@ View
Definition: thememanager_p.h:138
@ Button
Definition: thememanager_p.h:152
@ Tooltip
Definition: thememanager_p.h:169
@ Window
Definition: thememanager_p.h:144
@ Selection
Definition: thememanager_p.h:160
DecorationRole
Definition: thememanager_p.h:319
@ FocusColor
Definition: thememanager_p.h:323
BackgroundRole
Definition: thememanager_p.h:192
ForegroundRole
Definition: thememanager_p.h:262
ShadeRole
Definition: thememanager_p.h:340
@ MidShade
Definition: thememanager_p.h:353
@ MidlightShade
Definition: thememanager_p.h:349
@ LightShade
Definition: thememanager_p.h:345
@ DarkShade
Definition: thememanager_p.h:357
Definition: thememanager_p.h:518
const QString defaultThemeName
Definition: thememanager_p.h:527
QMap< QString, QString > themeMap
map<theme name, theme config path>
Definition: thememanager_p.h:528
QActionGroup * themeMenuActionGroup
Definition: thememanager_p.h:530
QMenu * themeMenuAction
Definition: thememanager_p.h:531
Definition: thememanager.h:46
QColor shade(const QColor &color, qreal ky, qreal kc=0.0)
Definition: thememanager_p.cpp:169
Definition: datefolderview.cpp:43