some fixes regarding issues with dark themes
authorMarcus Eggenberger <egs@quassel-irc.org>
Tue, 26 Aug 2008 18:18:17 +0000 (20:18 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Tue, 26 Aug 2008 18:18:17 +0000 (20:18 +0200)
src/client/buffermodel.cpp
src/client/buffermodel.h
src/qtui/chatline.cpp
src/qtui/chatscene.cpp
src/qtui/columnhandleitem.cpp
src/qtui/qtuistyle.h
src/qtui/topiclabel.cpp

index faf6090..9c8df06 100644 (file)
@@ -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<BufferId>();
index 7c00ea4..37f8916 100644 (file)
@@ -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);
index a28f4e8..e55ab14 100644 (file)
@@ -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;
index 3b01d0d..488a91d 100644 (file)
@@ -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)));
index c9e09ce..8f1f9a2 100644 (file)
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
 
+#include "columnhandleitem.h"
+
+#include <QApplication>
 #include <QCursor>
 #include <QGraphicsScene>
 #include <QGraphicsSceneHoverEvent>
 #include <QPainter>
-
-#include "columnhandleitem.h"
+#include <QPalette>
 
 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);
 }
 
index 8db3182..d3276f1 100644 (file)
  *   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
index d3a0177..b41f736 100644 (file)
@@ -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;