X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fverticaldock.cpp;h=f27ed237a2a6c531a6bd1d8508de51d86ce6f177;hp=28ebe6820e7731c3c426c6dc578b984b1528b529;hb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;hpb=6ffaa82b95c0be603b9f94688c435bdcf6129230 diff --git a/src/qtui/verticaldock.cpp b/src/qtui/verticaldock.cpp index 28ebe682..f27ed237 100644 --- a/src/qtui/verticaldock.cpp +++ b/src/qtui/verticaldock.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005/06 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,73 +15,85 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "verticaldock.h" +#include +#include #include +#include -#include +VerticalDockTitle::VerticalDockTitle(QDockWidget* parent) + : QWidget(parent) +{} -VerticalDockTitle::VerticalDockTitle(QDockWidget *parent) - : QWidget(parent) +QSize VerticalDockTitle::sizeHint() const { + return {8, 15}; } -VerticalDockTitle::~VerticalDockTitle() { +QSize VerticalDockTitle::minimumSizeHint() const +{ + return {8, 10}; } -QSize VerticalDockTitle::sizeHint() const { - return QSize(10, 15); -} +void VerticalDockTitle::paintEvent(QPaintEvent* event) +{ + Q_UNUSED(event); -QSize VerticalDockTitle::minimumSizeHint() const { - return QSize(10, 15); -} + QPainter painter(this); -void VerticalDockTitle::paintEvent(QPaintEvent *event) { - Q_UNUSED(event); - - QPainter painter(this); - - if(rect().isValid() && rect().height() > minimumSizeHint().height()) { - for(int i = 0; i < 2; i++) { - QPoint topLeft = rect().topLeft() + QPoint(3 + i*2, 5); - QPoint bottomRight = rect().topLeft() + QPoint(3 + i*2, rect().height() - 5); - qDrawShadeLine(&painter, topLeft, bottomRight, palette()); + if (rect().isValid() && rect().height() > minimumSizeHint().height()) { + for (int i = 0; i < 2; i++) { + QPoint topLeft = rect().topLeft() + QPoint(3 + i * 2, 2); + QPoint bottomRight = rect().topLeft() + QPoint(3 + i * 2, rect().height() - 2); + qDrawShadeLine(&painter, topLeft, bottomRight, palette()); + } } - } - } - // ============================== // Vertical Dock // ============================== -VerticalDock::VerticalDock(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags) +VerticalDock::VerticalDock(const QString& title, QWidget* parent, Qt::WindowFlags flags) + : QDockWidget(title, parent, flags) { - setDefaultTitleWidget(); + setDefaultTitleWidget(); } -VerticalDock::VerticalDock(QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(parent, flags) +VerticalDock::VerticalDock(QWidget* parent, Qt::WindowFlags flags) + : QDockWidget(parent, flags) { - setDefaultTitleWidget(); + setDefaultTitleWidget(); + setContentsMargins(0, 0, 0, 0); } -VerticalDock::~VerticalDock() { +void VerticalDock::setDefaultTitleWidget() +{ + QWidget* oldDockTitle = titleBarWidget(); + QWidget* newDockTitle = new VerticalDockTitle(this); + + setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); + setFeatures(features() | QDockWidget::DockWidgetVerticalTitleBar); + setTitleBarWidget(newDockTitle); + + if (oldDockTitle) + oldDockTitle->deleteLater(); } -void VerticalDock::setDefaultTitleWidget() { - QWidget *oldDockTitle = titleBarWidget(); - QWidget *newDockTitle = new VerticalDockTitle(this); +void VerticalDock::showTitle(bool show) +{ + QWidget* oldDockTitle = titleBarWidget(); + QWidget* newDockTitle = nullptr; + + if (show) + newDockTitle = new VerticalDockTitle(this); + else + newDockTitle = new EmptyDockTitle(this); - setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); - setFeatures(features() | QDockWidget::DockWidgetVerticalTitleBar); - setTitleBarWidget(newDockTitle); - - if(oldDockTitle) - oldDockTitle->deleteLater(); + setTitleBarWidget(newDockTitle); + if (oldDockTitle) + oldDockTitle->deleteLater(); }