From: Manuel Nickschas Date: Mon, 1 Sep 2008 19:23:18 +0000 (+0200) Subject: Trying to force Qt's layout system into not screwing up our topic widget for some... X-Git-Tag: 0.3.1~306 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=9861cef46e8a052140070b4c643092f9c62aa6df Trying to force Qt's layout system into not screwing up our topic widget for some people Please test this with your style. Widget handle still needs some love... --- diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index ab901fd6..7d2d90bd 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -32,6 +32,8 @@ TopicWidget::TopicWidget(QWidget *parent) ui.topicLineEdit->hide(); ui.topicLineEdit->installEventFilter(this); ui.topicLabel->show(); + setContentsMargins(0,0,0,0); + parent->setMinimumHeight(layout()->sizeHint().height() + 2*qApp->style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin)); } void TopicWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { @@ -74,6 +76,11 @@ void TopicWidget::switchEditable() { ui.topicEditButton->hide(); ui.topicLineEdit->show(); ui.topicLineEdit->setFocus(); + + setFixedHeight(layout()->sizeHint().height()); + // Update the dock widget too, else it won't resize in all styles... FIXME try to sanitize this + qobject_cast(parent())->setMinimumHeight(height() + 2*qApp->style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin)); + qobject_cast(parent())->adjustSize(); } void TopicWidget::switchPlain() { @@ -81,6 +88,10 @@ void TopicWidget::switchPlain() { ui.topicLabel->show(); ui.topicEditButton->show(); ui.topicLineEdit->setText(_topic); + setFixedHeight(layout()->sizeHint().height()); + // Update the dock widget too, else it won't resize in all styles... FIXME try to sanitize this + qobject_cast(parent())->setMinimumHeight(height() + 2*qApp->style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin)); + qobject_cast(parent())->adjustSize(); } // filter for the input widget to switch back to normal mode @@ -102,4 +113,3 @@ bool TopicWidget::eventFilter(QObject *obj, QEvent *event) { return false; } - diff --git a/src/qtui/ui/topicwidget.ui b/src/qtui/ui/topicwidget.ui index 3eae92e6..ca0ac046 100644 --- a/src/qtui/ui/topicwidget.ui +++ b/src/qtui/ui/topicwidget.ui @@ -5,12 +5,12 @@ 0 0 - 611 - 36 + 644 + 35 - + 0 0 @@ -30,22 +30,44 @@ Form - + + + QLayout::SetDefaultConstraint + - 4 + 0 + + + 0 + 0 + + QFrame::StyledPanel - QFrame::Raised + QFrame::Plain - + + + + 0 + 0 + + + + true + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + diff --git a/src/qtui/verticaldock.cpp b/src/qtui/verticaldock.cpp index 4ac07fe4..fc0125b1 100644 --- a/src/qtui/verticaldock.cpp +++ b/src/qtui/verticaldock.cpp @@ -20,6 +20,7 @@ #include "verticaldock.h" +#include #include #include @@ -34,7 +35,7 @@ QSize VerticalDockTitle::sizeHint() const { } QSize VerticalDockTitle::minimumSizeHint() const { - return QSize(10, 15); + return QSize(10, 10); } void VerticalDockTitle::paintEvent(QPaintEvent *event) { @@ -44,16 +45,13 @@ void VerticalDockTitle::paintEvent(QPaintEvent *event) { 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); + 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 // ============================== @@ -67,6 +65,7 @@ VerticalDock::VerticalDock(QWidget *parent, Qt::WindowFlags flags) : QDockWidget(parent, flags) { setDefaultTitleWidget(); + setContentsMargins(0, 0, 0, 0); } void VerticalDock::setDefaultTitleWidget() {