X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;h=a0d9be3b047085cb0e6f2ce0dd48afada5b82bc2;hb=2fabb938a014186c2aa7aa1a1b885c6afa353f1e;hp=2a065d76a267fa5743faeac5e12f22687fcb74ca;hpb=d30eb5039971db578ba6e777d737344187e5b02a;p=quassel.git diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 2a065d76..a0d9be3b 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 by the Quassel Project * + * Copyright (C) 2005-2015 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -23,13 +23,14 @@ #include #include #include +#include #include #include #include #include #include -#ifdef HAVE_KDE +#ifdef HAVE_KDE4 # include #else # include @@ -48,7 +49,6 @@ #include "clientbacklogmanager.h" #include "columnhandleitem.h" #include "contextmenuactionprovider.h" -#include "iconloader.h" #include "mainwin.h" #include "markerlineitem.h" #include "messagefilter.h" @@ -89,12 +89,12 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w connect(this, SIGNAL(sceneRectChanged(const QRectF &)), _markerLine, SLOT(sceneRectChanged(const QRectF &))); ChatViewSettings defaultSettings; - int defaultFirstColHandlePos = defaultSettings.value("FirstColumnHandlePos", 80).toInt(); - int defaultSecondColHandlePos = defaultSettings.value("SecondColumnHandlePos", 200).toInt(); + _defaultFirstColHandlePos = defaultSettings.value("FirstColumnHandlePos", 80).toInt(); + _defaultSecondColHandlePos = defaultSettings.value("SecondColumnHandlePos", 200).toInt(); ChatViewSettings viewSettings(this); - _firstColHandlePos = viewSettings.value("FirstColumnHandlePos", defaultFirstColHandlePos).toInt(); - _secondColHandlePos = viewSettings.value("SecondColumnHandlePos", defaultSecondColHandlePos).toInt(); + _firstColHandlePos = viewSettings.value("FirstColumnHandlePos", _defaultFirstColHandlePos).toInt(); + _secondColHandlePos = viewSettings.value("SecondColumnHandlePos", _defaultSecondColHandlePos).toInt(); _firstColHandle = new ColumnHandleItem(QtUi::style()->firstColumnSeparator()); addItem(_firstColHandle); @@ -159,6 +159,17 @@ ColumnHandleItem *ChatScene::secondColumnHandle() const return _secondColHandle; } +void ChatScene::resetColumnWidths() +{ + //make sure first column is at least 80 px wide, second 120 px + int firstColHandlePos = qMax(_defaultFirstColHandlePos, + 80); + int secondColHandlePos = qMax(_defaultSecondColHandlePos, + firstColHandlePos + 120); + + _firstColHandle->setXPos(firstColHandlePos); + _secondColHandle->setXPos(secondColHandlePos); +} ChatLine *ChatScene::chatLine(MsgId msgId, bool matchExact, bool ignoreDayChange) const { @@ -812,21 +823,26 @@ void ChatScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) // If we have text selected, insert the Copy Selection as first item if (isPosOverSelection(pos)) { QAction *sep = menu.insertSeparator(menu.actions().first()); - QAction *act = new Action(SmallIcon("edit-copy"), tr("Copy Selection"), &menu, this, + QAction *act = new Action(QIcon::fromTheme("edit-copy"), tr("Copy Selection"), &menu, this, SLOT(selectionToClipboard()), QKeySequence::Copy); menu.insertAction(sep, act); QString searchSelectionText = selection(); if (searchSelectionText.length() > _webSearchSelectionTextMaxVisible) - searchSelectionText = searchSelectionText.left(_webSearchSelectionTextMaxVisible).append(QString::fromUtf8("\u2026")); + searchSelectionText = searchSelectionText.left(_webSearchSelectionTextMaxVisible).append(QString::fromUtf8("…")); searchSelectionText = tr("Search '%1'").arg(searchSelectionText); - menu.addAction(SmallIcon("zoom-in"), searchSelectionText, this, SLOT(webSearchOnSelection())); + menu.addAction(QIcon::fromTheme("edit-find"), searchSelectionText, this, SLOT(webSearchOnSelection())); } if (QtUi::mainWindow()->menuBar()->isHidden()) menu.addAction(QtUi::actionCollection("General")->action("ToggleMenuBar")); + // show column reset action if columns have been resized in this session or there is at least one very narrow column + if ((_firstColHandlePos != _defaultFirstColHandlePos) || (_secondColHandlePos != _defaultSecondColHandlePos) || + (_firstColHandlePos <= 10) || (_secondColHandlePos - _firstColHandlePos <= 10)) + menu.addAction(new Action(tr("Reset Column Widths"), &menu, this, SLOT(resetColumnWidths()), 0)); + menu.exec(event->screenPos()); }