From 3b1c26de3508d26db05d4463f055cc7b91e3f407 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sun, 5 Feb 2012 14:56:27 +0000 Subject: [PATCH] Set the focus the subject input when creating a new forum/channel or channel message. Set the forum/channel message to read when expanding the message feed. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4891 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/ForumsDialog.cpp | 4 + .../src/gui/channels/CreateChannel.cpp | 2 + .../src/gui/channels/CreateChannelMsg.cpp | 3 +- retroshare-gui/src/gui/feeds/ChanMsgItem.cpp | 84 +++++++++--------- retroshare-gui/src/gui/feeds/ForumMsgItem.cpp | 86 +++++++++++-------- retroshare-gui/src/gui/feeds/ForumMsgItem.ui | 6 ++ retroshare-gui/src/gui/forums/CreateForum.cpp | 2 + 7 files changed, 107 insertions(+), 80 deletions(-) diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index fae797d1e..88e2712c1 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -742,6 +742,8 @@ void ForumsDialog::fillThreadFinished() #ifdef DEBUG_FORUMS std::cerr << "ForumsDialog::fillThreadFinished Add messages" << std::endl; #endif + ui.threadTreeWidget->setSortingEnabled(false); + /* add all messages in! */ if (lastViewType != thread->viewType || lastForumID != mCurrForumId) { ui.threadTreeWidget->clear(); @@ -758,6 +760,8 @@ void ForumsDialog::fillThreadFinished() CleanupItems (thread->items); } + ui.threadTreeWidget->setSortingEnabled(true); + if (thread->focusMsgId.empty() == false) { /* Search exisiting item */ QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); diff --git a/retroshare-gui/src/gui/channels/CreateChannel.cpp b/retroshare-gui/src/gui/channels/CreateChannel.cpp index 5c4946ed9..1bfd5c997 100644 --- a/retroshare-gui/src/gui/channels/CreateChannel.cpp +++ b/retroshare-gui/src/gui/channels/CreateChannel.cpp @@ -82,6 +82,8 @@ void CreateChannel::newChannel() ui.msgAnon->setChecked(true); ui.msgAuth->setEnabled(false); ui.msgGroupBox->hide(); + + ui.channelName->setFocus(); } void CreateChannel::createChannel() diff --git a/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp b/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp index ef5d08ce4..99252ea3f 100644 --- a/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp +++ b/retroshare-gui/src/gui/channels/CreateChannelMsg.cpp @@ -529,7 +529,6 @@ void CreateChannelMsg::cancelMsg() void CreateChannelMsg::newChannelMsg() { - if (!rsChannels) return; @@ -541,9 +540,9 @@ void CreateChannelMsg::newChannelMsg() } channelName->setText(QString::fromStdWString(ci.channelName)); + subjectEdit->setFocus(); } - void CreateChannelMsg::sendMsg() { std::cerr << "CreateChannelMsg::sendMsg()"; diff --git a/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp index fde4165f4..d4bd629a9 100644 --- a/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChanMsgItem.cpp @@ -44,38 +44,38 @@ ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, const std::string :QWidget(NULL), mParent(parent), mFeedId(feedId), mChanId(chanId), mMsgId(msgId), mIsHome(isHome) { - /* Invoke the Qt Designer generated object setup routine */ - setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); - setAttribute ( Qt::WA_DeleteOnClose, true ); + setAttribute ( Qt::WA_DeleteOnClose, true ); - m_inUpdateItemStatic = false; + m_inUpdateItemStatic = false; - /* general ones */ - connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) ); - connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) ); + /* general ones */ + connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) ); + connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) ); - /* specific */ - connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) ); - connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) ); - connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) ); - connect( copyLinkButton, SIGNAL( clicked( void ) ), this, SLOT( copyLink ( void ) ) ); + /* specific */ + connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) ); + connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) ); + connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) ); + connect( copyLinkButton, SIGNAL( clicked( void ) ), this, SLOT( copyLink ( void ) ) ); - connect( readButton, SIGNAL( toggled(bool) ), this, SLOT( readToggled(bool) ) ); - connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection); + connect( readButton, SIGNAL( toggled(bool) ), this, SLOT( readToggled(bool) ) ); + connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection); - downloadButton->hide(); - playButton->hide(); - warn_image_label->hide(); - warning_label->hide(); + downloadButton->hide(); + playButton->hide(); + warn_image_label->hide(); + warning_label->hide(); - titleLabel->setMinimumWidth(100); - subjectLabel->setMinimumWidth(100); - warning_label->setMinimumWidth(100); + titleLabel->setMinimumWidth(100); + subjectLabel->setMinimumWidth(100); + warning_label->setMinimumWidth(100); - small(); - updateItemStatic(); - updateItem(); + small(); + updateItemStatic(); + updateItem(); } void ChanMsgItem::updateItemStatic() @@ -311,6 +311,10 @@ void ChanMsgItem::toggle() expandFrame->show(); expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png"))); expandButton->setToolTip(tr("Hide")); + + if (!mIsHome) { + readToggled(false); + } } else { @@ -374,27 +378,27 @@ void ChanMsgItem::play() void ChanMsgItem::readToggled(bool checked) { - if (m_inUpdateItemStatic) { - return; - } + if (m_inUpdateItemStatic) { + return; + } - /* set always as read ... */ - uint32_t statusNew = CHANNEL_MSG_STATUS_READ; - if (checked) { - /* ... and as unread by user */ - statusNew |= CHANNEL_MSG_STATUS_UNREAD_BY_USER; - } else { - /* ... and as read by user */ - statusNew &= ~CHANNEL_MSG_STATUS_UNREAD_BY_USER; - } - rsChannels->setMessageStatus(mChanId, mMsgId, statusNew, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER); + /* set always as read ... */ + uint32_t statusNew = CHANNEL_MSG_STATUS_READ; + if (checked) { + /* ... and as unread by user */ + statusNew |= CHANNEL_MSG_STATUS_UNREAD_BY_USER; + } else { + /* ... and as read by user */ + statusNew &= ~CHANNEL_MSG_STATUS_UNREAD_BY_USER; + } + rsChannels->setMessageStatus(mChanId, mMsgId, statusNew, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER); } void ChanMsgItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int /*status*/) { - if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) { - updateItemStatic(); - } + if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) { + updateItemStatic(); + } } void ChanMsgItem::copyLink() diff --git a/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp index 2b3c479e7..adcb98b53 100644 --- a/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp @@ -30,13 +30,10 @@ #include #include -#include "gui/notifyqt.h" - #include "gui/forums/CreateForumMsg.h" #include "gui/chat/HandleRichText.h" #include "gui/common/AvatarDefs.h" - -#include +//#include "gui/settings/rsharesettings.h" /**** * #define DEBUG_ITEM 1 @@ -46,31 +43,30 @@ ForumMsgItem::ForumMsgItem(FeedHolder *parent, uint32_t feedId, const std::string &forumId, const std::string &postId, bool isHome) :QWidget(NULL), mParent(parent), mFeedId(feedId), mForumId(forumId), mPostId(postId), mIsHome(isHome), mIsTop(false) { - /* Invoke the Qt Designer generated object setup routine */ - setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); - setAttribute ( Qt::WA_DeleteOnClose, true ); + setAttribute ( Qt::WA_DeleteOnClose, true ); - /* general ones */ - connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) ); - connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) ); + /* general ones */ + connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) ); + connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) ); - /* specific ones */ - connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeForum ( void ) ) ); - connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyToPost ( void ) ) ); - connect( sendButton, SIGNAL( clicked( ) ), this, SLOT( sendMsg() ) ); + /* specific ones */ + connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeForum ( void ) ) ); + connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyToPost ( void ) ) ); + connect( sendButton, SIGNAL( clicked( ) ), this, SLOT( sendMsg() ) ); - subjectLabel->setMinimumWidth(20); + subjectLabel->setMinimumWidth(20); - small(); - updateItemStatic(); - updateItem(); - textEdit->hide(); - sendButton->hide(); - signedcheckBox->hide(); + small(); + updateItemStatic(); + updateItem(); + textEdit->hide(); + sendButton->hide(); + signedcheckBox->hide(); } - void ForumMsgItem::updateItemStatic() { if (!rsForums) @@ -157,10 +153,10 @@ void ForumMsgItem::updateItemStatic() prevSubLabel->setText(link.toHtml()); prevMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msg.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - QDateTime qtime; - qtime.setTime_t(msg.ts); - QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); - timestamplabel->setText(timestamp); + QDateTime qtime; + qtime.setTime_t(msg.ts); + QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); + timestamplabel->setText(timestamp); nextFrame->hide(); } @@ -183,9 +179,9 @@ void ForumMsgItem::updateItemStatic() nextMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msg.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); QDateTime qtime; - qtime.setTime_t(msg.ts); - QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); - timestamplabel->setText(timestamp); + qtime.setTime_t(msg.ts); + QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); + timestamplabel->setText(timestamp); prevSHLabel->setText(tr("In Reply to") + ": "); @@ -234,7 +230,6 @@ void ForumMsgItem::updateItemStatic() unsubscribeButton->hide(); } - void ForumMsgItem::updateItem() { /* fill in */ @@ -242,10 +237,8 @@ void ForumMsgItem::updateItem() std::cerr << "ForumMsgItem::updateItem()"; std::cerr << std::endl; #endif - } - void ForumMsgItem::small() { nextFrame->hide(); @@ -261,11 +254,32 @@ void ForumMsgItem::toggle() sendButton->setVisible(canReply); signedcheckBox->setVisible(canReply); expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png"))); - expandButton->setToolTip("Hide"); + expandButton->setToolTip("Hide"); if (!mIsTop) { nextFrame->show(); } + + uint32_t status; + rsForums->getMessageStatus(mForumId, mPostId, status); + + if (canReply) { + /* set always to read ... */ + uint32_t statusNew = status | FORUM_MSG_STATUS_READ; + +// bool setToReadOnActive = Settings->getForumMsgSetToReadOnActivate(); +// if (setToReadOnActive) { + /* ... and to read by user */ + statusNew &= ~FORUM_MSG_STATUS_UNREAD_BY_USER; +// } else { +// /* ... and to unread by user */ +// statusNew |= FORUM_MSG_STATUS_UNREAD_BY_USER; +// } + + if (status != statusNew) { + rsForums->setMessageStatus(mForumId, mPostId, statusNew, FORUM_MSG_STATUS_READ | FORUM_MSG_STATUS_UNREAD_BY_USER); + } + } } else { @@ -275,11 +289,10 @@ void ForumMsgItem::toggle() sendButton->hide(); signedcheckBox->hide(); expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); - expandButton->setToolTip("Expand"); + expandButton->setToolTip("Expand"); } } - void ForumMsgItem::removeItem() { #ifdef DEBUG_ITEM @@ -295,7 +308,6 @@ void ForumMsgItem::removeItem() /*********** SPECIFIC FUNCTIOSN ***********************/ - void ForumMsgItem::unsubscribeForum() { #ifdef DEBUG_ITEM @@ -309,7 +321,6 @@ void ForumMsgItem::unsubscribeForum() updateItemStatic(); } - void ForumMsgItem::subscribeForum() { #ifdef DEBUG_ITEM @@ -338,7 +349,6 @@ void ForumMsgItem::replyToPost() CreateForumMsg *cfm = new CreateForumMsg(mForumId, mPostId); cfm->show(); } - } void ForumMsgItem::sendMsg() diff --git a/retroshare-gui/src/gui/feeds/ForumMsgItem.ui b/retroshare-gui/src/gui/feeds/ForumMsgItem.ui index 79e5f603a..2968ef1ea 100644 --- a/retroshare-gui/src/gui/feeds/ForumMsgItem.ui +++ b/retroshare-gui/src/gui/feeds/ForumMsgItem.ui @@ -359,6 +359,9 @@ border-radius: 10px} true + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -520,6 +523,9 @@ border-radius: 10px} true + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + diff --git a/retroshare-gui/src/gui/forums/CreateForum.cpp b/retroshare-gui/src/gui/forums/CreateForum.cpp index e64cc2bd0..148f2d804 100644 --- a/retroshare-gui/src/gui/forums/CreateForum.cpp +++ b/retroshare-gui/src/gui/forums/CreateForum.cpp @@ -73,6 +73,8 @@ void CreateForum::newForum() ui.forumName->clear(); ui.forumDesc->clear(); + + ui.forumName->setFocus(); } void CreateForum::createForum()