File indexing completed on 2024-05-05 04:47:05
0001 // Copyright 2018-2020 Camilo Higuita <milo.h@aol.com> 0002 // Copyright 2018-2020 Nitrux Latinoamericana S.C. 0003 // 0004 // SPDX-License-Identifier: GPL-3.0-or-later 0005 0006 /*** 0007 Pix Copyright (C) 2018 Camilo Higuita 0008 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 0009 This is free software, and you are welcome to redistribute it 0010 under certain conditions; type `show c' for details. 0011 0012 This program is free software: you can redistribute it and/or modify 0013 it under the terms of the GNU General Public License as published by 0014 the Free Software Foundation, either version 3 of the License, or 0015 (at your option) any later version. 0016 0017 This program is distributed in the hope that it will be useful, 0018 but WITHOUT ANY WARRANTY; without even the implied warranty of 0019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0020 GNU General Public License for more details. 0021 0022 You should have received a copy of the GNU General Public License 0023 along with this program. If not, see <http://www.gnu.org/licenses/>. 0024 ***/ 0025 0026 #pragma once 0027 #include <QString> 0028 #include <QUrl> 0029 #include <QVariantList> 0030 0031 class Gallery; 0032 class Pix : public QObject 0033 { 0034 Q_OBJECT 0035 Q_PROPERTY(QVariantList sourcesModel READ sourcesModel NOTIFY sourcesChanged FINAL) 0036 Q_PROPERTY(QStringList sources READ sources NOTIFY sourcesChanged FINAL) 0037 Q_PROPERTY(Gallery* allImagesModel READ allImagesModel CONSTANT FINAL) 0038 0039 public: 0040 static Pix *instance() 0041 { 0042 if(m_instance) 0043 { 0044 return m_instance; 0045 } 0046 0047 m_instance = new Pix(); 0048 return m_instance; 0049 } 0050 0051 Pix(const Pix &) = delete; 0052 Pix &operator=(const Pix &) = delete; 0053 Pix(Pix &&) = delete; 0054 Pix &operator=(Pix &&) = delete; 0055 0056 inline static const QStringList getSourcePaths(); 0057 inline static void saveSourcePath(QStringList const &); 0058 inline static void removeSourcePath(const QString &); 0059 static QUrl cameraPath(); 0060 static QUrl screenshotsPath(); 0061 0062 Gallery* allImagesModel(); 0063 0064 public Q_SLOTS: 0065 QVariantList sourcesModel() const; 0066 QStringList sources() const; 0067 0068 void addSources(const QStringList &); 0069 void removeSources(const QString &); 0070 0071 void openPics(const QList<QUrl> &); 0072 0073 /*File actions*/ 0074 static void showInFolder(const QStringList &); 0075 0076 private: 0077 explicit Pix(QObject * = nullptr); 0078 static Pix * m_instance; 0079 0080 mutable Gallery* m_allImagesModel; 0081 0082 Q_SIGNALS: 0083 void viewPics(QStringList pics); 0084 void sourcesChanged(); 0085 };