2018-02-13 19:00:58 +08:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
** Qt Advanced Docking System
|
|
|
|
** Copyright (C) 2017 Uwe Kindler
|
|
|
|
**
|
|
|
|
** This library is free software; you can redistribute it and/or
|
|
|
|
** modify it under the terms of the GNU Lesser General Public
|
|
|
|
** License as published by the Free Software Foundation; either
|
|
|
|
** version 2.1 of the License, or (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This library is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
** Lesser General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU Lesser General Public
|
|
|
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
/// \file MainWindow.cpp
|
|
|
|
/// \author Uwe Kindler
|
|
|
|
/// \date 13.02.2018
|
|
|
|
/// \brief Implementation of CMainWindow demo class
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
|
|
|
#include <MainWindow.h>
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <QTime>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QCalendarWidget>
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QTreeView>
|
|
|
|
#include <QFileSystemModel>
|
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QWidgetAction>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QInputDialog>
|
2019-11-26 21:40:56 +08:00
|
|
|
#include <QRubberBand>
|
2019-12-10 21:44:44 +08:00
|
|
|
#include <QPlainTextEdit>
|
2019-12-11 22:50:13 +08:00
|
|
|
#include <QTableWidget>
|
2018-02-13 19:00:58 +08:00
|
|
|
|
|
|
|
#include <QMap>
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
|
|
|
|
#include "DockManager.h"
|
|
|
|
#include "DockWidget.h"
|
|
|
|
#include "DockAreaWidget.h"
|
2019-11-25 22:28:15 +08:00
|
|
|
#include "FloatingDockContainer.h"
|
2018-02-13 19:00:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
static ads::CDockWidget* createLongTextLabelDockWidget(QMenu* ViewMenu)
|
|
|
|
{
|
|
|
|
static int LabelCount = 0;
|
|
|
|
QLabel* l = new QLabel();
|
|
|
|
l->setWordWrap(true);
|
|
|
|
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
|
|
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.")
|
|
|
|
.arg(LabelCount)
|
|
|
|
.arg(QTime::currentTime().toString("hh:mm:ss:zzz")));
|
|
|
|
|
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Label %1").arg(LabelCount++));
|
|
|
|
DockWidget->setWidget(l);
|
|
|
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
|
|
|
return DockWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-11 21:12:39 +08:00
|
|
|
/**
|
|
|
|
* Function returns a features string with closable (c), movable (m) and floatable (f)
|
|
|
|
* features. i.e. The following string is for a not closable but movable and floatable
|
|
|
|
* widget: c- m+ f+
|
|
|
|
*/
|
|
|
|
static QString featuresString(ads::CDockWidget* DockWidget)
|
|
|
|
{
|
|
|
|
auto f = DockWidget->features();
|
|
|
|
return QString("c%1 m%2 f%3")
|
|
|
|
.arg(f.testFlag(ads::CDockWidget::DockWidgetClosable) ? "+" : "-")
|
|
|
|
.arg(f.testFlag(ads::CDockWidget::DockWidgetMovable) ? "+" : "-")
|
|
|
|
.arg(f.testFlag(ads::CDockWidget::DockWidgetFloatable) ? "+" : "-");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends the string returned by featuresString() to the window title of
|
|
|
|
* the given DockWidget
|
|
|
|
*/
|
|
|
|
static void appendFeaturStringToWindowTitle(ads::CDockWidget* DockWidget)
|
|
|
|
{
|
|
|
|
DockWidget->setWindowTitle(DockWidget->windowTitle()
|
|
|
|
+ QString(" (%1)").arg(featuresString(DockWidget)));
|
|
|
|
}
|
|
|
|
|
2019-12-10 21:44:44 +08:00
|
|
|
/**
|
|
|
|
* Helper function to create an SVG icon
|
|
|
|
*/
|
|
|
|
static QIcon svgIcon(const QString& File)
|
|
|
|
{
|
|
|
|
// This is a workaround, because because in item views SVG icons are not
|
|
|
|
// properly scaled an look blurry or pixelate
|
|
|
|
QIcon SvgIcon(File);
|
|
|
|
SvgIcon.addPixmap(SvgIcon.pixmap(92));
|
|
|
|
return SvgIcon;
|
|
|
|
}
|
|
|
|
|
2019-07-11 21:12:39 +08:00
|
|
|
|
2018-02-13 19:00:58 +08:00
|
|
|
//============================================================================
|
|
|
|
static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
|
|
|
|
{
|
|
|
|
static int CalendarCount = 0;
|
|
|
|
QCalendarWidget* w = new QCalendarWidget();
|
2018-11-08 17:04:29 +08:00
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++));
|
2018-02-13 19:00:58 +08:00
|
|
|
DockWidget->setWidget(w);
|
|
|
|
DockWidget->setToggleViewActionMode(ads::CDockWidget::ActionModeShow);
|
2019-12-10 21:44:44 +08:00
|
|
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/date_range.svg"));
|
2018-02-13 19:00:58 +08:00
|
|
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
|
|
|
return DockWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
static ads::CDockWidget* createFileSystemTreeDockWidget(QMenu* ViewMenu)
|
|
|
|
{
|
|
|
|
static int FileSystemCount = 0;
|
|
|
|
QTreeView* w = new QTreeView();
|
|
|
|
w->setFrameShape(QFrame::NoFrame);
|
|
|
|
QFileSystemModel* m = new QFileSystemModel(w);
|
|
|
|
m->setRootPath(QDir::currentPath());
|
|
|
|
w->setModel(m);
|
2019-07-11 21:12:39 +08:00
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1")
|
|
|
|
.arg(FileSystemCount++));
|
2018-02-13 19:00:58 +08:00
|
|
|
DockWidget->setWidget(w);
|
|
|
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
|
|
|
return DockWidget;
|
|
|
|
}
|
|
|
|
|
2019-12-11 22:50:13 +08:00
|
|
|
//============================================================================
|
|
|
|
static ads::CDockWidget* createEditorWidget(QMenu* ViewMenu)
|
|
|
|
{
|
|
|
|
static int EditorCount = 0;
|
|
|
|
QPlainTextEdit* w = new QPlainTextEdit();
|
|
|
|
w->setPlaceholderText("This is an editor. If you close the editor, it will be "
|
|
|
|
"deleted. Enter your text here.");
|
|
|
|
w->setStyleSheet("border: none");
|
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Editor %1").arg(EditorCount++));
|
|
|
|
DockWidget->setWidget(w);
|
|
|
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/edit.svg"));
|
|
|
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
|
|
|
return DockWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
static ads::CDockWidget* createTableWidget(QMenu* ViewMenu)
|
|
|
|
{
|
|
|
|
static int TableCount = 0;
|
|
|
|
QTableWidget* w = new QTableWidget();
|
|
|
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Table %1").arg(TableCount++));
|
|
|
|
static int colCount = 5;
|
|
|
|
static int rowCount = 30;
|
|
|
|
w->setColumnCount(colCount);
|
|
|
|
w->setRowCount(rowCount);
|
|
|
|
for (int col = 0; col < colCount; ++col)
|
|
|
|
{
|
|
|
|
w->setHorizontalHeaderItem(col, new QTableWidgetItem(QString("Col %1").arg(col+1)));
|
|
|
|
for (int row = 0; row < rowCount; ++row)
|
|
|
|
{
|
|
|
|
w->setItem(row, col, new QTableWidgetItem(QString("T %1-%2").arg(row + 1).arg(col+1)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DockWidget->setWidget(w);
|
|
|
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
|
|
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
|
|
|
return DockWidget;
|
|
|
|
}
|
|
|
|
|
2018-02-13 19:00:58 +08:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
/**
|
|
|
|
* Private data class pimpl
|
|
|
|
*/
|
|
|
|
struct MainWindowPrivate
|
|
|
|
{
|
|
|
|
CMainWindow* _this;
|
|
|
|
Ui::MainWindow ui;
|
2019-01-25 12:05:30 +08:00
|
|
|
QAction* SavePerspectiveAction = nullptr;
|
2018-02-13 19:00:58 +08:00
|
|
|
QWidgetAction* PerspectiveListAction = nullptr;
|
2019-01-25 12:05:30 +08:00
|
|
|
QComboBox* PerspectiveComboBox = nullptr;
|
2018-02-13 19:00:58 +08:00
|
|
|
ads::CDockManager* DockManager = nullptr;
|
|
|
|
|
|
|
|
MainWindowPrivate(CMainWindow* _public) : _this(_public) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the toolbar actions
|
|
|
|
*/
|
|
|
|
void createActions();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill the dock manager with dock widgets
|
|
|
|
*/
|
|
|
|
void createContent();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves the dock manager state and the main window geometry
|
|
|
|
*/
|
|
|
|
void saveState();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the list of perspectives
|
|
|
|
*/
|
|
|
|
void savePerspectives();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restores the dock manager state
|
|
|
|
*/
|
|
|
|
void restoreState();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore the perspective listo of the dock manager
|
|
|
|
*/
|
|
|
|
void restorePerspectives();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void MainWindowPrivate::createContent()
|
|
|
|
{
|
|
|
|
// Test container docking
|
|
|
|
QMenu* ViewMenu = ui.menuView;
|
|
|
|
auto DockWidget = createCalendarDockWidget(ViewMenu);
|
2018-08-24 19:41:58 +08:00
|
|
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
2018-02-13 19:00:58 +08:00
|
|
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
|
|
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
|
2018-11-01 05:13:34 +08:00
|
|
|
auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
2018-11-08 17:04:29 +08:00
|
|
|
auto ToolBar = FileSystemWidget->createDefaultToolBar();
|
2018-09-12 19:52:10 +08:00
|
|
|
ToolBar->addAction(ui.actionSaveState);
|
|
|
|
ToolBar->addAction(ui.actionRestoreState);
|
2018-11-01 05:13:34 +08:00
|
|
|
DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget);
|
2018-09-12 19:52:10 +08:00
|
|
|
|
2018-11-01 05:13:34 +08:00
|
|
|
FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
2018-11-08 17:04:29 +08:00
|
|
|
ToolBar = FileSystemWidget->createDefaultToolBar();
|
2018-09-12 19:52:10 +08:00
|
|
|
ToolBar->addAction(ui.actionSaveState);
|
|
|
|
ToolBar->addAction(ui.actionRestoreState);
|
2018-08-24 19:41:58 +08:00
|
|
|
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
|
2019-07-11 21:12:39 +08:00
|
|
|
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
|
|
|
appendFeaturStringToWindowTitle(FileSystemWidget);
|
2018-08-24 19:41:58 +08:00
|
|
|
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
|
2018-02-13 19:00:58 +08:00
|
|
|
DockWidget = createCalendarDockWidget(ViewMenu);
|
2018-08-24 19:41:58 +08:00
|
|
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
2019-01-25 12:05:30 +08:00
|
|
|
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
|
|
|
|
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
2018-02-13 19:00:58 +08:00
|
|
|
|
|
|
|
// Test dock area docking
|
|
|
|
auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), TopDockArea);
|
|
|
|
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
|
|
|
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
|
|
|
DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
2018-11-01 05:13:34 +08:00
|
|
|
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
2019-11-25 22:28:15 +08:00
|
|
|
|
2019-11-25 22:59:08 +08:00
|
|
|
auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle()));
|
|
|
|
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
|
|
|
|
|
2019-10-01 17:48:53 +08:00
|
|
|
for (auto DockWidget : DockManager->dockWidgetsMap())
|
|
|
|
{
|
|
|
|
_this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool)));
|
|
|
|
}
|
2018-02-13 19:00:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void MainWindowPrivate::createActions()
|
|
|
|
{
|
|
|
|
ui.toolBar->addAction(ui.actionSaveState);
|
2019-12-10 21:44:44 +08:00
|
|
|
ui.toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
|
ui.actionSaveState->setIcon(svgIcon(":/adsdemo/images/save.svg"));
|
2018-02-13 19:00:58 +08:00
|
|
|
ui.toolBar->addAction(ui.actionRestoreState);
|
2019-12-10 21:44:44 +08:00
|
|
|
ui.actionRestoreState->setIcon(svgIcon(":/adsdemo/images/restore.svg"));
|
2018-02-13 19:00:58 +08:00
|
|
|
|
2019-12-10 21:44:44 +08:00
|
|
|
SavePerspectiveAction = new QAction("Create Perspective", _this);
|
|
|
|
SavePerspectiveAction->setIcon(svgIcon(":/adsdemo/images/picture_in_picture.svg"));
|
2018-02-13 19:00:58 +08:00
|
|
|
_this->connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
|
|
|
|
PerspectiveListAction = new QWidgetAction(_this);
|
|
|
|
PerspectiveComboBox = new QComboBox(_this);
|
|
|
|
PerspectiveComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
PerspectiveComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
PerspectiveListAction->setDefaultWidget(PerspectiveComboBox);
|
|
|
|
ui.toolBar->addSeparator();
|
|
|
|
ui.toolBar->addAction(PerspectiveListAction);
|
|
|
|
ui.toolBar->addAction(SavePerspectiveAction);
|
2019-12-10 21:44:44 +08:00
|
|
|
|
|
|
|
QAction* a = ui.toolBar->addAction("Create Editor");
|
|
|
|
a->setToolTip("Creates floating dynamic dockable editor windows that are deleted on close");
|
|
|
|
a->setIcon(svgIcon(":/adsdemo/images/note_add.svg"));
|
|
|
|
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
|
2019-12-11 22:50:13 +08:00
|
|
|
|
|
|
|
a = ui.toolBar->addAction("Create Table");
|
|
|
|
a->setToolTip("Creates floating dynamic dockable table with millions of entries");
|
|
|
|
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
|
|
|
_this->connect(a, SIGNAL(triggered()), SLOT(createTable()));
|
2018-02-13 19:00:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void MainWindowPrivate::saveState()
|
|
|
|
{
|
|
|
|
QSettings Settings("Settings.ini", QSettings::IniFormat);
|
|
|
|
Settings.setValue("mainWindow/Geometry", _this->saveGeometry());
|
|
|
|
Settings.setValue("mainWindow/State", _this->saveState());
|
|
|
|
Settings.setValue("mainWindow/DockingState", DockManager->saveState());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void MainWindowPrivate::restoreState()
|
|
|
|
{
|
2018-10-11 20:15:27 +08:00
|
|
|
QSettings Settings("Settings.ini", QSettings::IniFormat);
|
2018-02-13 19:00:58 +08:00
|
|
|
_this->restoreGeometry(Settings.value("mainWindow/Geometry").toByteArray());
|
|
|
|
_this->restoreState(Settings.value("mainWindow/State").toByteArray());
|
2018-10-11 20:15:27 +08:00
|
|
|
DockManager->restoreState(Settings.value("mainWindow/DockingState").toByteArray());
|
2018-02-13 19:00:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void MainWindowPrivate::savePerspectives()
|
|
|
|
{
|
|
|
|
QSettings Settings("Settings.ini", QSettings::IniFormat);
|
|
|
|
DockManager->savePerspectives(Settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void MainWindowPrivate::restorePerspectives()
|
|
|
|
{
|
|
|
|
QSettings Settings("Settings.ini", QSettings::IniFormat);
|
|
|
|
DockManager->loadPerspectives(Settings);
|
|
|
|
PerspectiveComboBox->clear();
|
|
|
|
PerspectiveComboBox->addItems(DockManager->perspectiveNames());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
CMainWindow::CMainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
|
|
|
d(new MainWindowPrivate(this))
|
|
|
|
{
|
2018-11-08 19:57:25 +08:00
|
|
|
using namespace ads;
|
2018-02-13 19:00:58 +08:00
|
|
|
d->ui.setupUi(this);
|
|
|
|
d->createActions();
|
|
|
|
|
2019-09-13 03:15:35 +08:00
|
|
|
// uncomment the following line if the tab close button should be
|
|
|
|
// a QToolButton instead of a QPushButton
|
2019-09-13 20:19:43 +08:00
|
|
|
// CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton);
|
|
|
|
|
2019-11-28 20:22:59 +08:00
|
|
|
// uncomment the following line if you want a fixed tab width that does
|
2019-09-13 20:19:43 +08:00
|
|
|
// not change if the visibility of the close button changes
|
2019-11-28 20:22:59 +08:00
|
|
|
// CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true);
|
|
|
|
|
|
|
|
// uncomment the follwing line if you want to use non opaque undocking and splitter
|
|
|
|
// moevements
|
2019-12-16 18:45:18 +08:00
|
|
|
// CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
|
2019-09-13 03:15:35 +08:00
|
|
|
|
2018-02-13 19:00:58 +08:00
|
|
|
// Now create the dock manager and its content
|
2018-11-08 19:57:25 +08:00
|
|
|
d->DockManager = new CDockManager(this);
|
|
|
|
|
|
|
|
// Uncomment the following line to have the old style where the dock
|
|
|
|
// area close button closes the active tab
|
2019-09-13 20:19:43 +08:00
|
|
|
// CDockManager::setConfigFlags({CDockManager::DockAreaHasCloseButton
|
2019-09-13 03:24:48 +08:00
|
|
|
// | CDockManager::DockAreaCloseButtonClosesTab});
|
2018-02-13 19:00:58 +08:00
|
|
|
connect(d->PerspectiveComboBox, SIGNAL(activated(const QString&)),
|
|
|
|
d->DockManager, SLOT(openPerspective(const QString&)));
|
|
|
|
|
|
|
|
d->createContent();
|
|
|
|
// Default window geometry
|
2019-05-14 21:32:50 +08:00
|
|
|
resize(1280, 720);
|
2018-02-13 19:00:58 +08:00
|
|
|
|
2019-11-25 22:28:15 +08:00
|
|
|
//d->restoreState();
|
2018-02-13 19:00:58 +08:00
|
|
|
d->restorePerspectives();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
CMainWindow::~CMainWindow()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CMainWindow::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
|
|
|
d->saveState();
|
|
|
|
QMainWindow::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CMainWindow::on_actionSaveState_triggered(bool)
|
|
|
|
{
|
|
|
|
qDebug() << "MainWindow::on_actionSaveState_triggered";
|
|
|
|
d->saveState();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CMainWindow::on_actionRestoreState_triggered(bool)
|
|
|
|
{
|
|
|
|
qDebug() << "MainWindow::on_actionRestoreState_triggered";
|
|
|
|
d->restoreState();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CMainWindow::savePerspective()
|
|
|
|
{
|
|
|
|
QString PerspectiveName = QInputDialog::getText(this, "Save Perspective", "Enter unique name:");
|
|
|
|
if (PerspectiveName.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
d->DockManager->addPerspective(PerspectiveName);
|
|
|
|
QSignalBlocker Blocker(d->PerspectiveComboBox);
|
|
|
|
d->PerspectiveComboBox->clear();
|
|
|
|
d->PerspectiveComboBox->addItems(d->DockManager->perspectiveNames());
|
|
|
|
d->PerspectiveComboBox->setCurrentText(PerspectiveName);
|
|
|
|
|
|
|
|
d->savePerspectives();
|
|
|
|
}
|
|
|
|
|
2019-10-01 17:48:53 +08:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CMainWindow::onViewToggled(bool Open)
|
|
|
|
{
|
|
|
|
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
|
|
|
|
if (!DockWidget)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << DockWidget->objectName() << " viewToggled(" << Open << ")";
|
|
|
|
}
|
|
|
|
|
2019-12-10 21:44:44 +08:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CMainWindow::createEditor()
|
|
|
|
{
|
2019-12-11 22:50:13 +08:00
|
|
|
auto DockWidget = createEditorWidget(d->ui.menuView);
|
2019-12-10 21:44:44 +08:00
|
|
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
|
|
|
|
auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget);
|
|
|
|
FloatingWidget->move(QPoint(20, 20));
|
|
|
|
}
|
|
|
|
|
2019-12-11 22:50:13 +08:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CMainWindow::createTable()
|
|
|
|
{
|
|
|
|
auto DockWidget = createTableWidget(d->ui.menuView);
|
|
|
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
|
|
|
|
auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget);
|
|
|
|
FloatingWidget->move(QPoint(40, 40));
|
|
|
|
}
|
|
|
|
|