2017-02-27 01:13:56 +08:00
|
|
|
#include "mainwindow.h"
|
2017-03-13 04:41:50 +08:00
|
|
|
|
2017-02-27 01:13:56 +08:00
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
2017-03-23 22:57:15 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
2017-02-27 01:13:56 +08:00
|
|
|
#include <QTime>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QCalendarWidget>
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QTreeView>
|
|
|
|
#include <QFileSystemModel>
|
|
|
|
#include <QBoxLayout>
|
2017-03-23 22:57:15 +08:00
|
|
|
#include <QSettings>
|
2017-03-24 23:17:55 +08:00
|
|
|
#include <QDockWidget>
|
2017-02-27 01:13:56 +08:00
|
|
|
|
|
|
|
#include "DockManager.h"
|
|
|
|
#include "DockWidget.h"
|
2017-02-27 21:15:20 +08:00
|
|
|
#include "DockAreaWidget.h"
|
2017-02-27 01:13:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static int CONTENT_COUNT = 0;
|
|
|
|
|
2017-03-28 18:01:27 +08:00
|
|
|
|
2017-03-12 04:38:31 +08:00
|
|
|
static ads::CDockWidget* createLongTextLabelDockWidget(QMenu* ViewMenu)
|
2017-02-27 01:13:56 +08:00
|
|
|
{
|
2017-02-27 21:15:20 +08:00
|
|
|
static int LabelCount = 0;
|
2017-02-27 01:13:56 +08:00
|
|
|
QLabel* l = new QLabel();
|
|
|
|
l->setWordWrap(true);
|
|
|
|
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
2017-03-28 18:01:27 +08:00
|
|
|
l->setText(QString("Label %1 %2 - Lorem ipsum dolor sit amet, consectetuer adipiscing elit. "
|
|
|
|
"Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque "
|
|
|
|
"penatibus et magnis dis parturient montes, nascetur ridiculus mus. "
|
|
|
|
"Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. "
|
|
|
|
"Nulla consequat massa quis enim. Donec pede justo, fringilla vel, "
|
|
|
|
"aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, "
|
|
|
|
"imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede "
|
|
|
|
"mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum "
|
|
|
|
"semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, "
|
|
|
|
"porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, "
|
|
|
|
"dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla "
|
|
|
|
"ut metus varius laoreet.")
|
2017-03-22 23:08:44 +08:00
|
|
|
.arg(LabelCount)
|
|
|
|
.arg(QTime::currentTime().toString("hh:mm:ss:zzz")));
|
2017-02-27 01:13:56 +08:00
|
|
|
|
2017-02-27 21:15:20 +08:00
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Label %1").arg(LabelCount++));
|
2017-02-27 01:13:56 +08:00
|
|
|
DockWidget->setWidget(l);
|
2017-03-23 22:57:15 +08:00
|
|
|
DockWidget->setObjectName(DockWidget->windowTitle());
|
2017-03-12 04:38:31 +08:00
|
|
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
2017-02-27 01:13:56 +08:00
|
|
|
return DockWidget;
|
|
|
|
}
|
|
|
|
|
2017-03-28 18:01:27 +08:00
|
|
|
|
2017-03-12 04:38:31 +08:00
|
|
|
static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
|
2017-02-27 01:13:56 +08:00
|
|
|
{
|
2017-02-27 21:15:20 +08:00
|
|
|
static int CalendarCount = 0;
|
2017-02-27 01:13:56 +08:00
|
|
|
QCalendarWidget* w = new QCalendarWidget();
|
2017-02-27 21:15:20 +08:00
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++));
|
2017-02-27 01:13:56 +08:00
|
|
|
DockWidget->setWidget(w);
|
2017-03-23 22:57:15 +08:00
|
|
|
DockWidget->setObjectName(DockWidget->windowTitle());
|
2017-03-12 04:38:31 +08:00
|
|
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
2017-02-27 01:13:56 +08:00
|
|
|
return DockWidget;
|
|
|
|
}
|
|
|
|
|
2017-03-12 04:38:31 +08:00
|
|
|
static ads::CDockWidget* createFileSystemTreeDockWidget(QMenu* ViewMenu)
|
2017-02-27 01:13:56 +08:00
|
|
|
{
|
2017-02-27 21:15:20 +08:00
|
|
|
static int FileSystemCount = 0;
|
2017-02-27 01:13:56 +08:00
|
|
|
QTreeView* w = new QTreeView();
|
|
|
|
w->setFrameShape(QFrame::NoFrame);
|
|
|
|
QFileSystemModel* m = new QFileSystemModel(w);
|
|
|
|
m->setRootPath(QDir::currentPath());
|
|
|
|
w->setModel(m);
|
2017-02-27 21:15:20 +08:00
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1").arg(FileSystemCount++));
|
2017-02-27 01:13:56 +08:00
|
|
|
DockWidget->setWidget(w);
|
2017-03-23 22:57:15 +08:00
|
|
|
DockWidget->setObjectName(DockWidget->windowTitle());
|
2017-03-12 04:38:31 +08:00
|
|
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
2017-02-27 01:13:56 +08:00
|
|
|
return DockWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
m_DockManager = new ads::CDockManager(this);
|
|
|
|
createContent();
|
|
|
|
// Default window geometry
|
|
|
|
resize(800, 600);
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::createContent()
|
|
|
|
{
|
2017-03-01 05:41:34 +08:00
|
|
|
// Test container docking
|
2017-03-12 04:38:31 +08:00
|
|
|
QMenu* ViewMenu = this->ui->menuView;
|
|
|
|
auto DockWidget = createCalendarDockWidget(ViewMenu);
|
2017-02-27 21:15:20 +08:00
|
|
|
DockWidget->setFeatures(DockWidget->features().setFlag(ads::CDockWidget::DockWidgetClosable, false));
|
|
|
|
m_DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
2017-03-12 04:38:31 +08:00
|
|
|
m_DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
|
2017-03-27 19:18:16 +08:00
|
|
|
m_DockManager->addDockWidget(ads::BottomDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu));
|
|
|
|
/*auto TopDockArea = m_DockManager->addDockWidget(ads::TopDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu));
|
2017-03-12 04:38:31 +08:00
|
|
|
DockWidget = createCalendarDockWidget(ViewMenu);
|
2017-02-28 22:23:02 +08:00
|
|
|
DockWidget->setFeatures(DockWidget->features().setFlag(ads::CDockWidget::DockWidgetClosable, false));
|
2017-03-01 05:41:34 +08:00
|
|
|
m_DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
|
|
|
|
|
|
|
// Test dock area docking
|
2017-03-12 04:38:31 +08:00
|
|
|
auto RighDockArea = m_DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), TopDockArea);
|
|
|
|
m_DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
|
|
|
auto BottomDockArea = m_DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
|
|
|
m_DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
2017-03-24 23:17:55 +08:00
|
|
|
m_DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);*/
|
2017-02-27 01:13:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-23 22:57:15 +08:00
|
|
|
void MainWindow::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
2017-03-24 23:17:55 +08:00
|
|
|
/*QSettings Settings("Settings.ini", QSettings::IniFormat);
|
2017-03-23 22:57:15 +08:00
|
|
|
Settings.setValue("mainWindow/Geometry", saveGeometry());
|
2017-03-24 23:17:55 +08:00
|
|
|
Settings.setValue("mainWindow/DockingState", m_DockManager->saveState());*/
|
2017-03-23 22:57:15 +08:00
|
|
|
QMainWindow::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionSaveState_triggered(bool)
|
|
|
|
{
|
|
|
|
std::cout << "MainWindow::on_actionSaveState_triggered" << std::endl;
|
|
|
|
QSettings Settings("Settings.ini", QSettings::IniFormat);
|
|
|
|
Settings.setValue("mainWindow/Geometry", saveGeometry());
|
|
|
|
Settings.setValue("mainWindow/DockingState", m_DockManager->saveState());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionRestoreState_triggered(bool)
|
|
|
|
{
|
|
|
|
std::cout << "MainWindow::on_actionRestoreState_triggered" << std::endl;
|
|
|
|
QSettings Settings("Settings.ini", QSettings::IniFormat);
|
|
|
|
restoreGeometry(Settings.value("mainWindow/Geometry").toByteArray());
|
|
|
|
m_DockManager->restoreState(Settings.value("mainWindow/DockingState").toByteArray());
|
|
|
|
}
|
|
|
|
|