forked from githubuser0xFFFF/Qt-Advanced-Docking-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue githubuser0xFFFF#380 and add example
- Loading branch information
Showing
10 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(ads_example_hideshow VERSION ${VERSION_SHORT}) | ||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) | ||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED) | ||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
add_executable(HideShowExample WIN32 | ||
main.cpp | ||
MainWindow.cpp | ||
MainWindow.ui | ||
) | ||
target_include_directories(HideShowExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src") | ||
target_link_libraries(HideShowExample PRIVATE qtadvanceddocking) | ||
target_link_libraries(HideShowExample PUBLIC Qt${QT_VERSION_MAJOR}::Core | ||
Qt${QT_VERSION_MAJOR}::Gui | ||
Qt${QT_VERSION_MAJOR}::Widgets) | ||
set_target_properties(HideShowExample PROPERTIES | ||
AUTOMOC ON | ||
AUTORCC ON | ||
AUTOUIC ON | ||
CXX_STANDARD 14 | ||
CXX_STANDARD_REQUIRED ON | ||
CXX_EXTENSIONS OFF | ||
VERSION ${VERSION_SHORT} | ||
EXPORT_NAME "Qt Advanced Docking System Hide,Show Example" | ||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib" | ||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib" | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "../../examples/hideshow/MainWindow.h" | ||
|
||
#include "ui_MainWindow.h" | ||
|
||
#include <QLabel> | ||
#include <QPushButton> | ||
|
||
MainWindow::MainWindow(QWidget *parent) : | ||
QMainWindow(parent), | ||
ui(new Ui::MainWindow) | ||
{ | ||
ui->setupUi(this); | ||
|
||
ui->centralWidget->setLayout( m_layout = new QStackedLayout() ); | ||
|
||
m_welcomeWidget = new QWidget(this); | ||
auto welcomeLayout = new QVBoxLayout(m_welcomeWidget); | ||
welcomeLayout->addStretch(); | ||
QPushButton* openButton = new QPushButton("Open project"); | ||
welcomeLayout->addWidget( openButton ); | ||
welcomeLayout->addStretch(); | ||
|
||
connect( openButton, SIGNAL(clicked()), this, SLOT(openProject()) ); | ||
|
||
m_DockManager = new ads::CDockManager(ui->centralWidget); | ||
|
||
// 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()); | ||
|
||
connect( ui->actionOpen, SIGNAL(triggered()), this, SLOT(openProject()) ); | ||
connect( ui->actionClose, SIGNAL(triggered()), this, SLOT(closeProject()) ); | ||
|
||
// Add the dock widget to the top dock widget area | ||
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget); | ||
|
||
ui->centralWidget->layout()->addWidget( m_welcomeWidget ); | ||
ui->centralWidget->layout()->addWidget( m_DockManager ); | ||
|
||
closeProject(); | ||
} | ||
|
||
MainWindow::~MainWindow() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void MainWindow::openProject() | ||
{ | ||
ui->actionOpen->setEnabled(false); | ||
ui->actionClose->setEnabled(true); | ||
ui->menuView->setEnabled(true); | ||
|
||
m_layout->setCurrentWidget( m_DockManager ); | ||
} | ||
|
||
void MainWindow::closeProject() | ||
{ | ||
ui->actionOpen->setEnabled(true); | ||
ui->actionClose->setEnabled(false); | ||
ui->menuView->setEnabled(false); | ||
|
||
m_DockManager->hideManagerAndFloatingWidgets(); | ||
m_layout->setCurrentWidget( m_welcomeWidget ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef MAINWINDOW_H | ||
#define MAINWINDOW_H | ||
|
||
#include <QMainWindow> | ||
#include <QStackedLayout> | ||
#include "DockManager.h" | ||
|
||
QT_BEGIN_NAMESPACE | ||
namespace Ui { | ||
class MainWindow; | ||
} | ||
QT_END_NAMESPACE | ||
|
||
class MainWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit MainWindow(QWidget *parent = 0); | ||
~MainWindow(); | ||
|
||
private slots: | ||
void openProject(); | ||
void closeProject(); | ||
|
||
private: | ||
Ui::MainWindow *ui; | ||
QWidget* m_welcomeWidget; | ||
ads::CDockManager* m_DockManager; | ||
QStackedLayout* m_layout; | ||
}; | ||
|
||
#endif // MAINWINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QMainWindow" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralWidget"/> | ||
<widget class="QMenuBar" name="menuBar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>26</height> | ||
</rect> | ||
</property> | ||
<widget class="QMenu" name="menuView"> | ||
<property name="title"> | ||
<string>View</string> | ||
</property> | ||
</widget> | ||
<widget class="QMenu" name="menuFile"> | ||
<property name="title"> | ||
<string>File</string> | ||
</property> | ||
<addaction name="actionOpen"/> | ||
<addaction name="actionClose"/> | ||
</widget> | ||
<addaction name="menuFile"/> | ||
<addaction name="menuView"/> | ||
</widget> | ||
<widget class="QStatusBar" name="statusBar"/> | ||
<action name="actionOpen"> | ||
<property name="text"> | ||
<string>Open project</string> | ||
</property> | ||
</action> | ||
<action name="actionClose"> | ||
<property name="text"> | ||
<string>Close project</string> | ||
</property> | ||
</action> | ||
</widget> | ||
<layoutdefault spacing="6" margin="11"/> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
ADS_OUT_ROOT = $${OUT_PWD}/../.. | ||
|
||
QT += core gui widgets | ||
|
||
TARGET = HideShowExample | ||
DESTDIR = $${ADS_OUT_ROOT}/lib | ||
TEMPLATE = app | ||
CONFIG += c++14 | ||
CONFIG += debug_and_release | ||
adsBuildStatic { | ||
DEFINES += ADS_STATIC | ||
} | ||
|
||
DEFINES += QT_DEPRECATED_WARNINGS | ||
|
||
SOURCES += \ | ||
main.cpp \ | ||
MainWindow.cpp | ||
|
||
HEADERS += \ | ||
MainWindow.h | ||
|
||
FORMS += \ | ||
MainWindow.ui | ||
|
||
|
||
LIBS += -L$${ADS_OUT_ROOT}/lib | ||
include(../../ads.pri) | ||
INCLUDEPATH += ../../src | ||
DEPENDPATH += ../../src | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <QApplication> | ||
#include "../../examples/hideshow/MainWindow.h" | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
MainWindow w; | ||
w.show(); | ||
|
||
return a.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters