//static QString formattedToHtml(const QString &);
+ /** Convert mIRC control codes to our own */
+ static QString mircToInternal(QString);
+
void format();
private:
QString _formattedTimestamp, _formattedSender, _formattedText; // cache
- /** Convert mIRC control codes to our own */
- QString mircToInternal(QString);
friend QDataStream &operator>>(QDataStream &in, Message &msg);
};
SRCS += aboutdlg.cpp bufferwidget.cpp chatitem.cpp chatline.cpp chatline-old.cpp chatscene.cpp chatview.cpp chatwidget.cpp \
coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \
mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \
- topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
+ topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
HDRS += aboutdlg.h bufferwidget.h chatitem.h chatline.h chatline-old.h chatscene.h chatview.h chatwidget.h \
coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \
coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \
- topicwidget.h verticaldock.h jumpkeyhandler.h
+ topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h
FORMNAMES = aboutdlg.ui mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \
settingspagedlg.ui topicwidget.ui debugconsole.ui inputwidget.ui \
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005/06 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * 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. *
+ ***************************************************************************/
+
+#include "topicbutton.h"
+
+
+#include <QDebug>
+
+#include <QApplication>
+#include <QPainter>
+#include <QHBoxLayout>
+#include <QFont>
+#include <QFontMetrics>
+
+#include "qtui.h"
+#include "message.h"
+
+TopicButton::TopicButton(QWidget *parent)
+ : QAbstractButton(parent),
+ _sizeHint(QSize())
+{
+}
+
+void TopicButton::paintEvent(QPaintEvent *event) {
+ Q_UNUSED(event);
+
+ QPainter painter(this);
+ QFontMetrics metrics(qApp->font());
+
+ QPoint topLeft = rect().topLeft();
+ int height = sizeHint().height();
+ int width = 0;
+ QRect drawRect;
+ QString textPart;
+ foreach(QTextLayout::FormatRange fr, styledText.formats) {
+ textPart = styledText.text.mid(fr.start, fr.length);
+ width = metrics.width(textPart);
+ drawRect = QRect(topLeft, QPoint(topLeft.x() + width, topLeft.y() + height));
+ // qDebug() << drawRect << textPart << width << fr.format.background();
+ painter.setPen(QPen(fr.format.foreground(), 0));
+ painter.setBackground(fr.format.background()); // no clue why this doesnt work properly o_O
+ painter.drawText(drawRect, Qt::AlignLeft|Qt::TextSingleLine, textPart);
+ topLeft.setX(topLeft.x() + width);
+ }
+}
+
+void TopicButton::setAndStyleText(const QString &text) {
+ styledText = QtUi::style()->styleString(Message::mircToInternal(text));
+ setText(styledText.text);
+
+ QFontMetrics metrics(qApp->font());
+ _sizeHint = metrics.boundingRect(styledText.text).size();
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005/06 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * 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. *
+ ***************************************************************************/
+
+#ifndef TOPICBUTTON_H
+#define TOPICBUTTON_H
+
+#include <QSize>
+#include <QAbstractButton>
+
+#include "uistyle.h"
+
+class TopicButton : public QAbstractButton {
+ Q_OBJECT
+
+public:
+ TopicButton(QWidget *parent = 0);
+
+ void setAndStyleText(const QString &text);
+
+protected:
+ virtual void paintEvent(QPaintEvent *event);
+ virtual inline QSize sizeHint() const { return _sizeHint; }
+
+private:
+ UiStyle::StyledText styledText;
+ QSize _sizeHint;
+};
+
+#endif
: QWidget(parent)
{
ui.setupUi(this);
+ ui.topicLineEdit->hide();
+ ui.topicLineEdit->installEventFilter(this);
+ ui.topicButton->show();
}
void TopicWidget::setTopic(const QString &newtopic) {
+ ui.topicButton->setAndStyleText(newtopic);
ui.topicLineEdit->setText(newtopic);
- ui.topicLineEdit->setCursorPosition(0);
+ switchPlain();
}
void TopicWidget::on_topicLineEdit_returnPressed() {
- ui.topicLineEdit->setCursorPosition(0);
+ switchPlain();
emit topicChanged(topic());
}
+
+void TopicWidget::on_topicButton_clicked() {
+ switchEditable();
+}
+
+void TopicWidget::switchEditable() {
+ ui.topicButton->hide();
+ ui.topicLineEdit->show();
+}
+
+void TopicWidget::switchPlain() {
+ ui.topicLineEdit->hide();
+ ui.topicButton->show();
+}
+
+bool TopicWidget::eventFilter(QObject *obj, QEvent *event) {
+ if(event->type() != QEvent::KeyPress)
+ return QObject::eventFilter(obj, event);
+
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+
+ if(keyEvent->key() == Qt::Key_Escape) {
+ switchPlain();
+ return true;
+ }
+
+ return false;
+}
Q_OBJECT
Q_PROPERTY(QString topic READ topic WRITE setTopic STORED false)
- public:
- TopicWidget(QWidget *parent = 0);
-
- inline QString topic() const { return ui.topicLineEdit->text(); }
- void setTopic(const QString &newtopic);
-
- signals:
- void topicChanged(const QString &text);
-
- private slots:
- void on_topicLineEdit_returnPressed();
+public:
+ TopicWidget(QWidget *parent = 0);
+
+ inline QString topic() const { return ui.topicLineEdit->text(); }
+ void setTopic(const QString &newtopic);
+
+ virtual bool eventFilter(QObject *obj, QEvent *event);
+
+signals:
+ void topicChanged(const QString &text);
+
+private slots:
+ void on_topicLineEdit_returnPressed();
+ void on_topicButton_clicked();
+ void switchEditable();
+ void switchPlain();
- private:
- Ui::TopicWidget ui;
+private:
+ Ui::TopicWidget ui;
};
<rect>
<x>0</x>
<y>0</y>
- <width>558</width>
- <height>29</height>
+ <width>458</width>
+ <height>28</height>
</rect>
</property>
<property name="sizePolicy" >
</property>
<layout class="QHBoxLayout" >
<property name="leftMargin" >
- <number>0</number>
+ <number>2</number>
</property>
<property name="topMargin" >
- <number>0</number>
+ <number>2</number>
</property>
<property name="rightMargin" >
- <number>0</number>
+ <number>2</number>
</property>
<property name="bottomMargin" >
- <number>0</number>
+ <number>2</number>
</property>
<item>
<widget class="QLineEdit" name="topicLineEdit" />
</item>
+ <item>
+ <widget class="TopicButton" native="1" name="topicButton" />
+ </item>
<item>
<widget class="QToolButton" name="topicEditButton" >
<property name="enabled" >
<string>...</string>
</property>
<property name="icon" >
- <iconset resource="../../icons/icons.qrc" >:/22x22/actions/oxygen/22x22/actions/configure.png</iconset>
+ <iconset/>
</property>
<property name="iconSize" >
<size>
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>TopicButton</class>
+ <extends>QWidget</extends>
+ <header location="global" >topicbutton.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
<resources>
<include location="../../icons/icons.qrc" />
</resources>
{ using namespace Global;
quasselVersion = "0.2.0-alpha3-pre";
- quasselDate = "2008-03-09";
- quasselBuild = 622;
+ quasselDate = "2008-03-10";
+ quasselBuild = 624;
//! Minimum client build number the core needs
clientBuildNeeded = 620;