Changeset View
Changeset View
Standalone View
Standalone View
kcms/icons/main.h
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * main.h | 2 | * main.h | ||
3 | * | 3 | * | ||
4 | * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> | 4 | * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> | ||
5 | * KDE Frameworks 5 port Copyright (C) 2013 Jonathan Riddell <jr@jriddell.org> | 5 | * KDE Frameworks 5 port Copyright (C) 2013 Jonathan Riddell <jr@jriddell.org> | ||
6 | * Copyright (c) 2018 Kai Uwe Broulik <kde@privat.broulik.de> | 6 | * Copyright (c) 2018 Kai Uwe Broulik <kde@privat.broulik.de> | ||
7 | * Copyright (C) 2019 Benjamin Port <benjamin.port@enioka.com> | ||||
7 | * | 8 | * | ||
8 | * Requires the Qt widget libraries, available at no cost at | 9 | * Requires the Qt widget libraries, available at no cost at | ||
9 | * http://www.troll.no/ | 10 | * http://www.troll.no/ | ||
10 | * | 11 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | 15 | * (at your option) any later version. | ||
Show All 10 Lines | |||||
25 | 26 | | |||
26 | #pragma once | 27 | #pragma once | ||
27 | 28 | | |||
28 | #include <KQuickAddons/ConfigModule> | 29 | #include <KQuickAddons/ConfigModule> | ||
29 | 30 | | |||
30 | #include <KNS3/DownloadDialog> | 31 | #include <KNS3/DownloadDialog> | ||
31 | 32 | | |||
32 | #include <QScopedPointer> | 33 | #include <QScopedPointer> | ||
33 | 34 | | |||
ervin: s/QMap/QHash/ | |||||
ervin: Still not addressed, use a QHash | |||||
34 | class KIconTheme; | 35 | class KIconTheme; | ||
36 | class IconsSettings; | ||||
35 | 37 | | |||
36 | class QQuickItem; | 38 | class QQuickItem; | ||
37 | class QTemporaryFile; | 39 | class QTemporaryFile; | ||
38 | 40 | | |||
39 | namespace KIO | 41 | namespace KIO | ||
40 | { | 42 | { | ||
41 | class FileCopyJob; | 43 | class FileCopyJob; | ||
42 | } | 44 | } | ||
43 | 45 | | |||
44 | class IconsModel; | 46 | class IconsModel; | ||
45 | 47 | | |||
46 | class IconModule : public KQuickAddons::ConfigModule | 48 | class IconModule : public KQuickAddons::ConfigModule | ||
47 | { | 49 | { | ||
48 | Q_OBJECT | 50 | Q_OBJECT | ||
49 | 51 | Q_PROPERTY(IconsSettings *iconsSettings READ iconsSettings CONSTANT) | |||
50 | Q_PROPERTY(IconsModel *iconsModel READ iconsModel CONSTANT) | 52 | Q_PROPERTY(IconsModel *iconsModel READ iconsModel CONSTANT) | ||
51 | | ||||
52 | Q_PROPERTY(QStringList iconGroups READ iconGroups CONSTANT) | 53 | Q_PROPERTY(QStringList iconGroups READ iconGroups CONSTANT) | ||
53 | | ||||
54 | Q_PROPERTY(bool downloadingFile READ downloadingFile NOTIFY downloadingFileChanged) | 54 | Q_PROPERTY(bool downloadingFile READ downloadingFile NOTIFY downloadingFileChanged) | ||
55 | 55 | | |||
56 | public: | 56 | public: | ||
57 | IconModule(QObject *parent, const QVariantList &args); | 57 | IconModule(QObject *parent, const QVariantList &args); | ||
58 | ~IconModule() override; | 58 | ~IconModule() override; | ||
59 | 59 | | |||
60 | enum Roles { | 60 | enum Roles { | ||
61 | ThemeNameRole = Qt::UserRole + 1, | 61 | ThemeNameRole = Qt::UserRole + 1, | ||
62 | DescriptionRole, | 62 | DescriptionRole, | ||
63 | RemovableRole, | 63 | RemovableRole, | ||
64 | PendingDeletionRole | 64 | PendingDeletionRole | ||
65 | }; | 65 | }; | ||
66 | 66 | | |||
67 | IconsSettings *iconsSettings() const; | ||||
68 | | ||||
67 | IconsModel *iconsModel() const; | 69 | IconsModel *iconsModel() const; | ||
68 | 70 | | |||
69 | QStringList iconGroups() const; | 71 | QStringList iconGroups() const; | ||
70 | 72 | | |||
71 | bool downloadingFile() const; | 73 | bool downloadingFile() const; | ||
72 | 74 | | |||
73 | void load() override; | 75 | void load() override; | ||
74 | void save() override; | 76 | void save() override; | ||
75 | void defaults() override; | 77 | void defaults() override; | ||
76 | 78 | | |||
77 | Q_INVOKABLE void getNewStuff(QQuickItem *ctx); | 79 | Q_INVOKABLE void getNewStuff(QQuickItem *ctx); | ||
78 | Q_INVOKABLE void installThemeFromFile(const QUrl &url); | 80 | Q_INVOKABLE void installThemeFromFile(const QUrl &url); | ||
79 | 81 | | |||
80 | Q_INVOKABLE int iconSize(int group) const; | | |||
81 | Q_INVOKABLE void setIconSize(int group, int size); | | |||
82 | Q_INVOKABLE QList<int> availableIconSizes(int group) const; | 82 | Q_INVOKABLE QList<int> availableIconSizes(int group) const; | ||
ervin: Killing the const here is semantically wrong IMO. | |||||
ervin: Still not addressed, put the const back | |||||
83 | 83 | | |||
84 | // QML doesn't understand QList<QPixmap>, hence wrapped in a QVariantList | 84 | // QML doesn't understand QList<QPixmap>, hence wrapped in a QVariantList | ||
85 | Q_INVOKABLE QVariantList previewIcons(const QString &themeName, int size, qreal dpr, int limit = -1); | 85 | Q_INVOKABLE QVariantList previewIcons(const QString &themeName, int size, qreal dpr, int limit = -1); | ||
86 | 86 | | |||
87 | signals: | 87 | signals: | ||
88 | void iconSizesChanged(); | 88 | void iconSizesChanged(); | ||
89 | void downloadingFileChanged(); | 89 | void downloadingFileChanged(); | ||
90 | 90 | | |||
91 | void showSuccessMessage(const QString &message); | 91 | void showSuccessMessage(const QString &message); | ||
92 | void showErrorMessage(const QString &message); | 92 | void showErrorMessage(const QString &message); | ||
93 | 93 | | |||
94 | void showProgress(const QString &message); | 94 | void showProgress(const QString &message); | ||
95 | void hideProgress(); | 95 | void hideProgress(); | ||
96 | 96 | | |||
97 | private: | 97 | private: | ||
98 | void loadIconSizes(); | 98 | void loadIconSizes(); | ||
99 | void updateNeedsSave(); | ||||
100 | bool isThemeDirty() const; | ||||
99 | 101 | | |||
100 | void processPendingDeletions(); | 102 | void processPendingDeletions(); | ||
101 | 103 | | |||
102 | static QStringList findThemeDirs(const QString &archiveName); | 104 | static QStringList findThemeDirs(const QString &archiveName); | ||
103 | bool installThemes(const QStringList &themes, const QString &archiveName); | 105 | bool installThemes(const QStringList &themes, const QString &archiveName); | ||
104 | void installThemeFile(const QString &path); | 106 | void installThemeFile(const QString &path); | ||
105 | 107 | | |||
106 | void exportToKDE4(); | 108 | void exportToKDE4(); | ||
107 | 109 | | |||
108 | static QPixmap getBestIcon(KIconTheme &theme, const QStringList &iconNames, int size, qreal dpr); | 110 | static QPixmap getBestIcon(KIconTheme &theme, const QStringList &iconNames, int size, qreal dpr); | ||
109 | 111 | | |||
110 | IconsModel *m_model; | 112 | IconsSettings *m_settings; | ||
111 | // so we avoid launching changeicon process when theme didn't change (but only e.g. pending deletions) | | |||
112 | bool m_selectedThemeDirty = false; | | |||
113 | bool m_iconSizesDirty = false; | | |||
114 | 113 | | |||
115 | QVector<int> m_iconSizes; | 114 | IconsModel *m_model; | ||
You don't need the keys to be sorted, so please use QHash instead. Also we do camel case here, not snake case. :-) ervin: You don't need the keys to be sorted, so please use QHash instead.
Also we do camel case here… | |||||
Still not addressed... s/m_kicon_theme_map/m_iconThemeMap/ (we do camel case here) and should be a QHash. ervin: Still not addressed... s/m_kicon_theme_map/m_iconThemeMap/ (we do camel case here) and should… | |||||
116 | 115 | | |||
117 | QStringList m_iconGroups; | 116 | QStringList m_iconGroups; | ||
118 | 117 | | |||
119 | QScopedPointer<QTemporaryFile> m_tempInstallFile; | 118 | QScopedPointer<QTemporaryFile> m_tempInstallFile; | ||
120 | QPointer<KIO::FileCopyJob> m_tempCopyJob; | 119 | QPointer<KIO::FileCopyJob> m_tempCopyJob; | ||
121 | 120 | | |||
122 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | 121 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | ||
123 | | ||||
124 | }; | 122 | }; |
s/QMap/QHash/