From 29a74b98982cea1bbfac2f0db91701e8fb2a01a6 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 31 Mar 2008 16:20:32 +0000 Subject: [PATCH] fixed textcolor git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@449 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/ChatDialog.cpp | 68 +++++++++++++-------------- retroshare-gui/src/gui/ChatDialog.h | 11 +++-- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/retroshare-gui/src/gui/ChatDialog.cpp b/retroshare-gui/src/gui/ChatDialog.cpp index 26ea198f4..a58de7a56 100644 --- a/retroshare-gui/src/gui/ChatDialog.cpp +++ b/retroshare-gui/src/gui/ChatDialog.cpp @@ -44,15 +44,15 @@ #include #include #include +#include /** Constructor */ ChatDialog::ChatDialog(QWidget *parent) -: MainPage(parent) +: MainPage (parent) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); - setupsendActions(); setWindowIcon(QIcon(QString(":/images/rstray3.png"))); @@ -69,14 +69,15 @@ ChatDialog::ChatDialog(QWidget *parent) connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(getFont())); connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor())); #endif + connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor())); + connect(ui.actionSend, SIGNAL(triggered()), this, SLOT(returnPressed())); ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png"))); // connect(ui.msgSendList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), // this, SLOT(toggleSendItem( QTreeWidgetItem *, int ) )); - //loadInitMsg(); /* hide the Tree +/- */ ui.msgSendList -> setRootIsDecorated( false ); @@ -114,25 +115,6 @@ void ChatDialog::msgSendListCostumPopupMenu( QPoint point ) contextMnu.exec( mevent->globalPos() ); } -/*int ChatDialog::loadInitMsg() -{ - std::ostringstream out; - - //out << std::endl; - //out << std::endl; - //out << std::endl; - //out << " Welcome to:"; - //out << "
" << std::endl; - //out << " Retroshare's group chat.
"; - - QString txt = QString::fromStdString(out.str()); - ui.msgText->setHtml(txt); - - return 1; -}*/ - - - void ChatDialog::insertChat() { std::list newchat; @@ -326,11 +308,18 @@ void ChatDialog::clearOldChats() void ChatDialog::setColor() { - textColor = QColorDialog::getColor(Qt::black, this); - QPixmap pxm(24,24); - pxm.fill(textColor); - ui.colorChatButton->setIcon(pxm); - ui.lineEdit->setTextColor(textColor); + + bool ok; + QRgb color = QColorDialog::getRgba(ui.lineEdit->textColor().rgba(), &ok, this); + if (ok) { + _currentColor = QColor(color); + ui.lineEdit->setTextColor(_currentColor); + QPixmap pxm(24,24); + pxm.fill(_currentColor); + ui.colorChatButton->setIcon(pxm); + } + ui.lineEdit->setFocus(); + } void ChatDialog::getFont() @@ -354,15 +343,12 @@ void ChatDialog::setFont() } -void ChatDialog::setupsendActions() -{ - QAction *a; +void ChatDialog::returnPressed() +{ - a = new QAction(this); - a->setShortcut(Qt::CTRL + Qt::Key_S); - connect(a, SIGNAL(triggered()), this, SLOT(sendMsg())); - -} + this->sendMsg(); + +} // Update Chat Info information void ChatDialog::setChatInfo(QString info, QColor color) { @@ -388,4 +374,14 @@ void ChatDialog::displayInfoChatMenu(const QPoint& pos) { myChatMenu.exec(mapToGlobal(pos)+QPoint(0,80)); } - +bool ChatDialog::keyPressed(QEvent * event) +{ + QKeyEvent * e = static_cast(event); + if ((e->key() == Qt::Key_Enter) || (e->key() == Qt::Key_Return)) { + event->accept(); + sendMsg(); + return true; + } + + return false; + } diff --git a/retroshare-gui/src/gui/ChatDialog.h b/retroshare-gui/src/gui/ChatDialog.h index 7b1439ddc..7a02d44a5 100644 --- a/retroshare-gui/src/gui/ChatDialog.h +++ b/retroshare-gui/src/gui/ChatDialog.h @@ -43,8 +43,7 @@ public: void insertChat(); PopupChatDialog *getPrivateChat(std::string id, std::string name, bool show); void clearOldChats(); - -//int loadInitMsg(); + public slots: @@ -66,11 +65,14 @@ void toggleSendItem( QTreeWidgetItem *item, int col ); void setFont(); void getFont(); - void setupsendActions(); void on_actionClearChat_triggered(); void displayInfoChatMenu(const QPoint& pos); + void returnPressed(); + bool keyPressed(QEvent * event); + + private: @@ -85,7 +87,8 @@ private: QTreeView *msgSendList; - QColor textColor; + QColor textColor; + QColor _currentColor;