2020-05-13 22:05:00 +08:00
|
|
|
#include "MainWindow.h"
|
2020-05-07 20:39:02 +08:00
|
|
|
|
2018-12-20 16:15:02 +08:00
|
|
|
#include "ui_MainWindow.h"
|
|
|
|
|
|
|
|
#include <QLabel>
|
2020-05-07 20:39:02 +08:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QPlainTextEdit>
|
2018-12-20 16:15:02 +08:00
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
// Create the dock manager. Because the parent parameter is a QMainWindow
|
|
|
|
// the dock manager registers itself as the central widget.
|
2020-05-07 20:39:02 +08:00
|
|
|
QVBoxLayout* Layout = new QVBoxLayout(ui->dockContainer);
|
|
|
|
Layout->setContentsMargins(QMargins(0, 0, 0, 0));
|
|
|
|
m_DockManager = new ads::CDockManager(ui->dockContainer);
|
|
|
|
Layout->addWidget(m_DockManager);
|
2018-12-20 16:15:02 +08:00
|
|
|
|
|
|
|
// Create example content label - this can be any application specific
|
|
|
|
// widget
|
|
|
|
QLabel* l = new QLabel();
|
|
|
|
l->setWordWrap(true);
|
|
|
|
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
|
|
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
|
|
|
|
|
|
|
|
// Create a dock widget with the title Label 1 and set the created label
|
|
|
|
// as the dock widget content
|
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1");
|
|
|
|
DockWidget->setWidget(l);
|
|
|
|
|
|
|
|
// Add the toggleViewAction of the dock widget to the menu to give
|
|
|
|
// the user the possibility to show the dock widget if it has been closed
|
|
|
|
ui->menuView->addAction(DockWidget->toggleViewAction());
|
|
|
|
|
2020-05-07 20:39:02 +08:00
|
|
|
|
2018-12-20 16:15:02 +08:00
|
|
|
// Add the dock widget to the top dock widget area
|
|
|
|
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
|
2020-05-07 20:39:02 +08:00
|
|
|
|
|
|
|
// Create an example editor
|
|
|
|
QPlainTextEdit* te = new QPlainTextEdit();
|
|
|
|
te->setPlaceholderText("Please enter your text here into this QPlainTextEdit...");
|
|
|
|
DockWidget = new ads::CDockWidget("Editor 1");
|
|
|
|
ui->menuView->addAction(DockWidget->toggleViewAction());
|
|
|
|
m_DockManager->addDockWidget(ads::BottomDockWidgetArea, DockWidget);
|
2018-12-20 16:15:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2020-07-22 17:28:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
QMainWindow::closeEvent(event);
|
|
|
|
if (m_DockManager)
|
|
|
|
{
|
|
|
|
m_DockManager->deleteLater();
|
|
|
|
}
|
|
|
|
}
|