From: Manuel Nickschas Date: Fri, 21 Aug 2009 22:06:44 +0000 (+0200) Subject: Redesign the topic widget X-Git-Tag: 0.5-rc1~51 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=ef20dd04ad6ed1911fa070c5dafe2498d9a4fc9d Redesign the topic widget This replaces the old ugly hackish topicwidget by something cleaner. We now use a stacked widget to switch between display and edit mode. In edit mode, we use a MultiLineEdit rather than a single QLineEdit. Instead of doing voodooish resizing of the parent widget, we use proper sizeHints and sizePolicies that make Qt's layout system actually work with this. There are still some features missing though, notably clickable URLs and the clear button. Will be implemented ASAP. Closes #506, fixes #573, closes #608. --- diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index cc66bd46..dbca69e8 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -20,8 +20,6 @@ #include "topicwidget.h" -#include - #include "client.h" #include "iconloader.h" #include "networkmodel.h" @@ -30,13 +28,9 @@ TopicWidget::TopicWidget(QWidget *parent) : AbstractItemView(parent) { ui.setupUi(this); - ui.topicEditButton->setPixmap(BarIcon("edit-rename")); + ui.topicEditButton->setIcon(SmallIcon("edit-rename")); - 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) { @@ -61,7 +55,7 @@ void TopicWidget::setTopic(const QString &newtopic) { switchPlain(); } -void TopicWidget::on_topicLineEdit_returnPressed() { +void TopicWidget::on_topicLineEdit_textEntered() { QModelIndex currentIdx = currentIndex(); if(currentIdx.isValid() && currentIdx.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer) { BufferInfo bufferInfo = currentIdx.data(NetworkModel::BufferInfoRole).value(); @@ -78,26 +72,15 @@ void TopicWidget::on_topicEditButton_clicked() { } void TopicWidget::switchEditable() { - ui.topicLabel->hide(); - ui.topicEditButton->hide(); - ui.topicLineEdit->show(); + ui.stackedWidget->setCurrentIndex(1); 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(); + updateGeometry(); } void TopicWidget::switchPlain() { - ui.topicLineEdit->hide(); - ui.topicLabel->show(); - ui.topicEditButton->show(); + ui.stackedWidget->setCurrentIndex(0); 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(); + updateGeometry(); } // filter for the input widget to switch back to normal mode diff --git a/src/qtui/topicwidget.h b/src/qtui/topicwidget.h index 666dd742..76e68f19 100644 --- a/src/qtui/topicwidget.h +++ b/src/qtui/topicwidget.h @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _TOPICWIDGET_H_ -#define _TOPICWIDGET_H_ +#ifndef TOPICWIDGET_H_ +#define TOPICWIDGET_H_ #include "abstractitemview.h" @@ -40,11 +40,11 @@ protected slots: virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); private slots: - void on_topicLineEdit_returnPressed(); + void on_topicLineEdit_textEntered(); void on_topicEditButton_clicked(); void switchEditable(); void switchPlain(); - + private: Ui::TopicWidget ui; diff --git a/src/qtui/ui/topicwidget.ui b/src/qtui/ui/topicwidget.ui index 4610b01e..0d5e8f2b 100644 --- a/src/qtui/ui/topicwidget.ui +++ b/src/qtui/ui/topicwidget.ui @@ -1,116 +1,130 @@ - + + TopicWidget - - + + 0 0 - 644 - 35 + 643 + 27 - - + + 0 0 - + 0 0 - + 0 0 - + Form - - - QLayout::SetDefaultConstraint + + + 0 - - 4 - - - 2 - - - 4 - - - 2 - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Plain - - - - - - + + + 0 0 - - true - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - - - :/22x22/actions/oxygen/22x22/actions/edit-clear.png + + 0 + + + + 0 + 0 + + + + + 0 + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Plain + + + + + + + ... + + + + + + + + + 0 + 0 + + + + + 0 + + + + + + 0 + 0 + + + + + + - ClearableLineEdit - QLineEdit -
clearablelineedit.h
+ MultiLineEdit + QTextEdit +
multilineedit.h
- ClickableLabel - QLabel -
clickablelabel.h
+ StyledLabel + QFrame +
styledlabel.h
+ 1
- TopicLabel - QFrame -
topiclabel.h
+ ResizingStackedWidget + QStackedWidget +
resizingstackedwidget.h
1