File indexing completed on 2024-05-12 05:13:29

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include <QWidget>
0009 
0010 namespace GrantleeThemeEditor
0011 {
0012 class ThemeEditorTabWidget;
0013 class ThemeSession;
0014 class DesktopFilePage;
0015 }
0016 class EditorPage;
0017 class KZip;
0018 
0019 class ContactEditorPage : public QWidget
0020 {
0021     Q_OBJECT
0022 public:
0023     explicit ContactEditorPage(const QString &projectDir, const QString &themeName, QWidget *parent = nullptr);
0024     ~ContactEditorPage() override;
0025 
0026     [[nodiscard]] bool saveTheme(bool withConfirmation = true);
0027     void loadTheme(const QString &filename);
0028 
0029     void addExtraPage();
0030 
0031     void uploadTheme();
0032     void installTheme(const QString &themePath);
0033 
0034     [[nodiscard]] bool themeWasChanged() const;
0035 
0036     void reloadConfig();
0037 
0038     void insertFile();
0039 
0040     void updatePreview();
0041 
0042     void saveThemeAs(const QString &directory);
0043 
0044 Q_SIGNALS:
0045     void changed(bool);
0046     void canInsertFile(bool);
0047 
0048 private:
0049     void slotUpdateViewer();
0050     void slotCloseTab(int);
0051     void slotChanged();
0052     void slotCurrentWidgetChanged(int);
0053 
0054 private:
0055     void setChanged(bool b);
0056     void storeTheme(const QString &directory = QString());
0057     [[nodiscard]] QString projectDirectory() const;
0058     void createZip(const QString &themeName, KZip *zip);
0059     EditorPage *createExtraPage(const QString &filename);
0060     EditorPage *createCustomPage(const QString &filename);
0061     QList<EditorPage *> mExtraPage;
0062 
0063     GrantleeThemeEditor::ThemeEditorTabWidget *mTabWidget = nullptr;
0064     EditorPage *mEditorPage = nullptr;
0065     EditorPage *mEditorGroupPage = nullptr;
0066     EditorPage *mEditorGroupEmbeddedPage = nullptr;
0067     EditorPage *mEditorEmbeddedPage = nullptr;
0068     GrantleeThemeEditor::DesktopFilePage *mDesktopPage = nullptr;
0069     GrantleeThemeEditor::ThemeSession *const mThemeSession;
0070     bool mChanged = false;
0071 };