16#ifndef QGSDOCKABLEWIDGETHELPER_H
17#define QGSDOCKABLEWIDGETHELPER_H
34using namespace Qt::StringLiterals;
41class GUI_EXPORT QgsNonRejectableDialog :
public QDialog
45 explicit QgsNonRejectableDialog( QWidget *parent =
nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
46 void reject()
override;
59class GUI_EXPORT QgsDockableWidgetHelper :
public QObject
63 static const QgsSettingsEntryBool *sSettingsIsDocked
SIP_SKIP;
64 static const QgsSettingsEntryVariant *sSettingsDockGeometry
SIP_SKIP;
65 static const QgsSettingsEntryVariant *sSettingsDialogGeometry
SIP_SKIP;
66 static const QgsSettingsEntryEnumFlag<Qt::DockWidgetArea> *sSettingsDockArea
SIP_SKIP;
70 enum class Option :
int
73 PermanentWidget = 1 << 2,
76 Q_DECLARE_FLAGS( Options, Option )
87 QgsDockableWidgetHelper(
88 const QString &windowTitle,
90 QMainWindow *ownerWindow,
91 const QString &dockId,
92 const QStringList &tabifyWith = QStringList(),
94 bool defaultIsDocked =
false,
95 Qt::DockWidgetArea defaultDockArea = Qt::DockWidgetArea::RightDockWidgetArea,
96 Options options = Options()
99 ~QgsDockableWidgetHelper()
override;
105 bool isDocked()
const {
return mIsDocked; }
108 void writeXml( QDomElement &viewDom );
109 void readXml(
const QDomElement &viewDom );
112 void setWidget( QWidget *widget );
114 QWidget *widget() {
return mWidget; }
117 QgsDockWidget *dockWidget();
122 void setWindowTitle(
const QString &title );
124 QString windowTitle()
const {
return mWindowTitle; }
127 void setDockObjectName(
const QString &name );
129 QString dockObjectName()
const;
136 void setSettingKeyDockId(
const QString &
id );
142 bool isUserVisible()
const;
148 QToolButton *createDockUndockToolButton();
153 QAction *createDockUndockAction(
const QString &title, QWidget *parent );
155 bool eventFilter( QObject *watched, QEvent *event )
override;
157 static std::function<QString()> sAppStylesheetFunction;
159 static QMainWindow *sOwnerWindow;
164 void dockModeToggled(
bool docked );
166 void visibilityChanged(
bool isVisible );
169 void toggleDockMode(
bool docked );
171 void setUserVisible(
bool visible );
184 void setupDockWidget(
const QStringList &tabSiblings = QStringList() );
186 bool mIsDocked =
true;
187 QWidget *mWidget =
nullptr;
189 QPointer<QDialog> mDialog;
190 QRect mDialogGeometry;
192 QPointer<QgsDockWidget> mDock;
194 bool mIsDockFloating =
true;
195 Qt::DockWidgetArea mDockArea = Qt::RightDockWidgetArea;
197 QString mWindowTitle;
199 QMainWindow *mOwnerWindow =
nullptr;
201 QStringList mTabifyWith;
207 QString mSettingKeyDockId;
209 friend class TestQgsDockableWidgetHelper;
DockableWidgetInitialState
Dockable widget initial states.
@ RestorePreviousState
Restore the previous state of this dock.
static QgsSettingsTreeNode * sTtreeWidgetGeometry
QgsSettingsTreeNamedListNode * createNamedListNode(const QString &key, const Qgis::SettingsTreeNodeOptions &options=Qgis::SettingsTreeNodeOptions())
Creates a named list tree node.