File indexing completed on 2024-04-21 05:30:59

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef SETTINGSTABLAYOUTSHANDLER_H
0007 #define SETTINGSTABLAYOUTSHANDLER_H
0008 
0009 //! local
0010 #include "../generic/generichandler.h"
0011 #include "../../data/layoutdata.h"
0012 
0013 //! Qt
0014 #include <QAction>
0015 #include <QButtonGroup>
0016 #include <QMenu>
0017 
0018 //!
0019 #include <KConfigGroup>
0020 
0021 namespace Ui {
0022 class SettingsDialog;
0023 }
0024 
0025 namespace Latte {
0026 class Corona;
0027 
0028 namespace Settings {
0029 namespace Controller {
0030 class Layouts;
0031 }
0032 
0033 namespace Dialog{
0034 class SettingsDialog;
0035 }
0036 
0037 }
0038 }
0039 
0040 namespace Latte {
0041 namespace Settings {
0042 namespace Handler {
0043 
0044 //! Handlers are objects to handle the UI elements that semantically associate with specific
0045 //! ui::tabs or different windows. They are responsible also to handle the user interaction
0046 //! between controllers and views
0047 
0048 class TabLayouts : public Generic
0049 {
0050     Q_OBJECT
0051 public:
0052     TabLayouts(Dialog::SettingsDialog *parent);
0053     ~TabLayouts();
0054 
0055     bool hasChangedData() const override;
0056     bool inDefaultValues() const override;
0057     bool isCurrentTab() const;
0058 
0059     bool isViewsDialogVisible() const;
0060 
0061     Latte::Corona *corona() const;
0062     Dialog::SettingsDialog *dialog() const;
0063     Ui::SettingsDialog *ui() const;
0064     Controller::Layouts *layoutsController() const;
0065 
0066 public slots:
0067     void onDragEnterEvent(QDragEnterEvent *event);
0068     void onDragLeaveEvent(QDragLeaveEvent *event);
0069     void onDragMoveEvent(QDragMoveEvent *event);
0070     void onDropEvent(QDropEvent *event);
0071 
0072     void showViewsDialog();
0073 
0074     void reset() override;
0075     void resetDefaults() override;
0076     void save() override;
0077 
0078 signals:
0079     void currentPageChanged();
0080 
0081 private slots:
0082     void initUi();
0083     void initLayoutMenu();
0084 
0085     void loadConfig();
0086     void saveConfig();
0087 
0088     void downloadLayout();
0089     void duplicateLayout();
0090     void switchLayout();
0091     void importLayout();
0092     void exportLayoutForBackup();
0093     void exportLayoutAsTemplate();
0094     void lockLayout();
0095     void removeLayout();
0096     void toggleActivitiesManager();
0097     void toggleEnabledLayout();
0098     void showDetailsDialog();
0099 
0100     void onCurrentPageChanged();
0101     void onLayoutFilesDropped(const QStringList &paths);
0102     void onRawLayoutDropped(const QString &rawLayout);
0103     void updatePerLayoutButtonsState();
0104 
0105     void newLayout(const QString &templateName);
0106 
0107 private:
0108     bool isHoveringLayoutsTable(const QPoint &pos);
0109 
0110     void initLayoutTemplatesSubMenu();
0111     void initImportLayoutSubMenu();
0112     void initExportLayoutSubMenu();
0113 
0114 private:
0115     Settings::Dialog::SettingsDialog *m_parentDialog{nullptr};
0116     Ui::SettingsDialog *m_ui{nullptr};
0117     Latte::Corona *m_corona{nullptr};
0118 
0119     Settings::Controller::Layouts *m_layoutsController{nullptr};
0120 
0121     KConfigGroup m_storage;
0122 
0123     bool m_isViewsDialogVisible{false};
0124 
0125     QButtonGroup *m_inMemoryButtons;
0126 
0127     //! Layout menu actions
0128     QMenu *m_layoutMenu{nullptr};
0129     QMenu *m_layoutTemplatesSubMenu{nullptr};
0130     QMenu *m_layoutImportSubMenu{nullptr};
0131     QMenu *m_layoutExportSubMenu{nullptr};
0132 
0133     QAction *m_switchLayoutAction{nullptr};
0134     QAction *m_activitiesManagerAction{nullptr};
0135     QAction *m_newLayoutAction{nullptr};
0136     QAction *m_duplicateLayoutAction{nullptr};
0137     QAction *m_enabledLayoutAction{nullptr};
0138     QAction *m_readOnlyLayoutAction{nullptr};
0139     QAction *m_removeLayoutAction{nullptr};
0140     QAction *m_importLayoutAction{nullptr};
0141     QAction *m_exportLayoutAction{nullptr};
0142     QAction *m_detailsAction{nullptr};
0143     QAction *m_viewsAction{nullptr};
0144 };
0145 
0146 }
0147 }
0148 }
0149 
0150 #endif