Changeset View
Changeset View
Standalone View
Standalone View
krusader/icon.h
- This file was copied from krusader/FileSystem/krtrashhandler.h.
1 | /***************************************************************************** | 1 | /***************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2009 Csaba Karai <krusader@users.sourceforge.net> * | 2 | * Copyright (C) 2018 Nikita Melnichenko <nikita+kde@melnichenko.name> * | ||
3 | * Copyright (C) 2009-2018 Krusader Krew [https://krusader.org] * | 3 | * Copyright (C) 2018 Krusader Krew [https://krusader.org] * | ||
4 | * * | 4 | * * | ||
5 | * This file is part of Krusader [https://krusader.org]. * | 5 | * This file is part of Krusader [https://krusader.org]. * | ||
6 | * * | 6 | * * | ||
7 | * Krusader is free software: you can redistribute it and/or modify * | 7 | * Krusader is free software: you can redistribute it and/or modify * | ||
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * | ||
9 | * the Free Software Foundation, either version 2 of the License, or * | 9 | * the Free Software Foundation, either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * | ||
11 | * * | 11 | * * | ||
12 | * Krusader is distributed in the hope that it will be useful, * | 12 | * Krusader is distributed in the hope that it will be useful, * | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
15 | * GNU General Public License for more details. * | 15 | * GNU General Public License for more details. * | ||
16 | * * | 16 | * * | ||
17 | * You should have received a copy of the GNU General Public License * | 17 | * You should have received a copy of the GNU General Public License * | ||
18 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 18 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
19 | *****************************************************************************/ | 19 | *****************************************************************************/ | ||
20 | 20 | | |||
21 | #ifndef KRTRASHHANDLER_H | 21 | #ifndef ICON_H | ||
22 | #define KRTRASHHANDLER_H | 22 | #define ICON_H | ||
23 | 23 | | |||
24 | // QtCore | 24 | // QtGui | ||
25 | #include <QString> | 25 | #include <QIcon> | ||
26 | #include <QUrl> | 26 | #include <QIconEngine> | ||
27 | 27 | | |||
28 | #include <KCoreAddons/KDirWatch> | 28 | /** | ||
29 | 29 | * @class Icon | |||
30 | class KrTrashWatcher; | 30 | * | ||
31 | 31 | * Universal icon class for Krusader. | |||
32 | class KrTrashHandler | 32 | * | ||
33 | { | 33 | * There is a list of configured themes that Icon searches in. | ||
34 | public: | 34 | * The order of themes is the following: active theme, theme specified by user, | ||
35 | static bool isTrashEmpty(); | 35 | * fallback themes that provide complete icon set for Krusader. | ||
36 | static QString trashIcon(); | 36 | * If icon is not found in any configured theme, the fallback icon is used. | ||
37 | static void emptyTrash(); | 37 | */ | ||
38 | static void restoreTrashedFiles(const QList<QUrl> &url); | 38 | class Icon : public QIcon | ||
39 | static void startWatcher(); | | |||
40 | static void stopWatcher(); | | |||
41 | | ||||
42 | private: | | |||
43 | static KrTrashWatcher * _trashWatcher; | | |||
44 | }; | | |||
45 | | ||||
46 | | ||||
47 | /** Watches the trashrc config file for changes and updates the trash icon. */ | | |||
48 | class KrTrashWatcher : public QObject | | |||
49 | { | 39 | { | ||
50 | Q_OBJECT | | |||
51 | | ||||
52 | public: | 40 | public: | ||
53 | KrTrashWatcher(); | 41 | Icon(); | ||
54 | virtual ~KrTrashWatcher(); | 42 | explicit Icon(QString name, QStringList overlays = QStringList()); | ||
55 | 43 | | |||
56 | public slots: | 44 | /// Check if icon exists in any configured theme | ||
57 | void slotTrashChanged(); | 45 | static bool exists(QString iconName); | ||
58 | 46 | | |||
59 | private: | 47 | /// Apply overlays to the pixmap with fallbacks to standard emblems | ||
60 | KDirWatch * _watcher; | 48 | static void applyOverlays(QPixmap *pixmap, QStringList overlays); | ||
61 | }; | 49 | }; | ||
62 | 50 | | |||
63 | #endif /* __KR_TRASH_HANDLER__ */ | 51 | #endif // ICON_H |