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>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>

View File

@ -71,12 +71,41 @@ ChatWidget::ChatWidget(QWidget *parent) :
peerStatus = 0;
mChatType = CHATTYPE_UNKNOWN;
firstShow = true;
firstSearch = true;
inChatCharFormatChanged = false;
completer = NULL;
lastMsgDate = QDate::currentDate();
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->addFileButton, SIGNAL(clicked()), this , SLOT(addExtraFile()));
@ -125,6 +154,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
ui->pushtoolsButton->setMenu(menu);
ui->chatTextEdit->installEventFilter(this);
ui->textBrowser->installEventFilter(this);
#if QT_VERSION < 0x040700
// 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)
{
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 (event->type() == QEvent::KeyPress) {
@ -303,6 +378,10 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
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) {
@ -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 {
if (event->type() == QEvent::WindowActivate) {
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->append(formatMsg);
if (ui->leSearch->isVisible()) {
QString qsTextToFind=ui->leSearch->text();
findText(qsTextToFind);
}
resetStatusBar();
if (incoming && chatType == MSGTYPE_NORMAL) {
@ -675,6 +780,24 @@ void ChatWidget::contextMenuTextBrowser(QPoint point)
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()
{
if (inChatCharFormatChanged) {
@ -753,6 +876,202 @@ void ChatWidget::on_closeInfoFrameButton_clicked()
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()
{
bool ok;
@ -828,6 +1147,8 @@ void ChatWidget::addSmiley()
void ChatWidget::clearChatHistory()
{
ui->textBrowser->clear();
on_searchButton_clicked(false);
ui->markButton->setChecked(false);
}
void ChatWidget::deleteChatHistory()

View File

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

View File

@ -15,12 +15,14 @@
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="titleLayout">
<property name="spacing">
<number>3</number>
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="hTitleLayout">
<item>
<layout class="QVBoxLayout" name="titleLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
@ -60,12 +62,182 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="infoFrame">
<property name="palette">
<palette>
</layout>
</item>
<item>
<spacer>
<property name="orientation">
<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>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
@ -713,12 +885,53 @@ border-image: url(:/images/closepressed.png)
</action>
<action name="actionResetFont">
<property name="text">
<string>Reset font to default</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<string>Reset font to default</string>
</property>
</action>
<action name="actionFindCaseSensitively">
<property name="checkable">
<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>
<extends>QTextBrowser</extends>
<header>gui/common/RSTextBrowser.h</header>
@ -731,12 +944,17 @@ border-image: url(:/images/closepressed.png)
</customwidget>
<customwidget>
<class>MimeTextEdit</class>
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -19,6 +19,7 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QColorDialog>
#include <QFontDialog>
#include <QMenu>
#include <QMessageBox>
@ -166,6 +167,14 @@ ChatPage::save(QString &/*errmsg*/)
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->setPrivateChatHistoryCount(ui.privateChatLoadCount->value());
Settings->setLobbyChatHistoryCount(ui.lobbyChatLoadCount->value());
@ -251,6 +260,17 @@ ChatPage::load()
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.privateChatLoadCount->setValue(Settings->getPrivateChatHistoryCount());
ui.lobbyChatLoadCount->setValue(Settings->getLobbyChatHistoryCount());
@ -473,3 +493,21 @@ void ChatPage::on_historyComboBoxVariant_currentIndexChanged(int /*index*/)
{
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_historyList_currentRowChanged(int currentRow);
void on_cbSearch_WithoutLimit_toggled(bool);
void on_btSearch_FoundColor_clicked();
void collectedContacts_customPopupMenu(QPoint) ;
void collectedInvite_openDistantChat() ;
@ -69,6 +72,8 @@ class ChatPage : public ConfigPage
QString historyStylePath;
QString historyStyleVariant;
QRgb rgbChatSearchFoundColor;
/** Qt Designer generated object */
Ui::ChatPage ui;
};

View File

@ -298,12 +298,169 @@
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxSearch">
<property name="title">
<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 name="sizeHint" stdset="0">
<size>

View File

@ -526,6 +526,80 @@ bool RshareSettings::getChatSendMessageWithCtrlReturn()
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()
{
return (enumToasterPosition) value("ToasterPosition", TOASTERPOS_BOTTOMRIGHT).toInt();
@ -546,11 +620,6 @@ void RshareSettings::setToasterMargin(QPoint margin)
setValue("ToasterMargin", margin);
}
void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue)
{
setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue);
}
QString RshareSettings::getChatScreenFont()
{
return valueFromGroup("Chat", "ChatScreenFont").toString();

View File

@ -25,6 +25,7 @@
#define _RSHARESETTINGS_H
#include <QHash>
#include <QRgb>
#include <QSettings>
#include <gui/linetypes.h>
@ -214,6 +215,27 @@ public:
bool getChatSendMessageWithCtrlReturn();
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();
void setToasterPosition(enumToasterPosition position);

View File

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