From c5c74323b6d8f3fc6775ca1d08cb84c602bac58d Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Tue, 26 Aug 2008 20:18:17 +0200 Subject: [PATCH] some fixes regarding issues with dark themes --- src/client/buffermodel.cpp | 15 +++++++++++++++ src/client/buffermodel.h | 4 +++- src/qtui/chatline.cpp | 14 +++++++------- src/qtui/chatscene.cpp | 7 +++++-- src/qtui/columnhandleitem.cpp | 19 ++++++++++++------- src/qtui/qtuistyle.h | 22 +++++++++++----------- src/qtui/topiclabel.cpp | 2 +- 7 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index faf6090f..9c8df06f 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -71,6 +71,21 @@ void BufferModel::switchToBuffer(const BufferId &bufferId) { setCurrentIndex(mapFromSource(source_index)); } +void BufferModel::switchToBufferIndex(const QModelIndex &bufferIdx) { + // we accept indexes that directly belong to us or our parent - nothing else + if(bufferIdx.model() == this) { + setCurrentIndex(bufferIdx); + return; + } + + if(bufferIdx.model() == sourceModel()) { + setCurrentIndex(mapFromSource(bufferIdx)); + return; + } + + qWarning() << "BufferModel::switchToBufferIndex(const QModelIndex &):" << bufferIdx << "does not belong to BufferModel or NetworkModel"; +} + void BufferModel::debug_currentChanged(QModelIndex current, QModelIndex previous) { Q_UNUSED(previous); qDebug() << "Switched current Buffer: " << current << current.data().toString() << "Buffer:" << current.data(NetworkModel::BufferIdRole).value(); diff --git a/src/client/buffermodel.h b/src/client/buffermodel.h index 7c00ea4f..37f8916c 100644 --- a/src/client/buffermodel.h +++ b/src/client/buffermodel.h @@ -45,10 +45,12 @@ public: void synchronizeSelectionModel(MappedSelectionModel *selectionModel); void synchronizeView(QAbstractItemView *view); -public slots: inline QModelIndex currentIndex() { return standardSelectionModel()->currentIndex(); } + +public slots: void setCurrentIndex(const QModelIndex &newCurrent); void switchToBuffer(const BufferId &bufferId); + void switchToBufferIndex(const QModelIndex &bufferIdx); private slots: void debug_currentChanged(QModelIndex current, QModelIndex previous); diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index a28f4e84..e55ab14f 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -68,15 +68,15 @@ ChatItem &ChatLine::item(ChatLineModel::ColumnType column) { qreal ChatLine::setGeometry(qreal width, qreal firstHandlePos, qreal secondHandlePos) { if(width != _width) prepareGeometryChange(); - qreal firstsep = QtUi::style()->firstColumnSeparator()/2; - qreal secondsep = QtUi::style()->secondColumnSeparator()/2; + qreal firstSepWidth = QtUi::style()->firstColumnSeparator(); + qreal secondSepWidth = QtUi::style()->secondColumnSeparator(); - _height = _contentsItem.setGeometry(width - secondHandlePos - secondsep); - _timestampItem.setGeometry(firstHandlePos - firstsep, _height); - _senderItem.setGeometry(secondHandlePos - firstHandlePos - (firstsep+secondsep), _height); + _height = _contentsItem.setGeometry(width - secondHandlePos - secondSepWidth); + _timestampItem.setGeometry(firstHandlePos, _height); + _senderItem.setGeometry(secondHandlePos - firstHandlePos - firstSepWidth, _height); - _senderItem.setPos(firstHandlePos + firstsep, 0); - _contentsItem.setPos(secondHandlePos + secondsep, 0); + _senderItem.setPos(firstHandlePos + firstSepWidth, 0); + _contentsItem.setPos(secondHandlePos + secondSepWidth, 0); _width = width; return _height; diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 3b01d0df..488a91d6 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -75,8 +75,11 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, QObject secondColHandlePos = s.value(QString("ChatView/%1/SecondColumnHandlePos").arg(_idString), defaultSecondColHandlePos).toInt(); - firstColHandle = new ColumnHandleItem(QtUi::style()->firstColumnSeparator()); addItem(firstColHandle); - secondColHandle = new ColumnHandleItem(QtUi::style()->secondColumnSeparator()); addItem(secondColHandle); + firstColHandle = new ColumnHandleItem(QtUi::style()->firstColumnSeparator()); + addItem(firstColHandle); + + secondColHandle = new ColumnHandleItem(QtUi::style()->secondColumnSeparator()); + addItem(secondColHandle); connect(firstColHandle, SIGNAL(positionChanged(qreal)), this, SLOT(handlePositionChanged(qreal))); connect(secondColHandle, SIGNAL(positionChanged(qreal)), this, SLOT(handlePositionChanged(qreal))); diff --git a/src/qtui/columnhandleitem.cpp b/src/qtui/columnhandleitem.cpp index c9e09ce0..8f1f9a2e 100644 --- a/src/qtui/columnhandleitem.cpp +++ b/src/qtui/columnhandleitem.cpp @@ -18,12 +18,14 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "columnhandleitem.h" + +#include #include #include #include #include - -#include "columnhandleitem.h" +#include ColumnHandleItem::ColumnHandleItem(qreal w, QGraphicsItem *parent) : QGraphicsItem(parent), @@ -42,7 +44,7 @@ ColumnHandleItem::ColumnHandleItem(qreal w, QGraphicsItem *parent) } void ColumnHandleItem::setXPos(qreal xpos) { - setPos(xpos - width()/2, 0); + setPos(xpos, 0); } void ColumnHandleItem::setXLimits(qreal min, qreal max) { @@ -85,7 +87,7 @@ void ColumnHandleItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if(_moving) { _moving = false; setCursor(QCursor(Qt::OpenHandCursor)); - emit positionChanged(x() + width()/2); + emit positionChanged(x()); event->accept(); } else { event->ignore(); @@ -118,9 +120,12 @@ void ColumnHandleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * Q_UNUSED(widget); QLinearGradient gradient(0, 0, width(), 0); - gradient.setColorAt(0.25, Qt::transparent); - gradient.setColorAt(0.5, QColor(0, 0, 0, _hover * 200)); - gradient.setColorAt(0.75, Qt::transparent); + QColor rulerColor = QApplication::palette().windowText().color(); + rulerColor.setAlphaF(_hover); + gradient.setColorAt(0, Qt::transparent); + gradient.setColorAt(0.4, rulerColor); + gradient.setColorAt(0.6, rulerColor); + gradient.setColorAt(1, Qt::transparent); painter->fillRect(boundingRect(), gradient); } diff --git a/src/qtui/qtuistyle.h b/src/qtui/qtuistyle.h index 8db31824..d3276f16 100644 --- a/src/qtui/qtuistyle.h +++ b/src/qtui/qtuistyle.h @@ -18,24 +18,24 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _QTUISTYLE_H_ -#define _QTUISTYLE_H_ +#ifndef QTUISTYLE_H_ +#define QTUISTYLE_H_ #include "uistyle.h" class QtUiStyle : public UiStyle { - public: - QtUiStyle(); - virtual ~QtUiStyle(); +public: + QtUiStyle(); + virtual ~QtUiStyle(); - virtual inline qreal firstColumnSeparator() const { return 10; } - virtual inline qreal secondColumnSeparator() const { return 10; } - virtual inline QColor highlightColor() const { return _highlightColor; } - virtual void setHighlightColor(const QColor &); + virtual inline qreal firstColumnSeparator() const { return 6; } + virtual inline qreal secondColumnSeparator() const { return 6; } + virtual inline QColor highlightColor() const { return _highlightColor; } + virtual void setHighlightColor(const QColor &); - private: - QColor _highlightColor; +private: + QColor _highlightColor; }; #endif diff --git a/src/qtui/topiclabel.cpp b/src/qtui/topiclabel.cpp index d3a01778..b41f7365 100644 --- a/src/qtui/topiclabel.cpp +++ b/src/qtui/topiclabel.cpp @@ -77,7 +77,7 @@ void TopicLabel::setText(const QString &text) { offset = 0; update(); - UiStyle::StyledString styledContents = QtUi::style()->styleString(QtUi::style()->mircToInternal(text)); + UiStyle::StyledString styledContents = QtUi::style()->styleString("%D0" + QtUi::style()->mircToInternal(text)); plainText = styledContents.plainText; formatList = QtUi::style()->toTextLayoutList(styledContents.formatList, plainText.length()); int height = 1; -- 2.20.1