Trying to force Qt's layout system into not screwing up our topic widget for some...
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 1 Sep 2008 19:23:18 +0000 (21:23 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 1 Sep 2008 19:23:18 +0000 (21:23 +0200)
Please test this with your style. Widget handle still needs some love...

src/qtui/topicwidget.cpp
src/qtui/ui/topicwidget.ui
src/qtui/verticaldock.cpp

index ab901fd..7d2d90b 100644 (file)
@@ -32,6 +32,8 @@ TopicWidget::TopicWidget(QWidget *parent)
   ui.topicLineEdit->hide();
   ui.topicLineEdit->installEventFilter(this);
   ui.topicLabel->show();
   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 &current, const QModelIndex &previous) {
 }
 
 void TopicWidget::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
@@ -74,6 +76,11 @@ void TopicWidget::switchEditable() {
   ui.topicEditButton->hide();
   ui.topicLineEdit->show();
   ui.topicLineEdit->setFocus();
   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<QWidget *>(parent())->setMinimumHeight(height() + 2*qApp->style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin));
+  qobject_cast<QWidget *>(parent())->adjustSize();
 }
 
 void TopicWidget::switchPlain() {
 }
 
 void TopicWidget::switchPlain() {
@@ -81,6 +88,10 @@ void TopicWidget::switchPlain() {
   ui.topicLabel->show();
   ui.topicEditButton->show();
   ui.topicLineEdit->setText(_topic);
   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<QWidget *>(parent())->setMinimumHeight(height() + 2*qApp->style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin));
+  qobject_cast<QWidget *>(parent())->adjustSize();
 }
 
 // filter for the input widget to switch back to normal mode
 }
 
 // filter for the input widget to switch back to normal mode
@@ -102,4 +113,3 @@ bool TopicWidget::eventFilter(QObject *obj, QEvent *event) {
   
   return false;
 }
   
   return false;
 }
-
index 3eae92e..ca0ac04 100644 (file)
@@ -5,12 +5,12 @@
    <rect>
     <x>0</x>
     <y>0</y>
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>611</width>
-    <height>36</height>
+    <width>644</width>
+    <height>35</height>
    </rect>
   </property>
   <property name="sizePolicy" >
    </rect>
   </property>
   <property name="sizePolicy" >
-   <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+   <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
     <horstretch>0</horstretch>
     <verstretch>0</verstretch>
    </sizepolicy>
     <horstretch>0</horstretch>
     <verstretch>0</verstretch>
    </sizepolicy>
   <property name="windowTitle" >
    <string>Form</string>
   </property>
   <property name="windowTitle" >
    <string>Form</string>
   </property>
-  <layout class="QHBoxLayout" >
+  <layout class="QHBoxLayout" name="horizontalLayout" >
+   <property name="sizeConstraint" >
+    <enum>QLayout::SetDefaultConstraint</enum>
+   </property>
    <property name="margin" >
    <property name="margin" >
-    <number>4</number>
+    <number>0</number>
    </property>
    <item>
     <widget class="TopicLabel" name="topicLabel" >
    </property>
    <item>
     <widget class="TopicLabel" name="topicLabel" >
+     <property name="sizePolicy" >
+      <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
      <property name="frameShape" >
       <enum>QFrame::StyledPanel</enum>
      </property>
      <property name="frameShadow" >
      <property name="frameShape" >
       <enum>QFrame::StyledPanel</enum>
      </property>
      <property name="frameShadow" >
-      <enum>QFrame::Raised</enum>
+      <enum>QFrame::Plain</enum>
      </property>
     </widget>
    </item>
    <item>
      </property>
     </widget>
    </item>
    <item>
-    <widget class="ClearableLineEdit" name="topicLineEdit" />
+    <widget class="ClearableLineEdit" name="topicLineEdit" >
+     <property name="sizePolicy" >
+      <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="frame" >
+      <bool>true</bool>
+     </property>
+     <property name="alignment" >
+      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+     </property>
+    </widget>
    </item>
    <item>
     <widget class="ClickableLabel" name="topicEditButton" >
    </item>
    <item>
     <widget class="ClickableLabel" name="topicEditButton" >
index 4ac07fe..fc0125b 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "verticaldock.h"
 
 
 #include "verticaldock.h"
 
+#include <QLayout>
 #include <QPainter>
 
 #include <QDebug>
 #include <QPainter>
 
 #include <QDebug>
@@ -34,7 +35,7 @@ QSize VerticalDockTitle::sizeHint() const {
 }
 
 QSize VerticalDockTitle::minimumSizeHint() const {
 }
 
 QSize VerticalDockTitle::minimumSizeHint() const {
-  return QSize(10, 15);
+  return QSize(10, 10);
 }
 
 void VerticalDockTitle::paintEvent(QPaintEvent *event) {
 }
 
 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++) {
   
   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());
     }
   }
       qDrawShadeLine(&painter, topLeft, bottomRight, palette());
     }
   }
-
 }
 
 }
 
-
-
 // ==============================
 //  Vertical Dock
 // ==============================
 // ==============================
 //  Vertical Dock
 // ==============================
@@ -67,6 +65,7 @@ VerticalDock::VerticalDock(QWidget *parent, Qt::WindowFlags flags)
   : QDockWidget(parent, flags)
 {
   setDefaultTitleWidget();
   : QDockWidget(parent, flags)
 {
   setDefaultTitleWidget();
+  setContentsMargins(0, 0, 0, 0);
 }
 
 void VerticalDock::setDefaultTitleWidget() {
 }
 
 void VerticalDock::setDefaultTitleWidget() {