File indexing completed on 2024-12-01 11:10:29
0001 /* 0002 SPDX-FileCopyrightText: 2021 Michail Vourlakos <mvourlakos@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef ACTIONSHANDLER_H 0007 #define ACTIONSHANDLER_H 0008 0009 // local 0010 #include "actionlistwidgetitem.h" 0011 #include "../generic/generichandler.h" 0012 #include "../../data/generictable.h" 0013 0014 // Qt 0015 #include <QHash> 0016 #include <QObject> 0017 0018 namespace Ui { 0019 class ActionsDialog; 0020 } 0021 0022 namespace Latte{ 0023 namespace Settings{ 0024 namespace Dialog{ 0025 class ActionsDialog; 0026 } 0027 } 0028 } 0029 0030 0031 namespace Latte { 0032 namespace Settings { 0033 namespace Handler { 0034 0035 //! Handlers are objects to handle the UI elements that semantically associate with specific 0036 //! ui::tabs or different windows. They are responsible also to handle the user interaction 0037 //! between controllers and views 0038 0039 class ActionsHandler : public Generic 0040 { 0041 Q_OBJECT 0042 public: 0043 ActionsHandler(Dialog::ActionsDialog *dialog); 0044 ~ActionsHandler(); 0045 0046 bool hasChangedData() const override; 0047 bool inDefaultValues() const override; 0048 0049 QStringList currentAlwaysData() const; 0050 0051 public slots: 0052 void reset() override; 0053 void resetDefaults() override; 0054 void save() override; 0055 void updateButtonEnablement(); 0056 0057 void onCancel(); 0058 0059 private: 0060 void init(); 0061 void initItems(); 0062 0063 void loadItems(const QStringList &alwaysActions); 0064 0065 Data::GenericTable<Data::Generic> table(const QStringList &ids); 0066 0067 private: 0068 QStringList o_alwaysActions; 0069 0070 QHash<QString, Settings::ActionsDialog::ActionListWidgetItem *> m_items; 0071 0072 Dialog::ActionsDialog *m_dialog{nullptr}; 0073 Ui::ActionsDialog *m_ui{nullptr}; 0074 }; 0075 0076 } 0077 } 0078 } 0079 0080 #endif