Skip to content

Commit 7165969

Browse files
committed
Update ADS to v3.6.2
1 parent 0fbc681 commit 7165969

File tree

12 files changed

+141
-20
lines changed

12 files changed

+141
-20
lines changed

src/NotepadNext/NotepadNextApplication.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ bool NotepadNextApplication::initGui()
7373
{
7474
qInfo(Q_FUNC_INFO);
7575

76-
createNewWindow()->openFile("C:/pickles.txt");
77-
7876
luabridge::getGlobalNamespace(luaState->L)
7977
.beginNamespace("nn")
8078
.beginClass<QWidget>("QWidget")

src/ads/PyQtAds/_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def get_keywords():
2323
# setup.py/versioneer.py will grep for the variable names, so they must
2424
# each be defined on a line of their own. _version.py will just call
2525
# get_keywords().
26-
git_refnames = "$Format:%d$"
27-
git_full = "$Format:%H$"
28-
git_date = "$Format:%ci$"
26+
git_refnames = " (tag: 3.6.2)"
27+
git_full = "5fad43377b318daee42666e116d6d851d7d05f75"
28+
git_date = "2020-09-25 14:40:28 +0200"
2929
keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
3030
return keywords
3131

src/ads/demo/MainWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void appendFeaturStringToWindowTitle(ads::CDockWidget* DockWidget)
109109
static QIcon svgIcon(const QString& File)
110110
{
111111
// This is a workaround, because in item views SVG icons are not
112-
// properly scaled an look blurry or pixelate
112+
// properly scaled and look blurry or pixelate
113113
QIcon SvgIcon(File);
114114
SvgIcon.addPixmap(SvgIcon.pixmap(92));
115115
return SvgIcon;

src/ads/doc/user-guide.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ auto* CentralDockArea = DockManager->setCentralWidget(CentralDockWidget);
493493

494494
See the `centralwidget` example to learn how it works.
495495

496+
> ##### Note
497+
> The central widget needs to be the first dock widget that is added to the
498+
> dock manager. The function does not work and returns a `nullptr` if there
499+
> are already other dock widgets registered. So `setCentralWidget` should be
500+
> the first function that you call when adding dock widgets.
501+
502+
496503
## Styling
497504

498505
The Advanced Docking System supports styling via [Qt Style Sheets](https://doc.qt.io/qt-5/stylesheet.html). All components like splitters, tabs, buttons, titlebar and

src/ads/examples/centralwidget/mainwindow.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <QSettings>
1717
#include <QMessageBox>
1818
#include <QPlainTextEdit>
19+
#include <QToolBar>
1920

2021
#include "DockAreaWidget.h"
2122
#include "DockAreaTitleBar.h"
@@ -25,6 +26,18 @@
2526

2627
using namespace ads;
2728

29+
/**
30+
* Helper function to create an SVG icon
31+
*/
32+
static QIcon svgIcon(const QString& File)
33+
{
34+
// This is a workaround, because in item views SVG icons are not
35+
// properly scaled and look blurry or pixelate
36+
QIcon SvgIcon(File);
37+
SvgIcon.addPixmap(SvgIcon.pixmap(92));
38+
return SvgIcon;
39+
}
40+
2841
CMainWindow::CMainWindow(QWidget *parent)
2942
: QMainWindow(parent)
3043
, ui(new Ui::CMainWindow)
@@ -77,10 +90,46 @@ CMainWindow::CMainWindow(QWidget *parent)
7790
PropertiesDockWidget->setMinimumSize(200,150);
7891
DockManager->addDockWidget(DockWidgetArea::RightDockWidgetArea, PropertiesDockWidget, CentralDockArea);
7992
ui->menuView->addAction(PropertiesDockWidget->toggleViewAction());
93+
94+
createPerspectiveUi();
8095
}
8196

8297
CMainWindow::~CMainWindow()
8398
{
8499
delete ui;
85100
}
86101

102+
103+
void CMainWindow::createPerspectiveUi()
104+
{
105+
SavePerspectiveAction = new QAction("Create Perspective", this);
106+
SavePerspectiveAction->setIcon(svgIcon(":/adsdemo/images/picture_in_picture.svg"));
107+
connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
108+
PerspectiveListAction = new QWidgetAction(this);
109+
PerspectiveComboBox = new QComboBox(this);
110+
PerspectiveComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
111+
PerspectiveComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
112+
connect(PerspectiveComboBox, SIGNAL(activated(const QString&)),
113+
DockManager, SLOT(openPerspective(const QString&)));
114+
PerspectiveListAction->setDefaultWidget(PerspectiveComboBox);
115+
ui->toolBar->addSeparator();
116+
ui->toolBar->addAction(PerspectiveListAction);
117+
ui->toolBar->addAction(SavePerspectiveAction);
118+
}
119+
120+
121+
void CMainWindow::savePerspective()
122+
{
123+
QString PerspectiveName = QInputDialog::getText(this, "Save Perspective", "Enter unique name:");
124+
if (PerspectiveName.isEmpty())
125+
{
126+
return;
127+
}
128+
129+
DockManager->addPerspective(PerspectiveName);
130+
QSignalBlocker Blocker(PerspectiveComboBox);
131+
PerspectiveComboBox->clear();
132+
PerspectiveComboBox->addItems(DockManager->perspectiveNames());
133+
PerspectiveComboBox->setCurrentText(PerspectiveName);
134+
}
135+

src/ads/examples/centralwidget/mainwindow.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define MAINWINDOW_H
33

44
#include <QMainWindow>
5+
#include <QComboBox>
6+
#include <QWidgetAction>
57

68
#include "DockManager.h"
79
#include "DockAreaWidget.h"
@@ -20,13 +22,19 @@ class CMainWindow : public QMainWindow
2022
~CMainWindow();
2123

2224
private:
23-
static const QString kTableTopLayout;
24-
static const QString kTableBottomLayout;
25+
QAction* SavePerspectiveAction = nullptr;
26+
QWidgetAction* PerspectiveListAction = nullptr;
27+
QComboBox* PerspectiveComboBox = nullptr;
2528

2629
Ui::CMainWindow *ui;
2730

2831
ads::CDockManager* DockManager;
2932
ads::CDockAreaWidget* StatusDockArea;
3033
ads::CDockWidget* TimelineDockWidget;
34+
35+
void createPerspectiveUi();
36+
37+
private slots:
38+
void savePerspective();
3139
};
3240
#endif // MAINWINDOW_H

src/ads/examples/centralwidget/mainwindow.ui

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
</widget>
3131
<addaction name="menuView"/>
3232
</widget>
33+
<widget class="QToolBar" name="toolBar">
34+
<property name="windowTitle">
35+
<string>toolBar</string>
36+
</property>
37+
<attribute name="toolBarArea">
38+
<enum>TopToolBarArea</enum>
39+
</attribute>
40+
<attribute name="toolBarBreak">
41+
<bool>false</bool>
42+
</attribute>
43+
</widget>
3344
</widget>
3445
<resources/>
3546
<connections/>

src/ads/src/DockContainerWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
12071207
std::cout << (const char*)buf
12081208
<< (DockArea->isHidden() ? " " : "v")
12091209
<< (DockArea->openDockWidgetsCount() > 0 ? " " : "c")
1210-
<< " DockArea" << std::endl;
1210+
<< " DockArea " << "[hs: " << DockArea->sizePolicy().horizontalStretch() << ", vs: " << DockArea->sizePolicy().verticalStretch() << "]" << std::endl;
12111211
buf.fill(' ', (level + 1) * 4);
12121212
for (int i = 0; i < DockArea->dockWidgetsCount(); ++i)
12131213
{

src/ads/src/DockManager.cpp

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,27 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
279279
int DockContainers = s.attributes().value("Containers").toInt();
280280
#endif
281281
ADS_PRINT(DockContainers);
282+
283+
if (CentralWidget)
284+
{
285+
const auto CentralWidgetAttribute = s.attributes().value("CentralWidget");
286+
// If we have a central widget but a state without central widget, then
287+
// something is wrong.
288+
if (CentralWidgetAttribute.isEmpty())
289+
{
290+
qWarning() << "Dock manager has central widget but saved state does not have central widget.";
291+
return false;
292+
}
293+
294+
// If the object name of the central widget does not match the name of the
295+
// saved central widget, the something is wrong
296+
if (CentralWidget->objectName() != CentralWidgetAttribute.toString())
297+
{
298+
qWarning() << "Object name of central widget does not match name of central widget in saved state.";
299+
return false;
300+
}
301+
}
302+
282303
int DockContainerCount = 0;
283304
while (s.readNextStartElement())
284305
{
@@ -405,7 +426,6 @@ bool DockManagerPrivate::restoreState(const QByteArray& State, int version)
405426
return false;
406427
}
407428

408-
CentralWidget = nullptr;
409429
// Hide updates of floating widgets from use
410430
hideFloatingWidgets();
411431
markDockWidgetsDirty();
@@ -419,6 +439,7 @@ bool DockManagerPrivate::restoreState(const QByteArray& State, int version)
419439
restoreDockWidgetsOpenState();
420440
restoreDockAreasIndices();
421441
emitTopLevelEvents();
442+
_this->dumpLayout();
422443

423444
return true;
424445
}
@@ -636,6 +657,10 @@ QByteArray CDockManager::saveState(int version) const
636657
s.writeAttribute("Version", QString::number(CurrentVersion));
637658
s.writeAttribute("UserVersion", QString::number(version));
638659
s.writeAttribute("Containers", QString::number(d->Containers.count()));
660+
if (d->CentralWidget)
661+
{
662+
s.writeAttribute("CentralWidget", d->CentralWidget->objectName());
663+
}
639664
for (auto Container : d->Containers)
640665
{
641666
Container->saveState(s);
@@ -706,6 +731,7 @@ CFloatingDockContainer* CDockManager::addDockWidgetFloating(CDockWidget* Dockwid
706731
{
707732
d->UninitializedFloatingWidgets.append(FloatingWidget);
708733
}
734+
emit dockWidgetAdded(Dockwidget);
709735
return FloatingWidget;
710736
}
711737

@@ -732,7 +758,9 @@ CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
732758
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
733759
{
734760
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
735-
return CDockContainerWidget::addDockWidget(area, Dockwidget, DockAreaWidget);
761+
auto AreaOfAddedDockWidget = CDockContainerWidget::addDockWidget(area, Dockwidget, DockAreaWidget);
762+
emit dockWidgetAdded(Dockwidget);
763+
return AreaOfAddedDockWidget;
736764
}
737765

738766

@@ -901,10 +929,20 @@ CDockAreaWidget* CDockManager::setCentralWidget(CDockWidget* widget)
901929
return nullptr;
902930
}
903931

904-
// Setting a new central widget is now allowed if there is alread a central
905-
// widget
932+
// Setting a new central widget is now allowed if there is already a central
933+
// widget or if there are already other dock widgets
906934
if (d->CentralWidget)
907935
{
936+
qWarning("Setting a central widget not possible because there is already a central widget.");
937+
return nullptr;
938+
}
939+
940+
// Setting a central widget is now allowed if there are already other
941+
// dock widgets.
942+
if (!d->DockWidgetsMap.isEmpty())
943+
{
944+
qWarning("Setting a central widget not possible - the central widget need to be the first "
945+
"dock widget that is added to the dock manager.");
908946
return nullptr;
909947
}
910948

src/ads/src/DockManager.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,12 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
398398
* movable, floatable or closable and the titlebar of the central
399399
* dock area is not visible.
400400
* If the given widget could be set as central widget, the function returns
401-
* the created cok area. If the widget could not be set, because there
401+
* the created dock area. If the widget could not be set, because there
402402
* is already a central widget, this function returns a nullptr.
403403
* To clear the central widget, pass a nullptr to the function.
404+
* \note Setting a central widget is only possible if no other dock widgets
405+
* have been registered before. That means, this function should be the
406+
* first function that you call before you add other dock widgets.
404407
* \retval != 0 The dock area that contains the central widget
405408
* \retval nullptr Indicates that the given widget can not be set as central
406409
* widget because there is already a central widget.
@@ -552,6 +555,12 @@ public slots:
552555
*/
553556
void dockAreaCreated(ads::CDockAreaWidget* DockArea);
554557

558+
/**
559+
* This signal is emitted if a dock widget has been added to this
560+
* dock manager instance.
561+
*/
562+
void dockWidgetAdded(ads::CDockWidget* DockWidget);
563+
555564
/**
556565
* This signal is emitted just before the given dock widget is removed
557566
* from the dock manager

src/ads/src/FloatingDockContainer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess
752752
case WM_NCLBUTTONDOWN:
753753
if (msg->wParam == HTCAPTION && d->isState(DraggingInactive))
754754
{
755-
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_NCLBUTTONDOWN" << e->type());
755+
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_NCLBUTTONDOWN");
756756
d->DragStartPos = pos();
757757
d->setState(DraggingMousePressed);
758758
}
@@ -765,7 +765,7 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess
765765
case WM_ENTERSIZEMOVE:
766766
if (d->isState(DraggingMousePressed))
767767
{
768-
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_ENTERSIZEMOVE" << e->type());
768+
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_ENTERSIZEMOVE");
769769
d->setState(DraggingFloatingWidget);
770770
d->updateDropOverlays(QCursor::pos());
771771
}
@@ -774,7 +774,7 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess
774774
case WM_EXITSIZEMOVE:
775775
if (d->isState(DraggingFloatingWidget))
776776
{
777-
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_EXITSIZEMOVE" << e->type());
777+
ADS_PRINT("CFloatingDockContainer::nativeEvent WM_EXITSIZEMOVE");
778778
if (GetAsyncKeyState(VK_ESCAPE) & 0x8000)
779779
{
780780
d->handleEscapeKey();

src/ads/src/src.pro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ SOURCES += \
5959
DockFocusController.cpp
6060

6161

62-
unix {
63-
HEADERS += linux/FloatingWidgetTitleBar.h
64-
SOURCES += linux/FloatingWidgetTitleBar.cpp
62+
unix:!macx {
63+
HEADERS += linux/FloatingWidgetTitleBar.h
64+
SOURCES += linux/FloatingWidgetTitleBar.cpp
65+
QT += x11extras
6566
}
6667

6768
DISTFILES +=

0 commit comments

Comments
 (0)