File indexing completed on 2025-03-09 04:23:06
0001 /* 0002 * Copyright (C) 2016 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 #ifndef PERUSECONFIG_H 0023 #define PERUSECONFIG_H 0024 0025 #include <QObject> 0026 /** 0027 * \brief Class to handle reading and writing the configuration. 0028 * 0029 * Peruse will store the data in 'peruserc' at the QStandardPath 0030 * for configuration. 0031 */ 0032 class PeruseConfig : public QObject 0033 { 0034 Q_OBJECT 0035 Q_ENUMS(ZoomMode) 0036 /** 0037 * \brief recently opened represents the recently opened books. 0038 */ 0039 Q_PROPERTY(QStringList recentlyOpened READ recentlyOpened NOTIFY recentlyOpenedChanged) 0040 /** 0041 * \brief book locations is where Peruse will look for books, whether they have been removed, added, etc. 0042 */ 0043 Q_PROPERTY(QStringList bookLocations READ bookLocations NOTIFY bookLocationsChanged) 0044 0045 /** 0046 * \brief boolean representing whether or not we should animate jumps on the page 0047 */ 0048 Q_PROPERTY(bool animateJumpAreas READ animateJumpAreas WRITE setAnimateJumpAreas NOTIFY animateJumpAreasChanged) 0049 public: 0050 /** 0051 * \brief Enum holding the preferred zoom mode. 0052 */ 0053 enum ZoomMode { 0054 ZoomFull = 0, 0055 ZoomFitWidth = 1, 0056 ZoomFitHeight = 2 0057 }; 0058 0059 explicit PeruseConfig(QObject* parent = nullptr); 0060 ~PeruseConfig() override; 0061 0062 /** 0063 * \brief Add a book to the recently opened list. 0064 * @param path the path/filename of the newly opened book. 0065 */ 0066 Q_INVOKABLE void bookOpened(QString path); 0067 /** 0068 * @return a list of recently opened files. 0069 */ 0070 QStringList recentlyOpened() const; 0071 /** 0072 * \brief Fires when the list of recently opened files has changed. 0073 */ 0074 Q_SIGNAL void recentlyOpenedChanged(); 0075 0076 /** 0077 * \brief Add a folder to the book locations. 0078 * @param location path to the folder to add. 0079 */ 0080 Q_INVOKABLE void addBookLocation(const QString& location); 0081 /** 0082 * \brief Remove a folder from the book locations. 0083 * @param location path of the folder to remove. 0084 */ 0085 Q_INVOKABLE void removeBookLocation(const QString& location); 0086 /** 0087 * @return a QStringList with paths to all the folders to check for books. 0088 */ 0089 QStringList bookLocations() const; 0090 /** 0091 * \brief Fires when the book locations to check have changed. 0092 */ 0093 Q_SIGNAL void bookLocationsChanged(); 0094 0095 /** 0096 * @return a boolean representing value of animateJumpAreas property 0097 */ 0098 bool animateJumpAreas() const; 0099 0100 /** 0101 * \biref sets the animateJumpAreas property value to the passed parameter 0102 * @param animate the new value for animateJumpAreas property 0103 */ 0104 void setAnimateJumpAreas(bool animate); 0105 0106 /** 0107 * \biref Fires when the animateJumpAreas property gets changed 0108 */ 0109 Q_SIGNAL void animateJumpAreasChanged(); 0110 0111 /** 0112 * \brief Fires when there is an config error message to show. 0113 * @param message The Error message to show. 0114 */ 0115 Q_SIGNAL void showMessage(QString message); 0116 0117 // This should go somewhere more sensible, really... like a static on Qt. or something :P 0118 Q_INVOKABLE QString homeDir() const; 0119 /** 0120 * Creates a KFileMetaData::UserMetaData for this file, property and value so the information is not lost when files are moved around outside of Peruse 0121 */ 0122 Q_INVOKABLE void setFilesystemProperty(QString fileName, QString propertyName, QString value); 0123 /** 0124 * @brief getFilesystemProperty 0125 * @param fileName file name of the file to get data from. 0126 * @param propertyName value of the proper to get data from. 0127 * @return the value of the property. 0128 */ 0129 Q_INVOKABLE QString getFilesystemProperty(QString fileName, QString propertyName); 0130 0131 /** 0132 * Convenience function which simply forwards the information from 0133 * QImageReader::supportedImageFormats() in a QML-friendly format. 0134 * @return A list of image formats by short name - see the documentation for QImageReader::supportedImageFormats() for further details 0135 */ 0136 Q_INVOKABLE QStringList supportedImageFormats() const; 0137 private: 0138 class Private; 0139 Private* d; 0140 }; 0141 0142 #endif//PERUSECONFIG_H