From 3d2eb4f8711ed9fcc7db3853e44974df64bbdfb0 Mon Sep 17 00:00:00 2001 From: reionwong Date: Sun, 20 Jun 2021 16:35:42 +0800 Subject: [PATCH] Add CIconTheme class --- CMakeLists.txt | 1 + src/about.cpp | 19 +++++++++++++ src/about.h | 19 +++++++++++++ src/battery.cpp | 19 +++++++++++++ src/battery.h | 19 +++++++++++++ src/batteryhistorymodel.cpp | 20 +++++++++++++ src/batteryhistorymodel.h | 20 +++++++++++++ src/cicontheme.cpp | 57 +++++++++++++++++++++++++++++++++++++ src/cicontheme.h | 35 +++++++++++++++++++++++ src/language.cpp | 21 +++++++++++++- src/language.h | 19 +++++++++++++ 11 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 src/cicontheme.cpp create mode 100644 src/cicontheme.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f1c682d..8267230 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ set(SRCS src/background.cpp src/password.cpp src/batteryhistorymodel.cpp + src/cicontheme.cpp ) set(RESOURCES diff --git a/src/about.cpp b/src/about.cpp index be0ebf8..5b25257 100644 --- a/src/about.cpp +++ b/src/about.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "about.h" #include diff --git a/src/about.h b/src/about.h index 62e87b5..9299d2e 100644 --- a/src/about.h +++ b/src/about.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef ABOUT_H #define ABOUT_H diff --git a/src/battery.cpp b/src/battery.cpp index b6412ca..7801bbb 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "battery.h" #include #include diff --git a/src/battery.h b/src/battery.h index 720623d..087d238 100644 --- a/src/battery.h +++ b/src/battery.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef BATTERY_H #define BATTERY_H diff --git a/src/batteryhistorymodel.cpp b/src/batteryhistorymodel.cpp index 4089a5e..d9fc62d 100644 --- a/src/batteryhistorymodel.cpp +++ b/src/batteryhistorymodel.cpp @@ -1,3 +1,23 @@ +/*************************************************************************** + * Copyright (C) 2021 Reion Wong * + * Copyright (C) 2015 Kai Uwe Broulik * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + #include "batteryhistorymodel.h" #include diff --git a/src/batteryhistorymodel.h b/src/batteryhistorymodel.h index 94233b4..ea2d850 100644 --- a/src/batteryhistorymodel.h +++ b/src/batteryhistorymodel.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * Copyright (C) 2021 Reion Wong * + * Copyright (C) 2015 Kai Uwe Broulik * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + #ifndef BATTERYHISTORYMODEL_H #define BATTERYHISTORYMODEL_H diff --git a/src/cicontheme.cpp b/src/cicontheme.cpp new file mode 100644 index 0000000..c9d9e64 --- /dev/null +++ b/src/cicontheme.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cicontheme.h" +#include +#include +#include + +CIconTheme::CIconTheme(QObject *parent) + : QObject(parent) +{ + +} + +QStringList CIconTheme::list() +{ + QStringList list; + QStringList iconsPath; + iconsPath += QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("icons"), QStandardPaths::LocateDirectory); + iconsPath += QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("pixmaps"), QStandardPaths::LocateDirectory); + + for (const QString &path : qAsConst(iconsPath)) { + QDir dir(path); + QStringList dirList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + for (const QString &dir : dirList) { + const QString &itemPath = path + "/" + dir; + if (itemPath.startsWith("default.")) { + continue; + } + + if (!QFileInfo::exists(itemPath + "/index.desktop") && + !QFileInfo::exists(itemPath + "/index.theme")) { + continue; + } + + list.append(path + "/" + dir); + } + } + + return list; +} diff --git a/src/cicontheme.h b/src/cicontheme.h new file mode 100644 index 0000000..785a192 --- /dev/null +++ b/src/cicontheme.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CICONTHEME_H +#define CICONTHEME_H + +#include + +class CIconTheme : public QObject +{ + Q_OBJECT + +public: + explicit CIconTheme(QObject *parent = nullptr); + + static QStringList list(); +}; + +#endif // CICONTHEME_H diff --git a/src/language.cpp b/src/language.cpp index 7ec54d2..5b673b9 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -1,4 +1,23 @@ -#include "language.h" +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "language.h" #include #include #include diff --git a/src/language.h b/src/language.h index cc588a2..0f54b36 100644 --- a/src/language.h +++ b/src/language.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef LOCALE_H #define LOCALE_H