File indexing completed on 2024-05-19 04:58:35

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2014  David Rosca <nowrep@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #ifndef DATAPATHS_H
0019 #define DATAPATHS_H
0020 
0021 #include <QStringList>
0022 
0023 #include "qzcommon.h"
0024 
0025 class QTemporaryDir;
0026 
0027 class FALKON_EXPORT DataPaths
0028 {
0029 public:
0030     enum Path {
0031         AppData = 0,
0032         Themes,
0033         Plugins,
0034         Config,
0035         Profiles,
0036         CurrentProfile,
0037         Temp,
0038         Cache,
0039         Sessions,
0040         LastPath
0041     };
0042 
0043     explicit DataPaths();
0044     ~DataPaths();
0045 
0046     // Set absolute path of current profile
0047     static void setCurrentProfilePath(const QString &profilePath);
0048     // Set Config path to $AppData/data
0049     static void setPortableVersion();
0050 
0051     // Returns main path (Themes -> /usr/share/themes)
0052     static QString path(Path type);
0053     // Returns all paths (Themes -> /usr/share/themes, ~/.config/falkon/themes)
0054     static QStringList allPaths(Path type);
0055     // Returns full path of existing file
0056     static QString locate(Path type, const QString &file);
0057     // Convenience function for getting CurrentProfile
0058     static QString currentProfilePath();
0059 
0060 private:
0061     void init();
0062     void initCurrentProfile(const QString &profilePath);
0063     void initAssetsIn(const QString &path);
0064 
0065     QStringList m_paths[LastPath];
0066     QScopedPointer<QTemporaryDir> m_tmpdir;
0067 };
0068 
0069 #endif // DATAPATHS_H