DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dsettingswidgetfactory.h
1// SPDX-FileCopyrightText: 2016 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#pragma once
6
7#include <functional>
8
9#include <QObject>
10#include <QScopedPointer>
11
12#include <dtkwidget_global.h>
13
14DCORE_BEGIN_NAMESPACE
15class DSettingsOption;
16DCORE_END_NAMESPACE
17
18DWIDGET_BEGIN_NAMESPACE
19
20class DSettingsWidgetFactoryPrivate;
21class LIBDTKWIDGETSHARED_EXPORT DSettingsWidgetFactory : public QObject
22{
23 Q_OBJECT
24public:
25 typedef QWidget *(WidgetCreateHandler)(QObject *);
26 typedef QPair<QWidget*, QWidget*> (ItemCreateHandler)(QObject *);
27
28 explicit DSettingsWidgetFactory(QObject *parent = Q_NULLPTR);
30
31 void registerWidget(const QString &viewType, std::function<WidgetCreateHandler> handler);
32 void registerWidget(const QString &viewType, std::function<ItemCreateHandler> handler);
33
34 QWidget *createWidget(QPointer<DTK_CORE_NAMESPACE::DSettingsOption> option);
35 QWidget *createWidget(const QByteArray &translateContext, QPointer<DTK_CORE_NAMESPACE::DSettingsOption> option);
36 QPair<QWidget*, QWidget*> createItem(QPointer<DTK_CORE_NAMESPACE::DSettingsOption> option) const;
37 QPair<QWidget*, QWidget*> createItem(const QByteArray &translateContext, QPointer<DTK_CORE_NAMESPACE::DSettingsOption> option) const;
38#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
39 D_DECL_DEPRECATED static QWidget *createTwoColumWidget(DTK_CORE_NAMESPACE::DSettingsOption *option, QWidget *rightWidget);
40 D_DECL_DEPRECATED static QWidget *createTwoColumWidget(const QByteArray &translateContext, DTK_CORE_NAMESPACE::DSettingsOption *option, QWidget *rightWidget);
41#endif
42 static QPair<QWidget*, QWidget*> createStandardItem(const QByteArray &translateContext, DTK_CORE_NAMESPACE::DSettingsOption *option, QWidget *rightWidget);
43
44private:
45 QScopedPointer<DSettingsWidgetFactoryPrivate> dd_ptr;
46 Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), DSettingsWidgetFactory)
47};
48
49DWIDGET_END_NAMESPACE
DSettingsWidgetFactory是一个用于构造Deepin风格的设置对话框的控件.
Definition dsettingswidgetfactory.h:22
QWidget *() WidgetCreateHandler(QObject *)
自定义的控件构建函数,一般接受一个 Dtk::Core::DSettingsOption 作为参数.
Definition dsettingswidgetfactory.h:25