Themes are now searched by desktop files.
[tagua/yd.git] / src / pref_theme.h
blob02da674635f9923b9c837746792f406d8bbd4e91
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef PREFERENCES__THEME_H
12 #define PREFERENCES__THEME_H
14 #include <set>
15 #include <map>
16 #include <boost/shared_ptr.hpp>
17 #include <QDateTime>
18 #include <QDir>
19 #include "option.h"
20 #include "ui_pref_theme.h"
21 #include "ui_pref_theme_page.h"
23 class VariantInfo;
24 class Settings;
25 class QAction;
27 class PrefTheme : public QWidget
28 , private Ui::PrefTheme {
29 Q_OBJECT
30 friend class PrefThemeCategory;
31 typedef class PrefThemeCategory Category;
33 class ThemeInfo {
34 public:
35 QString file_name;
36 QString name;
37 QString description;
38 QStringList variants;
39 QDateTime last_modified;
41 ThemeInfo() {}
42 ThemeInfo(const QString& f, const QString& n,
43 const QString& d, const QStringList& v, const QDateTime& t)
44 : file_name(f)
45 , name(n)
46 , description(d)
47 , variants(v)
48 , last_modified(t) {}
51 typedef QList<ThemeInfo> ThemeInfoList;
52 typedef std::map<QString, Category*> CategoryMap;
54 std::map<QString, boost::shared_ptr<OptList> > m_new_theme_options;
55 CategoryMap m_categories;
57 OptList get_file_options(const QString&, bool reload_defaults = false);
58 static ThemeInfoList to_theme_info_list(const QStringList& files, const Settings& s);
59 static void update_list_view(QListWidget* list, const ThemeInfoList& themes,
60 QString variant, QString settings);
61 static void read_theme_info(PrefTheme::ThemeInfo& info, const QString& desktopFile);
62 private slots:
63 void variantChanged();
65 public:
66 PrefTheme(QWidget *parent = 0);
67 ~PrefTheme();
69 void apply();
71 static QString getBestTheme(VariantInfo* vi, const QString&);
75 class PrefThemeCategory : public QWidget
76 , private Ui::PrefThemePage {
77 Q_OBJECT
79 public:
80 friend class PrefTheme;
81 QAction* m_reset;
82 PrefTheme* m_parent;
83 QString m_id;
84 PrefTheme::ThemeInfoList m_themes;
85 std::map<QString, QString> m_new_themes;
86 std::map<QString, bool> m_new_use_def;
88 QLayout *m_opt_layout;
89 QWidget *m_opt_widget;
91 PrefThemeCategory(QWidget* parent, PrefTheme* owner);
93 public slots:
94 void reset();
95 void themeChanged();
96 void themeChecked(bool ck);
100 #endif //PREFERENCES__THEME_H