mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-03-31 10:22:39 +08:00
Implemented status dialog in demo application to test several CDockWidget functions
This commit is contained in:
parent
277d3fffe4
commit
6a815a836c
@ -74,6 +74,7 @@
|
|||||||
#include "DockAreaTabBar.h"
|
#include "DockAreaTabBar.h"
|
||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
#include "DockComponentsFactory.h"
|
#include "DockComponentsFactory.h"
|
||||||
|
#include "StatusDialog.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -466,6 +467,11 @@ void MainWindowPrivate::createActions()
|
|||||||
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
||||||
_this->connect(a, SIGNAL(triggered()), SLOT(createTable()));
|
_this->connect(a, SIGNAL(triggered()), SLOT(createTable()));
|
||||||
ui.menuTests->addAction(a);
|
ui.menuTests->addAction(a);
|
||||||
|
|
||||||
|
ui.menuTests->addSeparator();
|
||||||
|
a = ui.menuTests->addAction("Show Status Dialog");
|
||||||
|
_this->connect(a, SIGNAL(triggered()), SLOT(showStatusDialog()));
|
||||||
|
ui.menuTests->addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -690,3 +696,11 @@ void CMainWindow::createTable()
|
|||||||
FloatingWidget->move(QPoint(40, 40));
|
FloatingWidget->move(QPoint(40, 40));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CMainWindow::showStatusDialog()
|
||||||
|
{
|
||||||
|
CStatusDialog Dialog(d->DockManager);
|
||||||
|
Dialog.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ private slots:
|
|||||||
void createEditor();
|
void createEditor();
|
||||||
void createTable();
|
void createTable();
|
||||||
void onEditorCloseRequested();
|
void onEditorCloseRequested();
|
||||||
|
void showStatusDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
88
demo/StatusDialog.cpp
Normal file
88
demo/StatusDialog.cpp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
//============================================================================
|
||||||
|
/// \file StatusDialog.cpp
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 13.04.2020
|
||||||
|
/// \brief Implementation of CStatusDialog class
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include "StatusDialog.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "DockManager.h"
|
||||||
|
#include "DockWidget.h"
|
||||||
|
#include "ui_StatusDialog.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data class of CStatusDialog class (pimpl)
|
||||||
|
*/
|
||||||
|
struct StatusDialogPrivate
|
||||||
|
{
|
||||||
|
CStatusDialog *_this;
|
||||||
|
Ui::CStatusDialogClass ui;
|
||||||
|
ads::CDockManager* DockManager;
|
||||||
|
QMap<QString, ads::CDockWidget*> DockWidgets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data constructor
|
||||||
|
*/
|
||||||
|
StatusDialogPrivate(CStatusDialog *_public);
|
||||||
|
};
|
||||||
|
// struct StatusDialogPrivate
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
StatusDialogPrivate::StatusDialogPrivate(CStatusDialog *_public) :
|
||||||
|
_this(_public)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CStatusDialog::CStatusDialog(ads::CDockManager* DockManager) :
|
||||||
|
QDialog(DockManager),
|
||||||
|
d(new StatusDialogPrivate(this))
|
||||||
|
{
|
||||||
|
d->ui.setupUi(this);
|
||||||
|
d->DockManager = DockManager;
|
||||||
|
d->DockWidgets = DockManager->dockWidgetsMap();
|
||||||
|
|
||||||
|
for (auto it = d->DockWidgets.begin(); it != d->DockWidgets.end(); ++it)
|
||||||
|
{
|
||||||
|
QVariant vDockWidget = QVariant::fromValue(it.value());
|
||||||
|
d->ui.dockWidgetsComboBox->addItem(it.key(), vDockWidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CStatusDialog::~CStatusDialog()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CStatusDialog::on_dockWidgetsComboBox_currentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto vDockWidget = d->ui.dockWidgetsComboBox->currentData();
|
||||||
|
auto DockWidget = vDockWidget.value<ads::CDockWidget*>();
|
||||||
|
d->ui.isClosedCheckBox->setChecked(DockWidget->isClosed());
|
||||||
|
d->ui.isFloatingCheckBox->setChecked(DockWidget->isFloating());
|
||||||
|
d->ui.tabbedCheckBox->setChecked(DockWidget->isTabbed());
|
||||||
|
d->ui.isCurrentTabCheckBox->setChecked(DockWidget->isCurrentTab());
|
||||||
|
d->ui.closableCheckBox->setChecked(DockWidget->features().testFlag(ads::CDockWidget::DockWidgetClosable));
|
||||||
|
d->ui.movableCheckBox->setChecked(DockWidget->features().testFlag(ads::CDockWidget::DockWidgetMovable));
|
||||||
|
d->ui.floatableCheckBox->setChecked(DockWidget->features().testFlag(ads::CDockWidget::DockWidgetFloatable));
|
||||||
|
d->ui.deleteOnCloseCheckBox->setChecked(DockWidget->features().testFlag(ads::CDockWidget::DockWidgetDeleteOnClose));
|
||||||
|
d->ui.customCloseHandlingCheckBox->setChecked(DockWidget->features().testFlag(ads::CDockWidget::CustomCloseHandling));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// EOF StatusDialog.cpp
|
47
demo/StatusDialog.h
Normal file
47
demo/StatusDialog.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef StatusDialogH
|
||||||
|
#define StatusDialogH
|
||||||
|
//============================================================================
|
||||||
|
/// \file StatusDialog.h
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 13.04.2020
|
||||||
|
/// \brief Declaration of CStatusDialog class
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace ads {class CDockManager;}
|
||||||
|
struct StatusDialogPrivate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays status info about dock widgets
|
||||||
|
*/
|
||||||
|
class CStatusDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
StatusDialogPrivate* d; ///< private data (pimpl)
|
||||||
|
friend class StatusDialogPrivate;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_dockWidgetsComboBox_currentIndexChanged(int index);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
public:
|
||||||
|
using Super = QDialog;
|
||||||
|
/**
|
||||||
|
* Default Constructor
|
||||||
|
*/
|
||||||
|
CStatusDialog(ads::CDockManager* parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual Destructor
|
||||||
|
*/
|
||||||
|
virtual ~CStatusDialog();
|
||||||
|
}; // class StatusDialog
|
||||||
|
|
||||||
|
// namespace namespace_name
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#endif // StatusDialogH
|
146
demo/StatusDialog.ui
Normal file
146
demo/StatusDialog.ui
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CStatusDialogClass</class>
|
||||||
|
<widget class="QDialog" name="CStatusDialogClass">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>357</width>
|
||||||
|
<height>331</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dock Widget Status</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetFixedSize</enum>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="dockWidgetLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Dock Widget:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="dockWidgetsComboBox">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>300</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="statusGroupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Status</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="isClosedCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>closed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="isFloatingCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>floating</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="tabbedCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>tabbed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="isCurrentTabCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>is current tab</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="flagsGroupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Feature Flags</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="closableCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>DockWidgetClosable</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="movableCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>DockWidgetMovable</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="floatableCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>DockWidgetFloatable</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="deleteOnCloseCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>DockWidgetDeleteOnClose</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="customCloseHandlingCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>CustomCloseHandling</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -18,13 +18,16 @@ adsBuildStatic {
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
MainWindow.cpp
|
MainWindow.cpp \
|
||||||
|
StatusDialog.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
MainWindow.h
|
MainWindow.h \
|
||||||
|
StatusDialog.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui \
|
||||||
|
StatusDialog.ui
|
||||||
|
|
||||||
RESOURCES += demo.qrc
|
RESOURCES += demo.qrc
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionExit"/>
|
|
||||||
<addaction name="actionSaveState"/>
|
<addaction name="actionSaveState"/>
|
||||||
<addaction name="actionRestoreState"/>
|
<addaction name="actionRestoreState"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user