From 01ef1fbf218fffbde24b36d41f9489bdba9ec6d0 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Fri, 14 Dec 2007 18:12:37 +0000 Subject: [PATCH] Make the chatwidget remember column sizes. This should make EgS happy :) --- src/qtui/chatwidget.cpp | 14 +++++++--- src/qtui/guisettings.cpp | 7 +++++ src/uisupport/uisettings.cpp | 34 ++++++++++++++++++++++++ src/uisupport/uisettings.h | 50 ++++++++++++++++++++++++++++++++++++ src/uisupport/uisupport.pri | 4 +-- 5 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 src/uisupport/uisettings.cpp create mode 100644 src/uisupport/uisettings.h diff --git a/src/qtui/chatwidget.cpp b/src/qtui/chatwidget.cpp index b0a06e3f..b44e90c1 100644 --- a/src/qtui/chatwidget.cpp +++ b/src/qtui/chatwidget.cpp @@ -22,7 +22,7 @@ #include "chatwidget.h" #include "chatline-old.h" #include "qtui.h" - +#include "uisettings.h" ChatWidget::ChatWidget(QWidget *parent) : QAbstractScrollArea(parent) { //setAutoFillBackground(false); @@ -50,8 +50,11 @@ void ChatWidget::init(QString netname, QString bufname) { bufferName = bufname; setBackgroundRole(QPalette::Base); setFont(QFont("Fixed")); - tsWidth = 90; - senderWidth = 100; + UiSettings s; + QVariant tsDef = s.value("DefaultTimestampColumnWidth", 90); + QVariant senderDef = s.value("DefaultSenderColumnWidth", 100); + tsWidth = s.value(QString("%1/%2/TimestampColumnWidth").arg(netname, bufname), tsDef).toInt(); + senderWidth = s.value(QString("%1/%2/SenderColumnWidth").arg(netname, bufname), senderDef).toInt(); computePositions(); adjustScrollBar(); verticalScrollBar()->setValue(verticalScrollBar()->maximum()); @@ -72,6 +75,11 @@ ChatWidget::~ChatWidget() { //foreach(ChatLine *l, lines) { // delete l; //} + UiSettings s; + s.setValue("DefaultTimestampColumnWidth", tsWidth); // FIXME stupid dirty quicky + s.setValue("DefaultSenderColumnWidth", senderWidth); + s.setValue(QString("%1/%2/TimestampColumnWidth").arg(networkName, bufferName), tsWidth); + s.setValue(QString("%1/%2/SenderColumnWidth").arg(networkName, bufferName), senderWidth); } QSize ChatWidget::sizeHint() const { diff --git a/src/qtui/guisettings.cpp b/src/qtui/guisettings.cpp index c647d6fa..af384271 100644 --- a/src/qtui/guisettings.cpp +++ b/src/qtui/guisettings.cpp @@ -17,3 +17,10 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + +#include "guisettings.h" + +GuiSettings::GuiSettings() : ClientSettings("GUI") { + + +} diff --git a/src/uisupport/uisettings.cpp b/src/uisupport/uisettings.cpp new file mode 100644 index 00000000..2851644b --- /dev/null +++ b/src/uisupport/uisettings.cpp @@ -0,0 +1,34 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by the Quassel IRC Team * + * 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 "uisettings.h" + +UiSettings::UiSettings() : ClientSettings("UI") { + + +} + +void UiSettings::setValue(const QString &key, const QVariant &data) { + setLocalValue(key, data); +} + +QVariant UiSettings::value(const QString &key, const QVariant &def) { + return localValue(key, def); +} diff --git a/src/uisupport/uisettings.h b/src/uisupport/uisettings.h new file mode 100644 index 00000000..282190d5 --- /dev/null +++ b/src/uisupport/uisettings.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by the Quassel IRC Team * + * 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 _UISETTINGS_H_ +#define _UISETTINGS_H_ + +#include "clientsettings.h" + +class UiSettings : public ClientSettings { + + public: + UiSettings(); + + void setValue(const QString &key, const QVariant &data); + QVariant value(const QString &key, const QVariant &def = QVariant()); + + +}; + +/* +class GuiProfile : public ClientSettings { + + public: + GuiProfile(); + + static QStringList availableProfiles(); + static GuiProfile *profile(QString name); + + + +}; +*/ +#endif diff --git a/src/uisupport/uisupport.pri b/src/uisupport/uisupport.pri index 9ed33098..0a8cb817 100644 --- a/src/uisupport/uisupport.pri +++ b/src/uisupport/uisupport.pri @@ -1,8 +1,8 @@ DEPMOD = common client QT_MOD = core gui network -SRCS += bufferview.cpp bufferviewfilter.cpp inputline.cpp nickview.cpp tabcompleter.cpp uistyle.cpp -HDRS += bufferview.h bufferviewfilter.h inputline.h nickview.h tabcompleter.h uistyle.h +SRCS += bufferview.cpp bufferviewfilter.cpp inputline.cpp nickview.cpp tabcompleter.cpp uisettings.cpp uistyle.cpp +HDRS += bufferview.h bufferviewfilter.h inputline.h nickview.h tabcompleter.h uisettings.h uistyle.h FORMNAMES = -- 2.20.1