Changed the QFrame of QScrollArea on Settings to noFrame

Added Search and Marker Feature for the Chat Widget, thx to Phenom for the Patch (AddSearchAndMarkerOnChatWidget_v0.6_7377.patch)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7380 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2014-05-26 21:51:53 +00:00
parent b7f794c37d
commit f93d41991e
10 changed files with 1074 additions and 205 deletions

View file

@ -14,6 +14,9 @@
<string notr="true">MainWindow</string> <string notr="true">MainWindow</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>

View file

@ -71,12 +71,41 @@ ChatWidget::ChatWidget(QWidget *parent) :
peerStatus = 0; peerStatus = 0;
mChatType = CHATTYPE_UNKNOWN; mChatType = CHATTYPE_UNKNOWN;
firstShow = true; firstShow = true;
firstSearch = true;
inChatCharFormatChanged = false; inChatCharFormatChanged = false;
completer = NULL; completer = NULL;
lastMsgDate = QDate::currentDate(); lastMsgDate = QDate::currentDate();
lastStatusSendTime = 0 ; lastStatusSendTime = 0 ;
iCharToStartSearch=Settings->getChatSearchCharToStartSearch();
bFindCaseSensitively=Settings->getChatSearchCaseSensitively();
bFindWholeWords=Settings->getChatSearchWholeWords();
bMoveToCursor=Settings->getChatSearchMoveToCursor();
bSearchWithoutLimit=Settings->getChatSearchSearchWithoutLimit();
uiMaxSearchLimitColor=Settings->getChatSearchMaxSearchLimitColor();
cFoundColor=Settings->getChatSearchFoundColor();
ui->actionSearchWithoutLimit->setText(tr("Don't stop to color after ")+QString::number(uiMaxSearchLimitColor)+tr(" items found (need more CPU)"));
ui->leSearch->setVisible(false);
ui->searchBefore->setVisible(false);
ui->searchBefore->setToolTip(tr("<b>Find Previous </b><br/><i>Ctrl+Shift+G</i>"));
ui->searchAfter->setVisible(false);
ui->searchAfter->setToolTip(tr("<b>Find Next </b><br/><i>Ctrl+G</i>"));
ui->searchButton->setCheckable(true);
ui->searchButton->setChecked(false);
ui->searchButton->setToolTip(tr("<b>Find </b><br/><i>Ctrl+F</i>"));
ui->leSearch->installEventFilter(this);
connect(ui->actionFindCaseSensitively, SIGNAL(triggered()), this, SLOT(toogle_FindCaseSensitively()));
connect(ui->actionFindWholeWords, SIGNAL(triggered()), this, SLOT(toogle_FindWholeWords()));
connect(ui->actionMoveToCursor, SIGNAL(triggered()), this, SLOT(toogle_MoveToCursor()));
connect(ui->actionSearchWithoutLimit, SIGNAL(triggered()), this, SLOT(toogle_SeachWithoutLimit()));
connect(ui->searchButton, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuSearchButton(QPoint)));
ui->markButton->setToolTip(tr("<b>Mark this selected text</b><br><i>Ctr+M</i>"));
connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendChat())); connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendChat()));
connect(ui->addFileButton, SIGNAL(clicked()), this , SLOT(addExtraFile())); connect(ui->addFileButton, SIGNAL(clicked()), this , SLOT(addExtraFile()));
@ -125,6 +154,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
ui->pushtoolsButton->setMenu(menu); ui->pushtoolsButton->setMenu(menu);
ui->chatTextEdit->installEventFilter(this); ui->chatTextEdit->installEventFilter(this);
ui->textBrowser->installEventFilter(this);
#if QT_VERSION < 0x040700 #if QT_VERSION < 0x040700
// embedded images are not supported before QT 4.7.0 // embedded images are not supported before QT 4.7.0
@ -292,6 +322,51 @@ void ChatWidget::processSettings(bool load)
bool ChatWidget::eventFilter(QObject *obj, QEvent *event) bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
{ {
if (obj == ui->textBrowser || obj == ui->leSearch || obj == ui->chatTextEdit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent) {
if (keyEvent->key() == Qt::Key_F && keyEvent->modifiers() == Qt::ControlModifier)
{
bool bTextselected=false;
if (obj == ui->textBrowser )
{
if (ui->textBrowser->textCursor().selectedText().length()>0)
{
ui->leSearch->setText(ui->textBrowser->textCursor().selectedText());
bTextselected=true;
}
}
if (obj == ui->chatTextEdit)
{
if (ui->chatTextEdit->textCursor().selectedText().length()>0)
{
ui->leSearch->setText(ui->chatTextEdit->textCursor().selectedText());
bTextselected=true;
}
}
ui->searchButton->setChecked(!ui->searchButton->isChecked() | bTextselected);
ui->leSearch->setVisible(bTextselected);//To discard re-selection of text
on_searchButton_clicked(ui->searchButton->isChecked());
return true; // eat event
}
if (keyEvent->key() == Qt::Key_G && keyEvent->modifiers() == Qt::ControlModifier)
{
if (ui->searchAfter->isVisible())
on_searchAfter_clicked();
return true; // eat event
}
if (keyEvent->key() == Qt::Key_G && keyEvent->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
{
if (ui->searchBefore->isVisible())
on_searchBefore_clicked();
return true; // eat event
}
}
}
}
if (obj == ui->textBrowser) { if (obj == ui->textBrowser) {
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {
@ -303,6 +378,10 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
ui->textBrowser->textCursor().deleteChar(); ui->textBrowser->textCursor().deleteChar();
} }
if (keyEvent->key() == Qt::Key_M && keyEvent->modifiers() == Qt::ControlModifier)
{
on_markButton_clicked(!ui->markButton->isChecked());
}
} }
} }
} else if (obj == ui->chatTextEdit) { } else if (obj == ui->chatTextEdit) {
@ -351,6 +430,27 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
} }
} }
} }
} else if (obj == ui->leSearch) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent) {
QString qsTextToFind=ui->leSearch->text();
if (((qsTextToFind.length()>iCharToStartSearch) || (keyEvent->key()==Qt::Key_Return)) && (keyEvent->text().length()>0))
{
if (keyEvent->key()==Qt::Key_Backspace) {
qsTextToFind=qsTextToFind.left(qsTextToFind.length()-1);// "\010"
} else if (keyEvent->key()==Qt::Key_Tab) { // "\011"
} else if (keyEvent->key()==Qt::Key_Return) { // "\015"
} else if (keyEvent->text().length()==1)
qsTextToFind+=keyEvent->text();
findText(qsTextToFind);
} else {
ui->leSearch->setPalette(qpSave_leSearch);
}
}
}
} else { } else {
if (event->type() == QEvent::WindowActivate) { if (event->type() == QEvent::WindowActivate) {
if (isVisible() && (window() == NULL || window()->isActiveWindow())) { if (isVisible() && (window() == NULL || window()->isActiveWindow())) {
@ -627,6 +727,11 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
ui->textBrowser->textCursor().setBlockFormat(QTextBlockFormat ()); ui->textBrowser->textCursor().setBlockFormat(QTextBlockFormat ());
ui->textBrowser->append(formatMsg); ui->textBrowser->append(formatMsg);
if (ui->leSearch->isVisible()) {
QString qsTextToFind=ui->leSearch->text();
findText(qsTextToFind);
}
resetStatusBar(); resetStatusBar();
if (incoming && chatType == MSGTYPE_NORMAL) { if (incoming && chatType == MSGTYPE_NORMAL) {
@ -675,6 +780,24 @@ void ChatWidget::contextMenuTextBrowser(QPoint point)
delete(contextMnu); delete(contextMnu);
} }
void ChatWidget::contextMenuSearchButton(QPoint /*point*/)
{
QMenu *contextMnu = new QMenu;
contextMnu->addSeparator();
ui->actionFindCaseSensitively->setChecked(bFindCaseSensitively);
contextMnu->addAction(ui->actionFindCaseSensitively);
ui->actionFindWholeWords->setChecked(bFindWholeWords);
contextMnu->addAction(ui->actionFindWholeWords);
ui->actionMoveToCursor->setChecked(bMoveToCursor);
contextMnu->addAction(ui->actionMoveToCursor);
ui->actionSearchWithoutLimit->setChecked(bSearchWithoutLimit);
contextMnu->addAction(ui->actionSearchWithoutLimit);
contextMnu->exec(QCursor::pos());
delete(contextMnu);
}
void ChatWidget::chatCharFormatChanged() void ChatWidget::chatCharFormatChanged()
{ {
if (inChatCharFormatChanged) { if (inChatCharFormatChanged) {
@ -753,6 +876,202 @@ void ChatWidget::on_closeInfoFrameButton_clicked()
ui->infoFrame->setVisible(false); ui->infoFrame->setVisible(false);
} }
void ChatWidget::on_searchButton_clicked(bool bValue)
{
if (firstSearch)
qpSave_leSearch=ui->leSearch->palette();
removeFoundText();
ui->searchBefore->setVisible(false);//findText set it to true
ui->searchAfter->setVisible(false);//findText set it to true
ui->leSearch->setPalette(qpSave_leSearch);
if (bValue) {
ui->leSearch->setFocus();
if (!ui->leSearch->isVisible()){//Take text selected if leSearch is Invisible
if (ui->textBrowser->textCursor().selectedText().length()>0) {
ui->leSearch->setText(ui->textBrowser->textCursor().selectedText());
findText(ui->leSearch->text());
} else if(ui->chatTextEdit->textCursor().selectedText().length()>0) {
ui->leSearch->setText(ui->chatTextEdit->textCursor().selectedText());
findText(ui->leSearch->text());
}
}
if (!ui->leSearch->text().isEmpty())
findText(ui->leSearch->text());
} else {
//Erase last result Cursor
QTextDocument *qtdDocument = ui->textBrowser->document();
qtcCurrent=QTextCursor(qtdDocument);
}
ui->leSearch->setVisible(bValue);
}
void ChatWidget::on_searchBefore_clicked()
{
findText(ui->leSearch->text(),true,true);
}
void ChatWidget::on_searchAfter_clicked()
{
findText(ui->leSearch->text(),false,true);
}
void ChatWidget::toogle_FindCaseSensitively()
{
bFindCaseSensitively=!bFindCaseSensitively;
}
void ChatWidget::toogle_FindWholeWords()
{
bFindWholeWords=!bFindWholeWords;
}
void ChatWidget::toogle_MoveToCursor()
{
bMoveToCursor=!bMoveToCursor;
}
void ChatWidget::toogle_SeachWithoutLimit()
{
bSearchWithoutLimit=!bSearchWithoutLimit;
}
bool ChatWidget::findText(const QString& qsStringToFind)
{
return findText(qsStringToFind, false,false);
}
bool ChatWidget::findText(const QString& qsStringToFind, bool bBackWard, bool bForceMove)
{
QTextDocument *qtdDocument = ui->textBrowser->document();
bool bFound = false;
bool bFirstFound = true;
uint uiFoundCount = 0;
removeFoundText();
if (qsLastsearchText!=qsStringToFind)
qtcCurrent=QTextCursor(qtdDocument);
qsLastsearchText=qsStringToFind;
if (!qsStringToFind.isEmpty())
{
QPalette qpBackGround=ui->leSearch->palette();
QTextCursor qtcHighLight(qtdDocument);
QTextCursor qtcCursor(qtdDocument);
QTextCharFormat qtcfPlainFormat(qtcHighLight.charFormat());
QTextCharFormat qtcfColorFormat = qtcfPlainFormat;
qtcfColorFormat.setBackground(QBrush(cFoundColor));
if (ui->textBrowser->textCursor().selectedText().length()>0)
qtcCurrent=ui->textBrowser->textCursor();
if (bBackWard) qtcHighLight.setPosition(qtdDocument->characterCount()-1);
qtcCursor.beginEditBlock();
while(!qtcHighLight.isNull()
&& ( (!bBackWard && !qtcHighLight.atEnd())
|| (bBackWard && !qtcHighLight.atStart())
))
{
QTextDocument::FindFlags qtdFindFlag;
if (bFindCaseSensitively) qtdFindFlag|=QTextDocument::FindCaseSensitively;
if (bFindWholeWords) qtdFindFlag|=QTextDocument::FindWholeWords;
if (bBackWard) qtdFindFlag|=QTextDocument::FindBackward;
qtcHighLight=qtdDocument->find(qsStringToFind,qtcHighLight, qtdFindFlag);
if(!qtcHighLight.isNull())
{
bFound=true;
if (!bFirstFound)
{
if (smFoundCursor.size()<uiMaxSearchLimitColor || bSearchWithoutLimit)// stop after uiMaxSearchLimitColor
{
QTextCharFormat qtcfSave= qtcHighLight.charFormat();
smFoundCursor[qtcHighLight]=qtcfSave;
qtcHighLight.mergeCharFormat(qtcfColorFormat);
}
}
if (bFirstFound &&
((bBackWard && (qtcHighLight.position()<qtcCurrent.position()))
|| (!bBackWard && (qtcHighLight.position()>qtcCurrent.position()))
))
{
bFirstFound=false;
qtcCurrent=qtcHighLight;
if (bMoveToCursor || bForceMove) ui->textBrowser->setTextCursor(qtcHighLight);
}//if (bFirstFound && (qtcHighLight.position()>qtcCurrent.position()))
if (uiFoundCount<UINT_MAX)
uiFoundCount+=1;
}//if(!qtcHighLight.isNull())
}//while(!qtcHighLight.isNull() && !qtcHighLight.atEnd())
if (bFound)
{
qpBackGround.setColor(QPalette::Base,QColor(0,200,0));
ui->leSearch->setToolTip(QString::number(uiFoundCount)+tr(" founded items."));
} else {
qpBackGround.setColor(QPalette::Base,QColor(200,0,0));
ui->leSearch->setToolTip(tr("No items founded."));
}
ui->leSearch->setPalette(qpBackGround);
qtcCursor.endEditBlock();
ui->searchBefore->setVisible((!bFirstFound || (!bBackWard && bFound)));
ui->searchAfter->setVisible((!bFirstFound || (bBackWard && bFound)));
firstSearch = false;
} else { //if (!qsStringToFind.isEmpty())
ui->leSearch->setPalette(qpSave_leSearch);
}
return bFound;
}
void ChatWidget::removeFoundText()
{
for(std::map<QTextCursor,QTextCharFormat>::const_iterator it=smFoundCursor.begin();it!=smFoundCursor.end();++it)
{
QTextCursor qtcCurrent=it->first;
QTextCharFormat qtcfCurrent=it->second;
qtcCurrent.setCharFormat(qtcfCurrent);
}
smFoundCursor.clear();
}
void ChatWidget::on_markButton_clicked(bool bValue)
{
if (bValue)
{
if (ui->textBrowser->textCursor().selectedText().length()>0)
{
qtcMark=ui->textBrowser->textCursor();
ui->markButton->setToolTip(tr("<b>Return to marked text</b><br><i>Ctr+M</i>"));
} else { bValue=false;}
} else {
if (qtcMark.position()!=0)
{
ui->textBrowser->setTextCursor(qtcMark);
qtcMark=QTextCursor(ui->textBrowser->document());
ui->markButton->setToolTip(tr("<b>Mark this selected text</b><br><i>Ctr+M</i>"));
}
}
ui->markButton->setChecked(bValue);
}
void ChatWidget::chooseColor() void ChatWidget::chooseColor()
{ {
bool ok; bool ok;
@ -828,6 +1147,8 @@ void ChatWidget::addSmiley()
void ChatWidget::clearChatHistory() void ChatWidget::clearChatHistory()
{ {
ui->textBrowser->clear(); ui->textBrowser->clear();
on_searchButton_clicked(false);
ui->markButton->setChecked(false);
} }
void ChatWidget::deleteChatHistory() void ChatWidget::deleteChatHistory()

View file

@ -22,23 +22,26 @@
#ifndef CHATWIDGET_H #ifndef CHATWIDGET_H
#define CHATWIDGET_H #define CHATWIDGET_H
#include <QWidget> #include <QWidget>
#include <QCompleter> #include <QCompleter>
#include "gui/common/HashBox.h" #include <QTextCursor>
#include "ChatStyle.h" #include <QTextCharFormat>
#include "gui/style/RSStyle.h" #include "gui/common/HashBox.h"
#include "ChatStyle.h"
#include "gui/style/RSStyle.h"
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
class QAction; class QAction;
class QTextEdit; class QTextEdit;
class QPushButton; class QPushButton;
class ChatWidget; class ChatWidget;
class QMenu;
namespace Ui {
class ChatWidget; namespace Ui {
class ChatWidget;
} }
// a Container for the logic behind buttons in a PopupChatDialog // a Container for the logic behind buttons in a PopupChatDialog
@ -120,22 +123,32 @@ protected:
virtual void showEvent(QShowEvent *event); virtual void showEvent(QShowEvent *event);
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
void updateTitle(); void updateTitle();
private slots: private slots:
void contextMenuTextBrowser(QPoint); void contextMenuTextBrowser(QPoint);
void chatCharFormatChanged(); void contextMenuSearchButton(QPoint);
void chatCharFormatChanged();
void fileHashingFinished(QList<HashedFile> hashedFiles);
void fileHashingFinished(QList<HashedFile> hashedFiles);
void smileyWidget(); void smileyWidget();
void addSmiley(); void addSmiley();
void addExtraFile(); void addExtraFile();
void addExtraPicture(); void addExtraPicture();
void on_closeInfoFrameButton_clicked(); void on_closeInfoFrameButton_clicked();
void on_searchButton_clicked(bool bValue);
void chooseColor(); void on_searchBefore_clicked();
void chooseFont(); void on_searchAfter_clicked();
void toogle_FindCaseSensitively();
void toogle_FindWholeWords();
void toogle_MoveToCursor();
void toogle_SeachWithoutLimit();
void on_markButton_clicked(bool bValue);
void chooseColor();
void chooseFont();
void resetFont(); void resetFont();
void setFont(); void setFont();
@ -144,12 +157,15 @@ private slots:
void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ; void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ;
bool fileSave(); bool fileSave();
bool fileSaveAs(); bool fileSaveAs();
private: private:
void updateStatusTyping(); bool findText(const QString& qsStringToFind);
void setCurrentFileName(const QString &fileName); bool findText(const QString& qsStringToFind, bool bBackWard, bool bForceMove);
void removeFoundText();
void updateStatusTyping();
void setCurrentFileName(const QString &fileName);
void colorChanged(); void colorChanged();
void fontChanged(); void fontChanged();
void setColorAndFont(); void setColorAndFont();
@ -178,12 +194,26 @@ private:
ChatStyle chatStyle; ChatStyle chatStyle;
RSStyle style; RSStyle style;
bool firstShow; bool firstShow;
bool inChatCharFormatChanged; bool inChatCharFormatChanged;
bool firstSearch;
TransferRequestFlags mDefaultExtraFileFlags ; // flags for extra files shared in this chat. Will be 0 by default, but might be ANONYMOUS for chat lobbies. QPalette qpSave_leSearch;
QDate lastMsgDate ; std::map<QTextCursor,QTextCharFormat> smFoundCursor;
int iCharToStartSearch;
bool bFindCaseSensitively;
bool bFindWholeWords;
bool bMoveToCursor;
bool bSearchWithoutLimit;
uint uiMaxSearchLimitColor;
QColor cFoundColor;
QString qsLastsearchText;
QTextCursor qtcCurrent;
QTextCursor qtcMark;
TransferRequestFlags mDefaultExtraFileFlags ; // flags for extra files shared in this chat. Will be 0 by default, but might be ANONYMOUS for chat lobbies.
QDate lastMsgDate ;
QCompleter *completer; QCompleter *completer;

View file

@ -15,12 +15,14 @@
<number>2</number> <number>2</number>
</property> </property>
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QVBoxLayout" name="titleLayout"> <layout class="QHBoxLayout" name="hTitleLayout">
<property name="spacing"> <item>
<number>3</number> <layout class="QVBoxLayout" name="titleLayout">
<property name="spacing">
<number>3</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>2</number> <number>2</number>
@ -60,12 +62,182 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QFrame" name="infoFrame"> <spacer>
<property name="palette"> <property name="orientation">
<palette> <enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>190</width>
<height>25</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="titleBarFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="hlTitleBarFrame">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QToolButton" name="markButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/highlight.png</normaloff>:/images/highlight.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LineEditClear" name="leSearch"/>
</item>
<item>
<widget class="QToolButton" name="searchBefore">
<property name="minimumSize">
<size>
<width>14</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>28</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/arrow-left.png</normaloff>:/images/arrow-left.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="searchAfter">
<property name="minimumSize">
<size>
<width>14</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>28</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/arrow-right.png</normaloff>:/images/arrow-right.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="searchButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/find.png</normaloff>:/images/find.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="infoFrame">
<property name="palette">
<palette>
<active> <active>
<colorrole role="Base"> <colorrole role="Base">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
@ -713,12 +885,53 @@ border-image: url(:/images/closepressed.png)
</action> </action>
<action name="actionResetFont"> <action name="actionResetFont">
<property name="text"> <property name="text">
<string>Reset font to default</string> <string>Reset font to default</string>
</property> </property>
</action> </action>
</widget> <action name="actionFindCaseSensitively">
<customwidgets> <property name="checkable">
<customwidget> <bool>true</bool>
</property>
<property name="text">
<string>Find Case Sensitively</string>
</property>
</action>
<action name="actionFindWholeWords">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Find Whole Words</string>
</property>
<property name="toolTip">
<string>Find Whole Words</string>
</property>
</action>
<action name="actionMoveToCursor">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Move To Cursor</string>
</property>
<property name="toolTip">
<string>Move To Cursor</string>
</property>
</action>
<action name="actionSearchWithoutLimit">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Don't stop to color after X items found (need more CPU)</string>
</property>
<property name="toolTip">
<string>WARNING: Could take long time on big history.</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>RSTextBrowser</class> <class>RSTextBrowser</class>
<extends>QTextBrowser</extends> <extends>QTextBrowser</extends>
<header>gui/common/RSTextBrowser.h</header> <header>gui/common/RSTextBrowser.h</header>
@ -731,12 +944,17 @@ border-image: url(:/images/closepressed.png)
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>MimeTextEdit</class> <class>MimeTextEdit</class>
<extends>QTextEdit</extends> <extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header> <header location="global">gui/common/MimeTextEdit.h</header>
</customwidget> </customwidget>
</customwidgets> <customwidget>
<resources> <class>LineEditClear</class>
<include location="../images.qrc"/> <extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View file

@ -19,6 +19,7 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <QColorDialog>
#include <QFontDialog> #include <QFontDialog>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
@ -166,6 +167,14 @@ ChatPage::save(QString &/*errmsg*/)
Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked()); Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked());
Settings->setChatSearchCharToStartSearch(ui.sbSearch_CharToStart->value());
Settings->setChatSearchCaseSensitively(ui.cbSearch_CaseSensitively->isChecked());
Settings->setChatSearchWholeWords(ui.cbSearch_WholeWords->isChecked());
Settings->setChatSearchMoveToCursor(ui.cbSearch_MoveToCursor->isChecked());
Settings->setChatSearchSearchWithoutLimit(ui.cbSearch_WithoutLimit->isChecked());
Settings->setChatSearchMaxSearchLimitColor(ui.sbSearch_MaxLimitColor->value());
Settings->setChatSearchFoundColor(rgbChatSearchFoundColor);
Settings->setPublicChatHistoryCount(ui.publicChatLoadCount->value()); Settings->setPublicChatHistoryCount(ui.publicChatLoadCount->value());
Settings->setPrivateChatHistoryCount(ui.privateChatLoadCount->value()); Settings->setPrivateChatHistoryCount(ui.privateChatLoadCount->value());
Settings->setLobbyChatHistoryCount(ui.lobbyChatLoadCount->value()); Settings->setLobbyChatHistoryCount(ui.lobbyChatLoadCount->value());
@ -251,6 +260,17 @@ ChatPage::load()
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn()); ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
ui.sbSearch_CharToStart->setValue(Settings->getChatSearchCharToStartSearch());
ui.cbSearch_CaseSensitively->setChecked(Settings->getChatSearchCaseSensitively());
ui.cbSearch_WholeWords->setChecked(Settings->getChatSearchWholeWords());
ui.cbSearch_MoveToCursor->setChecked(Settings->getChatSearchMoveToCursor());
ui.cbSearch_WithoutLimit->setChecked(Settings->getChatSearchSearchWithoutLimit());
ui.sbSearch_MaxLimitColor->setValue(Settings->getChatSearchMaxSearchLimitColor());
rgbChatSearchFoundColor=Settings->getChatSearchFoundColor();
QPixmap pix(24, 24);
pix.fill(rgbChatSearchFoundColor);
ui.btSearch_FoundColor->setIcon(pix);
ui.publicChatLoadCount->setValue(Settings->getPublicChatHistoryCount()); ui.publicChatLoadCount->setValue(Settings->getPublicChatHistoryCount());
ui.privateChatLoadCount->setValue(Settings->getPrivateChatHistoryCount()); ui.privateChatLoadCount->setValue(Settings->getPrivateChatHistoryCount());
ui.lobbyChatLoadCount->setValue(Settings->getLobbyChatHistoryCount()); ui.lobbyChatLoadCount->setValue(Settings->getLobbyChatHistoryCount());
@ -473,3 +493,21 @@ void ChatPage::on_historyComboBoxVariant_currentIndexChanged(int /*index*/)
{ {
fillPreview(ui.historyList, ui.historyComboBoxVariant, ui.historyPreview); fillPreview(ui.historyList, ui.historyComboBoxVariant, ui.historyPreview);
} }
void ChatPage::on_cbSearch_WithoutLimit_toggled(bool checked)
{
ui.sbSearch_MaxLimitColor->setEnabled(!checked);
ui.lSearch_MaxLimitColor->setEnabled(!checked);
}
void ChatPage::on_btSearch_FoundColor_clicked()
{
bool ok;
QRgb color = QColorDialog::getRgba(rgbChatSearchFoundColor, &ok, window());
if (ok) {
rgbChatSearchFoundColor=color;
QPixmap pix(24, 24);
pix.fill(color);
ui.btSearch_FoundColor->setIcon(pix);
}
}

View file

@ -53,6 +53,9 @@ class ChatPage : public ConfigPage
void on_privateList_currentRowChanged(int currentRow); void on_privateList_currentRowChanged(int currentRow);
void on_historyList_currentRowChanged(int currentRow); void on_historyList_currentRowChanged(int currentRow);
void on_cbSearch_WithoutLimit_toggled(bool);
void on_btSearch_FoundColor_clicked();
void collectedContacts_customPopupMenu(QPoint) ; void collectedContacts_customPopupMenu(QPoint) ;
void collectedInvite_openDistantChat() ; void collectedInvite_openDistantChat() ;
@ -69,6 +72,8 @@ class ChatPage : public ConfigPage
QString historyStylePath; QString historyStylePath;
QString historyStyleVariant; QString historyStyleVariant;
QRgb rgbChatSearchFoundColor;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::ChatPage ui; Ui::ChatPage ui;
}; };

View file

@ -298,12 +298,169 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <widget class="QGroupBox" name="groupBoxSearch">
<property name="orientation"> <property name="title">
<enum>Qt::Vertical</enum> <string>Search by default</string>
</property>
<layout class="QVBoxLayout" name="vlSearch">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="hlSearch_CharToStart">
<item>
<widget class="QLabel" name="lSearch_CharToStart">
<property name="text">
<string>Number of char to start search</string>
</property>
</widget>
</item>
<item>
<spacer name="hsSearch_CharToStart">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="sbSearch_CharToStart">
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="cbSearch_CaseSensitively">
<property name="text">
<string>Case sensitive</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbSearch_WholeWords">
<property name="text">
<string>Whole Words</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbSearch_MoveToCursor">
<property name="text">
<string>Move to cursor</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbSearch_WithoutLimit">
<property name="text">
<string>Color All Text Found</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlSearch_MaxLimitColor">
<item>
<widget class="QLabel" name="lSearch_MaxLimitColor">
<property name="text">
<string>Number of found text coloring</string>
</property>
</widget>
</item>
<item>
<spacer name="hsSearch_MaxLimitColor">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="sbSearch_MaxLimitColor">
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlSearch_FoundColor">
<item>
<widget class="QLabel" name="lSearch_FoundColor">
<property name="text">
<string>Color of found text</string>
</property>
</widget>
</item>
<item>
<spacer name="hsSearch_FoundColor">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btSearch_FoundColor">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Choose color of found text</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>

View file

@ -526,6 +526,80 @@ bool RshareSettings::getChatSendMessageWithCtrlReturn()
return valueFromGroup("Chat", "SendMessageWithCtrlReturn", false).toBool(); return valueFromGroup("Chat", "SendMessageWithCtrlReturn", false).toBool();
} }
void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue)
{
setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue);
}
void RshareSettings::setChatSearchCharToStartSearch(int iValue)
{
setValueToGroup("Chat", "SearchCharToStartSearch", iValue);
}
int RshareSettings::getChatSearchCharToStartSearch()
{
return valueFromGroup("Chat", "SearchCharToStartSearch", 4).toUInt();
}
void RshareSettings::setChatSearchCaseSensitively(bool bValue)
{
setValueToGroup("Chat", "SearchCaseSensitively", bValue);
}
bool RshareSettings::getChatSearchCaseSensitively()
{
return valueFromGroup("Chat", "SearchCaseSensitively", false).toBool();
}
void RshareSettings::setChatSearchWholeWords(bool bValue)
{
setValueToGroup("Chat", "SearchWholeWords", bValue);
}
bool RshareSettings::getChatSearchWholeWords()
{
return valueFromGroup("Chat", "SearchWholeWords", false).toBool();
}
void RshareSettings::setChatSearchMoveToCursor(bool bValue)
{
setValueToGroup("Chat", "SearchMoveToCursor", bValue);
}
bool RshareSettings::getChatSearchMoveToCursor()
{
return valueFromGroup("Chat", "SearchMoveToCursor", true).toBool();
}
void RshareSettings::setChatSearchSearchWithoutLimit(bool bValue)
{
setValueToGroup("Chat", "SearchSearchWithoutLimit", bValue);
}
bool RshareSettings::getChatSearchSearchWithoutLimit()
{
return valueFromGroup("Chat", "SearchSearchWithoutLimit", false).toBool();
}
void RshareSettings::setChatSearchMaxSearchLimitColor(uint uiValue)
{
setValueToGroup("Chat", "SearchMaxSearchLimitColor", uiValue);
}
uint RshareSettings::getChatSearchMaxSearchLimitColor()
{
return valueFromGroup("Chat", "SearchMaxSearchLimitColor", 40).toUInt();
}
void RshareSettings::setChatSearchFoundColor(QRgb rgbValue)
{
setValueToGroup("Chat", "SearchMaxSearchFoundColor", QString::number(rgbValue));
}
QRgb RshareSettings::getChatSearchFoundColor()
{
return valueFromGroup("Chat", "SearchMaxSearchFoundColor", QString::number(QColor(255,255,150).rgba())).toUInt();
}
RshareSettings::enumToasterPosition RshareSettings::getToasterPosition() RshareSettings::enumToasterPosition RshareSettings::getToasterPosition()
{ {
return (enumToasterPosition) value("ToasterPosition", TOASTERPOS_BOTTOMRIGHT).toInt(); return (enumToasterPosition) value("ToasterPosition", TOASTERPOS_BOTTOMRIGHT).toInt();
@ -546,11 +620,6 @@ void RshareSettings::setToasterMargin(QPoint margin)
setValue("ToasterMargin", margin); setValue("ToasterMargin", margin);
} }
void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue)
{
setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue);
}
QString RshareSettings::getChatScreenFont() QString RshareSettings::getChatScreenFont()
{ {
return valueFromGroup("Chat", "ChatScreenFont").toString(); return valueFromGroup("Chat", "ChatScreenFont").toString();

View file

@ -25,6 +25,7 @@
#define _RSHARESETTINGS_H #define _RSHARESETTINGS_H
#include <QHash> #include <QHash>
#include <QRgb>
#include <QSettings> #include <QSettings>
#include <gui/linetypes.h> #include <gui/linetypes.h>
@ -214,6 +215,27 @@ public:
bool getChatSendMessageWithCtrlReturn(); bool getChatSendMessageWithCtrlReturn();
void setChatSendMessageWithCtrlReturn(bool bValue); void setChatSendMessageWithCtrlReturn(bool bValue);
void setChatSearchCharToStartSearch(int iValue);
int getChatSearchCharToStartSearch();
void setChatSearchCaseSensitively(bool bValue);
bool getChatSearchCaseSensitively();
void setChatSearchWholeWords(bool bValue);
bool getChatSearchWholeWords();
void setChatSearchMoveToCursor(bool bValue);
bool getChatSearchMoveToCursor();
void setChatSearchSearchWithoutLimit(bool bValue);
bool getChatSearchSearchWithoutLimit();
void setChatSearchMaxSearchLimitColor(uint uiValue);
uint getChatSearchMaxSearchLimitColor();
void setChatSearchFoundColor(QRgb rgbValue);
QRgb getChatSearchFoundColor();
enumToasterPosition getToasterPosition(); enumToasterPosition getToasterPosition();
void setToasterPosition(enumToasterPosition position); void setToasterPosition(enumToasterPosition position);

View file

@ -3,41 +3,41 @@
<class>Settings</class> <class>Settings</class>
<widget class="QDialog" name="Settings"> <widget class="QDialog" name="Settings">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>820</width> <width>820</width>
<height>620</height> <height>620</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Options</string> <string>Options</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../images.qrc"> <iconset resource="../images.qrc">
<normaloff>:/images/kcmsystem24.png</normaloff>:/images/kcmsystem24.png</iconset> <normaloff>:/images/kcmsystem24.png</normaloff>:/images/kcmsystem24.png</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="pageName"> <widget class="QLabel" name="pageName">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum"> <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
@ -93,109 +93,115 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="0" rowspan="3"> <item row="0" column="0" rowspan="3">
<widget class="QListWidget" name="listWidget"> <widget class="QListWidget" name="listWidget">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>130</width> <width>130</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>130</width> <width>130</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
<width>24</width> <width>24</width>
<height>24</height> <height>24</height>
</size> </size>
</property> </property>
<property name="textElideMode"> <property name="textElideMode">
<enum>Qt::ElideMiddle</enum> <enum>Qt::ElideMiddle</enum>
</property> </property>
<property name="movement"> <property name="movement">
<enum>QListView::Static</enum> <enum>QListView::Static</enum>
</property> </property>
<property name="flow"> <property name="flow">
<enum>QListView::TopToBottom</enum> <enum>QListView::TopToBottom</enum>
</property> </property>
<property name="isWrapping" stdset="0"> <property name="isWrapping" stdset="0">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="resizeMode"> <property name="resizeMode">
<enum>QListView::Fixed</enum> <enum>QListView::Fixed</enum>
</property> </property>
<property name="layoutMode"> <property name="layoutMode">
<enum>QListView::SinglePass</enum> <enum>QListView::SinglePass</enum>
</property> </property>
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="gridSize"> <property name="gridSize">
<size> <size>
<width>100</width> <width>100</width>
<height>24</height> <height>24</height>
</size> </size>
</property> </property>
<property name="viewMode"> <property name="viewMode">
<enum>QListView::ListMode</enum> <enum>QListView::ListMode</enum>
</property> </property>
<property name="modelColumn"> <property name="modelColumn">
<number>0</number> <number>0</number>
</property> </property>
<property name="uniformItemSizes"> <property name="uniformItemSizes">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="currentRow"> <property name="currentRow">
<number>-1</number> <number>-1</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable"> <property name="frameShape">
<bool>true</bool> <enum>QFrame::NoFrame</enum>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents"> <property name="frameShadow">
<property name="geometry"> <enum>QFrame::Plain</enum>
<rect> </property>
<x>0</x> <property name="widgetResizable">
<y>0</y> <bool>true</bool>
<width>664</width> </property>
<height>501</height> <widget class="QWidget" name="scrollAreaWidgetContents">
</rect> <property name="geometry">
</property> <rect>
<layout class="QVBoxLayout" name="verticalLayout"> <x>0</x>
<item> <y>0</y>
<widget class="QStackedWidget" name="stackedWidget"> <width>666</width>
<property name="currentIndex"> <height>517</height>
<number>0</number> </rect>
</property> </property>
<widget class="QWidget" name="page"/> <layout class="QVBoxLayout" name="verticalLayout">
</widget> <item>
</item> <widget class="QStackedWidget" name="stackedWidget">
</layout> <property name="currentIndex">
</widget> <number>0</number>
</widget> </property>
</item> <widget class="QWidget" name="page"/>
</layout> </widget>
</widget> </item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources> <resources>
<include location="../images.qrc"/> <include location="../images.qrc"/>
</resources> </resources>