diff --git a/AdvancedDockingSystem/AdvancedDockingSystem.pro b/AdvancedDockingSystem/AdvancedDockingSystem.pro index 250f62e..feb0fc9 100644 --- a/AdvancedDockingSystem/AdvancedDockingSystem.pro +++ b/AdvancedDockingSystem/AdvancedDockingSystem.pro @@ -14,17 +14,19 @@ windows { # MinGW *-g++* { QMAKE_CXXFLAGS += -std=c++11 + QMAKE_CXXFLAGS += -Wall -Wextra -pedantic } # MSVC *-msvc* { + QMAKE_CXXFLAGS += /Za } } SOURCES += \ src/API.cpp \ - src/ContainerWidget.cpp \ - src/SectionWidget.cpp \ - src/SectionContent.cpp \ + src/ContainerWidget.cpp \ + src/SectionWidget.cpp \ + src/SectionContent.cpp \ src/SectionTitleWidget.cpp \ src/SectionContentWidget.cpp \ src/DropOverlay.cpp \ diff --git a/AdvancedDockingSystem/include/ads/ContainerWidget.h b/AdvancedDockingSystem/include/ads/ContainerWidget.h index 67819ad..6f51242 100644 --- a/AdvancedDockingSystem/include/ads/ContainerWidget.h +++ b/AdvancedDockingSystem/include/ads/ContainerWidget.h @@ -72,4 +72,4 @@ public: }; ADS_NAMESPACE_END -#endif \ No newline at end of file +#endif diff --git a/AdvancedDockingSystem/include/ads/FloatingWidget.h b/AdvancedDockingSystem/include/ads/FloatingWidget.h index 68b6149..d5561f9 100644 --- a/AdvancedDockingSystem/include/ads/FloatingWidget.h +++ b/AdvancedDockingSystem/include/ads/FloatingWidget.h @@ -22,7 +22,7 @@ class FloatingWidget : public QWidget Q_OBJECT public: - FloatingWidget(ContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent = nullptr); + FloatingWidget(ContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent = NULL); virtual ~FloatingWidget(); InternalContentData takeContent(); @@ -41,4 +41,4 @@ private: }; ADS_NAMESPACE_END -#endif \ No newline at end of file +#endif diff --git a/AdvancedDockingSystem/include/ads/SectionContent.h b/AdvancedDockingSystem/include/ads/SectionContent.h index 9ecb58d..9dddaf2 100644 --- a/AdvancedDockingSystem/include/ads/SectionContent.h +++ b/AdvancedDockingSystem/include/ads/SectionContent.h @@ -42,4 +42,4 @@ private: }; ADS_NAMESPACE_END -#endif \ No newline at end of file +#endif diff --git a/AdvancedDockingSystem/include/ads/SectionContentWidget.h b/AdvancedDockingSystem/include/ads/SectionContentWidget.h index 5e4c44a..f418b9a 100644 --- a/AdvancedDockingSystem/include/ads/SectionContentWidget.h +++ b/AdvancedDockingSystem/include/ads/SectionContentWidget.h @@ -22,4 +22,4 @@ private: }; ADS_NAMESPACE_END -#endif \ No newline at end of file +#endif diff --git a/AdvancedDockingSystem/include/ads/SectionTitleWidget.h b/AdvancedDockingSystem/include/ads/SectionTitleWidget.h index c0e5a35..77e03d9 100644 --- a/AdvancedDockingSystem/include/ads/SectionTitleWidget.h +++ b/AdvancedDockingSystem/include/ads/SectionTitleWidget.h @@ -48,4 +48,4 @@ signals: }; ADS_NAMESPACE_END -#endif \ No newline at end of file +#endif diff --git a/AdvancedDockingSystem/include/ads/SectionWidget.h b/AdvancedDockingSystem/include/ads/SectionWidget.h index 6fe5735..7e4642b 100644 --- a/AdvancedDockingSystem/include/ads/SectionWidget.h +++ b/AdvancedDockingSystem/include/ads/SectionWidget.h @@ -74,4 +74,4 @@ private: }; ADS_NAMESPACE_END -#endif \ No newline at end of file +#endif diff --git a/AdvancedDockingSystem/src/API.cpp b/AdvancedDockingSystem/src/API.cpp index 0e2ba09..fbe8dc9 100644 --- a/AdvancedDockingSystem/src/API.cpp +++ b/AdvancedDockingSystem/src/API.cpp @@ -83,4 +83,4 @@ QSplitter* findImmediateSplitter(class QWidget* w) return sp; } -ADS_NAMESPACE_END \ No newline at end of file +ADS_NAMESPACE_END diff --git a/AdvancedDockingSystem/src/DropOverlay.cpp b/AdvancedDockingSystem/src/DropOverlay.cpp index 851bfbf..fa12731 100644 --- a/AdvancedDockingSystem/src/DropOverlay.cpp +++ b/AdvancedDockingSystem/src/DropOverlay.cpp @@ -17,7 +17,7 @@ ADS_NAMESPACE_BEGIN static QWidget* createDropWidget(const QString& img) { - auto label = new QLabel(); + QLabel* label = new QLabel(); label->setObjectName("DropAreaLabel"); label->setPixmap(QPixmap(img)); return label; @@ -57,7 +57,7 @@ DropOverlay::~DropOverlay() DropArea DropOverlay::cursorLocation() const { - auto loc = InvalidDropArea; + DropArea loc = InvalidDropArea; if (_splitAreas) { loc = _splitAreas->cursorLocation(); @@ -201,8 +201,8 @@ DropSplitAreas::DropSplitAreas(DropAreas areas, QWidget* parent) : DropArea DropSplitAreas::cursorLocation() const { - auto loc = InvalidDropArea; - auto pos = mapFromGlobal(QCursor::pos()); + DropArea loc = InvalidDropArea; + QPoint pos = mapFromGlobal(QCursor::pos()); if (_top && _top->geometry().contains(pos)) { loc = TopDropArea; diff --git a/AdvancedDockingSystem/src/FloatingWidget.cpp b/AdvancedDockingSystem/src/FloatingWidget.cpp index a62c276..a960c5b 100644 --- a/AdvancedDockingSystem/src/FloatingWidget.cpp +++ b/AdvancedDockingSystem/src/FloatingWidget.cpp @@ -21,7 +21,7 @@ FloatingWidget::FloatingWidget(ContainerWidget* container, SectionContent::RefPt _titleWidget(titleWidget), _contentWidget(contentWidget) { - auto l = new QBoxLayout(QBoxLayout::TopToBottom, this); + QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom, this); l->setContentsMargins(0, 0, 0, 0); l->setSpacing(0); setLayout(l); @@ -38,7 +38,7 @@ FloatingWidget::FloatingWidget(ContainerWidget* container, SectionContent::RefPt // maximizeButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // _titleLayout->addWidget(maximizeButton); - auto closeButton = new QPushButton(); + QPushButton* closeButton = new QPushButton(); closeButton->setObjectName("closeButton"); closeButton->setFlat(true); closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); diff --git a/AdvancedDockingSystem/src/SectionContent.cpp b/AdvancedDockingSystem/src/SectionContent.cpp index 59fa23b..66ff449 100644 --- a/AdvancedDockingSystem/src/SectionContent.cpp +++ b/AdvancedDockingSystem/src/SectionContent.cpp @@ -53,4 +53,4 @@ SectionContent::RefPtr SectionContent::newSectionContent(QWidget* title, QWidget return sc; } -ADS_NAMESPACE_END \ No newline at end of file +ADS_NAMESPACE_END diff --git a/AdvancedDockingSystem/src/SectionContentWidget.cpp b/AdvancedDockingSystem/src/SectionContentWidget.cpp index 46753d1..456020e 100644 --- a/AdvancedDockingSystem/src/SectionContentWidget.cpp +++ b/AdvancedDockingSystem/src/SectionContentWidget.cpp @@ -8,11 +8,11 @@ SectionContentWidget::SectionContentWidget(SectionContent::RefPtr c, QWidget* pa QFrame(parent), _content(c) { - auto l = new QBoxLayout(QBoxLayout::TopToBottom); + QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom); l->setContentsMargins(0, 0, 0, 0); l->setSpacing(0); l->addWidget(_content->contentWidget()); setLayout(l); } -ADS_NAMESPACE_END \ No newline at end of file +ADS_NAMESPACE_END diff --git a/AdvancedDockingSystem/src/SectionTitleWidget.cpp b/AdvancedDockingSystem/src/SectionTitleWidget.cpp index 9975d5e..bcdf286 100644 --- a/AdvancedDockingSystem/src/SectionTitleWidget.cpp +++ b/AdvancedDockingSystem/src/SectionTitleWidget.cpp @@ -30,7 +30,7 @@ SectionTitleWidget::SectionTitleWidget(SectionContent::RefPtr content, QWidget* _tabMoving(false), _activeTab(false) { - auto l = new QBoxLayout(QBoxLayout::LeftToRight); + QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight); l->addWidget(content->titleWidget()); setLayout(l); } @@ -74,33 +74,33 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev) // Drop contents of FloatingWidget into SectionWidget. if (_fw) { - auto cw = findParentContainerWidget(this); - auto sw = cw->sectionAt(cw->mapFromGlobal(ev->globalPos())); + ContainerWidget* cw = findParentContainerWidget(this); + SectionWidget* sw = cw->sectionAt(cw->mapFromGlobal(ev->globalPos())); if (sw) { - auto loc = showDropOverlay(sw); + DropArea loc = showDropOverlay(sw); if (loc != InvalidDropArea) { #if !defined(ADS_ANIMATIONS_ENABLED) - auto data = _fw->takeContent(); + InternalContentData data = _fw->takeContent(); _fw->deleteLater(); _fw.clear(); cw->dropContent(data, sw, loc); #else - auto moveAnim = new QPropertyAnimation(_fw, "pos", this); + QPropertyAnimation* moveAnim = new QPropertyAnimation(_fw, "pos", this); moveAnim->setStartValue(_fw->pos()); moveAnim->setEndValue(sw->mapToGlobal(sw->rect().topLeft())); moveAnim->setDuration(ADS_ANIMATION_DURATION); - auto resizeAnim = new QPropertyAnimation(_fw, "size", this); + QPropertyAnimation* resizeAnim = new QPropertyAnimation(_fw, "size", this); resizeAnim->setStartValue(_fw->size()); resizeAnim->setEndValue(sw->size()); resizeAnim->setDuration(ADS_ANIMATION_DURATION); - auto animGroup = new QParallelAnimationGroup(this); + QParallelAnimationGroup* animGroup = new QParallelAnimationGroup(this); QObject::connect(animGroup, &QPropertyAnimation::finished, [this, data, sw, loc]() { - auto data = _fw->takeContent(); + InternalContentData data = _fw->takeContent(); _fw->deleteLater(); _fw.clear(); cw->dropContent(data, sw, loc); @@ -127,7 +127,7 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev) if (dropArea != DropArea::InvalidDropArea) { #if !defined(ADS_ANIMATIONS_ENABLED) - auto data = _fw->takeContent(); + InternalContentData data = _fw->takeContent(); _fw->deleteLater(); _fw.clear(); cw->dropContent(data, NULL, dropArea); @@ -215,7 +215,7 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev) && !section->titleAreaGeometry().contains(section->mapFromGlobal(ev->globalPos()))) { // Create floating widget. - auto data = section->take(_content->uid(), false); + InternalContentData data = section->take(_content->uid(), false); _fw = new FloatingWidget(cw, data.content, data.titleWidget, data.contentWidget, cw); _fw->resize(section->size()); diff --git a/AdvancedDockingSystem/src/SectionWidget.cpp b/AdvancedDockingSystem/src/SectionWidget.cpp index 7925507..b34fb8c 100644 --- a/AdvancedDockingSystem/src/SectionWidget.cpp +++ b/AdvancedDockingSystem/src/SectionWidget.cpp @@ -31,7 +31,7 @@ SectionWidget::SectionWidget(ContainerWidget* parent) : _uid(NextUid++), _container(parent) { - auto l = new QBoxLayout(QBoxLayout::TopToBottom); + QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom); l->setContentsMargins(0, 0, 0, 0); l->setSpacing(0); setLayout(l); @@ -48,7 +48,7 @@ SectionWidget::SectionWidget(ContainerWidget* parent) : l->addLayout(_contentsLayout, 1); #if defined(ADS_ANIMATIONS_ENABLED) - auto shadow = new QGraphicsDropShadowEffect(this); + QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(this); shadow->setOffset(0, 0); shadow->setBlurRadius(8); setGraphicsEffect(shadow); @@ -65,7 +65,7 @@ SectionWidget::~SectionWidget() _container->_sections.removeAll(this); // Delete empty QSplitter. - auto splitter = findParentSplitter(this); + QSplitter* splitter = findParentSplitter(this); if (splitter && splitter->count() == 0) { splitter->deleteLater(); @@ -97,12 +97,12 @@ void SectionWidget::addContent(SectionContent::RefPtr c) { _contents.append(c); - auto title = new SectionTitleWidget(c, nullptr); + SectionTitleWidget* title = new SectionTitleWidget(c, NULL); _sectionTitles.append(title); _tabsLayout->insertWidget(_tabsLayout->count() - 1, title); QObject::connect(title, &SectionTitleWidget::clicked, this, &SectionWidget::onSectionTitleClicked); - auto content = new SectionContentWidget(c, nullptr); + SectionContentWidget* content = new SectionContentWidget(c, NULL); _sectionContents.append(content); _contentsLayout->addWidget(content); @@ -153,7 +153,7 @@ InternalContentData SectionWidget::take(int uid, bool del) } // Title wrapper widget (TAB) - auto title = _sectionTitles.takeAt(index); + SectionTitleWidget* title = _sectionTitles.takeAt(index); if (title) { _tabsLayout->removeWidget(title); @@ -163,7 +163,7 @@ InternalContentData SectionWidget::take(int uid, bool del) } // Content wrapper widget (CONTENT) - auto content = _sectionContents.takeAt(index); + SectionContentWidget* content = _sectionContents.takeAt(index); if (content) { _contentsLayout->removeWidget(content); @@ -240,10 +240,10 @@ void SectionWidget::setCurrentIndex(int index) qDebug() << Q_FUNC_INFO << index; for (int i = 0; i < _tabsLayout->count(); ++i) { - auto item = _tabsLayout->itemAt(i); + QLayoutItem* item = _tabsLayout->itemAt(i); if (item->widget()) { - auto stw = dynamic_cast(item->widget()); + SectionTitleWidget* stw = dynamic_cast(item->widget()); if (i == index) stw->setActiveTab(true); else @@ -266,12 +266,12 @@ void SectionWidget::paintEvent(QPaintEvent* e) void SectionWidget::onSectionTitleClicked() { - auto stw = qobject_cast(sender()); + SectionTitleWidget* stw = qobject_cast(sender()); if (stw) { - auto index = _tabsLayout->indexOf(stw); + int index = _tabsLayout->indexOf(stw); setCurrentIndex(index); } } -ADS_NAMESPACE_END \ No newline at end of file +ADS_NAMESPACE_END diff --git a/AdvancedDockingSystemDemo/src/icontitlewidget.cpp b/AdvancedDockingSystemDemo/src/icontitlewidget.cpp index 5bd77f2..9c6937e 100644 --- a/AdvancedDockingSystemDemo/src/icontitlewidget.cpp +++ b/AdvancedDockingSystemDemo/src/icontitlewidget.cpp @@ -9,27 +9,27 @@ IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent) : QFrame(parent) { - auto l = new QBoxLayout(QBoxLayout::LeftToRight); + QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight); l->setContentsMargins(0, 0, 0, 0); setLayout(l); // Icon label if (icon.isNull()) { -// auto titleIcon = new QLabel(); +// QLabel* titleIcon = new QLabel(); // titleIcon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(16, 16)); // l->addWidget(titleIcon); } else { - auto titleIcon = new QLabel(); + QLabel* titleIcon = new QLabel(); titleIcon->setPixmap(icon.pixmap(16, 16)); l->addWidget(titleIcon); } // Title label - auto titleText = new QLabel(title); - auto titleFont = titleText->font(); + QLabel* titleText = new QLabel(title); + QFont titleFont = titleText->font(); titleFont.setBold(true); titleText->setFont(titleFont); l->addWidget(titleText, 1); diff --git a/AdvancedDockingSystemDemo/src/main.cpp b/AdvancedDockingSystemDemo/src/main.cpp index 01c1db1..513ed2a 100644 --- a/AdvancedDockingSystemDemo/src/main.cpp +++ b/AdvancedDockingSystemDemo/src/main.cpp @@ -10,10 +10,10 @@ static void centerWidget(QWidget* widget) if (widget) { QDesktopWidget deskWidget; - const auto screenIndex = deskWidget.primaryScreen(); - const auto deskRect = deskWidget.availableGeometry(screenIndex); - const auto x = (deskRect.width() - widget->rect().width()) / 2; - const auto y = (deskRect.height() - widget->rect().height()) / 2; + const int screenIndex = deskWidget.primaryScreen(); + const QRect deskRect = deskWidget.availableGeometry(screenIndex); + const int x = (deskRect.width() - widget->rect().width()) / 2; + const int y = (deskRect.height() - widget->rect().height()) / 2; widget->move(x, y); } } @@ -23,10 +23,10 @@ static void resizeWidgetPerCent(QWidget* widget, qreal widthPC, qreal heightPC) if (widget && widthPC >= 0.0 && heightPC >= 0.0) { QDesktopWidget deskWidget; - const auto screenIndex = deskWidget.primaryScreen(); - const auto deskRect = deskWidget.availableGeometry(screenIndex); - const auto w = (deskRect.width() / 100) * widthPC; - const auto h = (deskRect.height() / 100) * heightPC; + const int screenIndex = deskWidget.primaryScreen(); + const QRect deskRect = deskWidget.availableGeometry(screenIndex); + const int w = (deskRect.width() / 100) * widthPC; + const int h = (deskRect.height() / 100) * heightPC; widget->resize(w, h); } } diff --git a/AdvancedDockingSystemDemo/src/mainwindow.cpp b/AdvancedDockingSystemDemo/src/mainwindow.cpp index efe3338..de078a2 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.cpp +++ b/AdvancedDockingSystemDemo/src/mainwindow.cpp @@ -88,14 +88,17 @@ MainWindow::MainWindow(QWidget *parent) : section->addContent(createCalendarSC()); _container->addSection(section); - QByteArray ba; - QFile f("test.dat"); - if (f.open(QFile::ReadOnly)) + if (true) { - ba = f.readAll(); - f.close(); + QByteArray ba; + QFile f("test.dat"); + if (f.open(QFile::ReadOnly)) + { + ba = f.readAll(); + f.close(); + } + _container->restoreGeometry(ba); } - _container->restoreGeometry(ba); } MainWindow::~MainWindow() @@ -118,6 +121,7 @@ void MainWindow::onActionAddSectionContentTriggered() void MainWindow::contextMenuEvent(QContextMenuEvent* e) { + Q_UNUSED(e); QMenu* m = _container->createContextMenu(); m->exec(QCursor::pos()); delete m; @@ -125,11 +129,15 @@ void MainWindow::contextMenuEvent(QContextMenuEvent* e) void MainWindow::closeEvent(QCloseEvent* e) { - QByteArray ba = _container->saveGeometry(); - QFile f("test.dat"); - if (f.open(QFile::WriteOnly)) + Q_UNUSED(e); + if (true) { - f.write(ba); - f.close(); + QByteArray ba = _container->saveGeometry(); + QFile f("test.dat"); + if (f.open(QFile::WriteOnly)) + { + f.write(ba); + f.close(); + } } }