#include "topicwidget.h"
-#include <QDebug>
-
#include "client.h"
#include "iconloader.h"
#include "networkmodel.h"
: 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) {
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<BufferInfo>();
}
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<QWidget *>(parent())->setMinimumHeight(height() + 2*qApp->style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin));
- qobject_cast<QWidget *>(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<QWidget *>(parent())->setMinimumHeight(height() + 2*qApp->style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin));
- qobject_cast<QWidget *>(parent())->adjustSize();
+ updateGeometry();
}
// filter for the input widget to switch back to normal mode
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>TopicWidget</class>
- <widget class="QWidget" name="TopicWidget" >
- <property name="geometry" >
+ <widget class="QWidget" name="TopicWidget">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>644</width>
- <height>35</height>
+ <width>643</width>
+ <height>27</height>
</rect>
</property>
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize" >
+ <property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
- <property name="baseSize" >
+ <property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout" >
- <property name="sizeConstraint" >
- <enum>QLayout::SetDefaultConstraint</enum>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="margin">
+ <number>0</number>
</property>
- <property name="leftMargin" >
- <number>4</number>
- </property>
- <property name="topMargin" >
- <number>2</number>
- </property>
- <property name="rightMargin" >
- <number>4</number>
- </property>
- <property name="bottomMargin" >
- <number>2</number>
- </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" >
- <enum>QFrame::Plain</enum>
- </property>
- </widget>
- </item>
<item>
- <widget class="ClearableLineEdit" name="topicLineEdit" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+ <widget class="ResizingStackedWidget" name="stackedWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<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" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="pixmap" >
- <pixmap>:/22x22/actions/oxygen/22x22/actions/edit-clear.png</pixmap>
+ <property name="currentIndex">
+ <number>0</number>
</property>
+ <widget class="QWidget" name="page">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Ignored">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="StyledLabel" name="topicLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="topicEditButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="page_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Ignored">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="MultiLineEdit" name="topicLineEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
- <class>ClearableLineEdit</class>
- <extends>QLineEdit</extends>
- <header location="global" >clearablelineedit.h</header>
+ <class>MultiLineEdit</class>
+ <extends>QTextEdit</extends>
+ <header>multilineedit.h</header>
</customwidget>
<customwidget>
- <class>ClickableLabel</class>
- <extends>QLabel</extends>
- <header location="global" >clickablelabel.h</header>
+ <class>StyledLabel</class>
+ <extends>QFrame</extends>
+ <header>styledlabel.h</header>
+ <container>1</container>
</customwidget>
<customwidget>
- <class>TopicLabel</class>
- <extends>QFrame</extends>
- <header location="global" >topiclabel.h</header>
+ <class>ResizingStackedWidget</class>
+ <extends>QStackedWidget</extends>
+ <header>resizingstackedwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>