2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-04-16 22:04:48 +08:00
|
|
|
#ifndef SETTINGSWIDGET_H
|
|
|
|
#define SETTINGSWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
2021-04-18 11:25:40 +08:00
|
|
|
class QAbstractItemView;
|
2021-04-16 22:04:48 +08:00
|
|
|
class SettingsWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit SettingsWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
virtual void init();
|
|
|
|
|
|
|
|
void load();
|
|
|
|
void save();
|
|
|
|
signals:
|
2021-04-17 14:52:47 +08:00
|
|
|
void settingsChanged(bool changed);
|
2022-10-12 19:48:35 +08:00
|
|
|
public slots:
|
|
|
|
void onUpdateIcons();
|
2021-04-16 22:04:48 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void doLoad() = 0;
|
|
|
|
virtual void doSave() = 0;
|
2024-04-05 20:43:04 +08:00
|
|
|
virtual void onLoaded();
|
2021-04-18 11:25:40 +08:00
|
|
|
void connectAbstractItemView(QAbstractItemView* pView);
|
|
|
|
void disconnectAbstractItemView(QAbstractItemView* pView);
|
2022-10-12 19:48:35 +08:00
|
|
|
virtual void updateIcons(const QSize &size) ;
|
2021-04-16 22:04:48 +08:00
|
|
|
public:
|
|
|
|
const QString& group();
|
|
|
|
const QString& name();
|
2021-04-17 14:52:47 +08:00
|
|
|
bool isSettingsChanged();
|
2021-04-18 11:25:40 +08:00
|
|
|
void connectInputs();
|
|
|
|
void disconnectInputs();
|
2021-04-16 22:04:48 +08:00
|
|
|
public slots:
|
|
|
|
void setSettingsChanged();
|
|
|
|
void clearSettingsChanged();
|
2021-04-18 11:25:40 +08:00
|
|
|
private:
|
|
|
|
|
2021-04-16 22:04:48 +08:00
|
|
|
private:
|
|
|
|
bool mSettingsChanged;
|
|
|
|
QString mGroup;
|
|
|
|
QString mName;
|
2024-04-02 16:55:51 +08:00
|
|
|
|
|
|
|
// QWidget interface
|
|
|
|
protected:
|
|
|
|
void showEvent(QShowEvent *event) override;
|
2021-04-16 22:04:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SETTINGSWIDGET_H
|