From f93d41991e76b9feb1a92a3c9ed951daee4c4aca Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 26 May 2014 21:51:53 +0000 Subject: [PATCH] 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 --- .../src/gui/chat/ChatLobbyDialog.ui | 3 + retroshare-gui/src/gui/chat/ChatWidget.cpp | 321 ++++++++++++++++++ retroshare-gui/src/gui/chat/ChatWidget.h | 102 ++++-- retroshare-gui/src/gui/chat/ChatWidget.ui | 266 +++++++++++++-- retroshare-gui/src/gui/settings/ChatPage.cpp | 38 +++ retroshare-gui/src/gui/settings/ChatPage.h | 5 + retroshare-gui/src/gui/settings/ChatPage.ui | 169 ++++++++- .../src/gui/settings/rsharesettings.cpp | 79 ++++- .../src/gui/settings/rsharesettings.h | 22 ++ retroshare-gui/src/gui/settings/settings.ui | 274 +++++++-------- 10 files changed, 1074 insertions(+), 205 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui b/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui index c5e73644e..4b6474357 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui @@ -14,6 +14,9 @@ MainWindow + + 0 + 0 diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index f2cbcd615..0d7c4afa4 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -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("Find Previous
Ctrl+Shift+G")); + ui->searchAfter->setVisible(false); + ui->searchAfter->setToolTip(tr("Find Next
Ctrl+G")); + ui->searchButton->setCheckable(true); + ui->searchButton->setChecked(false); + ui->searchButton->setToolTip(tr("Find
Ctrl+F")); + 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("Mark this selected text
Ctr+M")); + 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(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(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()qtcCurrent.position())) + )) + { + bFirstFound=false; + qtcCurrent=qtcHighLight; + if (bMoveToCursor || bForceMove) ui->textBrowser->setTextCursor(qtcHighLight); + + }//if (bFirstFound && (qtcHighLight.position()>qtcCurrent.position())) + + + if (uiFoundCountleSearch->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::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("Return to marked text
Ctr+M")); + + } else { bValue=false;} + } else { + if (qtcMark.position()!=0) + { + ui->textBrowser->setTextCursor(qtcMark); + qtcMark=QTextCursor(ui->textBrowser->document()); + ui->markButton->setToolTip(tr("Mark this selected text
Ctr+M")); + + } + } + 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() diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index 978edefa8..b83d4e8c9 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -22,23 +22,26 @@ #ifndef CHATWIDGET_H #define CHATWIDGET_H - -#include -#include -#include "gui/common/HashBox.h" -#include "ChatStyle.h" -#include "gui/style/RSStyle.h" + +#include +#include +#include +#include +#include "gui/common/HashBox.h" +#include "ChatStyle.h" +#include "gui/style/RSStyle.h" #include #include 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 hashedFiles); + +private slots: + void contextMenuTextBrowser(QPoint); + void contextMenuSearchButton(QPoint); + void chatCharFormatChanged(); + + void fileHashingFinished(QList 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 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; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index e7825959a..e47d67f3e 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -15,12 +15,14 @@ 2 - 0 - - - - - 3 + 0 + + + + + + + 3 2 @@ -60,12 +62,182 @@ - - - - - - + + + + + + Qt::Horizontal + + + + 190 + 25 + + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + 2 + + + + + + 0 + 0 + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + + :/images/highlight.png:/images/highlight.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + + + + 14 + 28 + + + + + 14 + 28 + + + + Qt::NoFocus + + + + :/images/arrow-left.png:/images/arrow-left.png + + + true + + + + + + + + 14 + 28 + + + + + 14 + 28 + + + + Qt::NoFocus + + + + :/images/arrow-right.png:/images/arrow-right.png + + + true + + + + + + + + 0 + 0 + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + Qt::CustomContextMenu + + + + :/images/find.png:/images/find.png + + + + 24 + 24 + + + + true + + + true + + + + + + +
+ + + + + @@ -713,12 +885,53 @@ border-image: url(:/images/closepressed.png) - Reset font to default - - - - - + Reset font to default + + + + + true + + + Find Case Sensitively + + + + + true + + + Find Whole Words + + + Find Whole Words + + + + + true + + + Move To Cursor + + + Move To Cursor + + + + + true + + + Don't stop to color after X items found (need more CPU) + + + WARNING: Could take long time on big history. + + + + + RSTextBrowser QTextBrowser
gui/common/RSTextBrowser.h
@@ -731,12 +944,17 @@ border-image: url(:/images/closepressed.png)
MimeTextEdit - QTextEdit -
gui/common/MimeTextEdit.h
-
-
- - + QTextEdit +
gui/common/MimeTextEdit.h
+
+ + LineEditClear + QLineEdit +
gui/common/LineEditClear.h
+
+
+ + diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index 3e3908a43..2995e7141 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -19,6 +19,7 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ +#include #include #include #include @@ -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); + } +} diff --git a/retroshare-gui/src/gui/settings/ChatPage.h b/retroshare-gui/src/gui/settings/ChatPage.h index e456ac7c5..f35252eb9 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.h +++ b/retroshare-gui/src/gui/settings/ChatPage.h @@ -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; }; diff --git a/retroshare-gui/src/gui/settings/ChatPage.ui b/retroshare-gui/src/gui/settings/ChatPage.ui index d5070a69c..6bdf481f1 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.ui +++ b/retroshare-gui/src/gui/settings/ChatPage.ui @@ -298,12 +298,169 @@
- - - - - - Qt::Vertical + + + + + + Search by default + + + + 2 + + + 2 + + + 0 + + + 0 + + + 0 + + + + + + + Number of char to start search + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 100 + + + + + + + + + Case sensitive + + + + + + + Whole Words + + + + + + + Move to cursor + + + + + + + Color All Text Found + + + + + + + + + Number of found text coloring + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1000 + + + + + + + + + + + Color of found text + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Choose color of found text + + + + + + + + + + + + Qt::Vertical diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index d6eb9f6e0..b6ee0780e 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -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(); diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index bcfea2dfa..bbceafcca 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -25,6 +25,7 @@ #define _RSHARESETTINGS_H #include +#include #include #include @@ -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); diff --git a/retroshare-gui/src/gui/settings/settings.ui b/retroshare-gui/src/gui/settings/settings.ui index e77f5d86a..8028a7b76 100755 --- a/retroshare-gui/src/gui/settings/settings.ui +++ b/retroshare-gui/src/gui/settings/settings.ui @@ -3,41 +3,41 @@ Settings - - 0 - 0 - 820 - 620 - - - + + 0 + 0 + 820 + 620 + + + Options - :/images/kcmsystem24.png:/images/kcmsystem24.png - - - - - - 6 - - - 0 - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - + :/images/kcmsystem24.png:/images/kcmsystem24.png + + + + + + 6 + + + 0 + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + @@ -93,109 +93,115 @@ Qt::Horizontal - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - false - - - - 24 - 24 - - - - Qt::ElideMiddle - - - QListView::Static - - - QListView::TopToBottom - - - false - - - QListView::Fixed - - - QListView::SinglePass - - - 0 - - - - 100 - 24 - - - - QListView::ListMode - - - 0 - - - true - - - -1 - - - - - - - Qt::Horizontal - - - - - - - true - - - - - 0 - 0 - 664 - 501 - - - - - - - 0 - - - - - - - - - - + + + + + + + + 130 + 0 + + + + + 130 + 16777215 + + + + false + + + + 24 + 24 + + + + Qt::ElideMiddle + + + QListView::Static + + + QListView::TopToBottom + + + false + + + QListView::Fixed + + + QListView::SinglePass + + + 0 + + + + 100 + 24 + + + + QListView::ListMode + + + 0 + + + true + + + -1 + + + + + + + Qt::Horizontal + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + 0 + 0 + 666 + 517 + + + + + + + 0 + + + + + + + + + +