diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index a88784c12..14ffca561 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -241,10 +241,6 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) /* Set Multi Selection */ ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection); - QFontMetricsF fontMetrics(ui.dirTreeView->font()); - int iconHeight = fontMetrics.height() * 1.5; - ui.dirTreeView->setIconSize(QSize(iconHeight, iconHeight)); - /* Hide platform specific features */ copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this ); connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) ); @@ -323,7 +319,7 @@ void SharedFilesDialog::hideEvent(QHideEvent *) model->setVisible(false) ; } -void SharedFilesDialog::showEvent(QShowEvent *) +void SharedFilesDialog::showEvent(QShowEvent *event) { if(model!=NULL) { @@ -336,6 +332,10 @@ void SharedFilesDialog::showEvent(QShowEvent *) restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); } + + if (!event->spontaneous()) { + updateFontSize(); + } } RemoteSharedFilesDialog::~RemoteSharedFilesDialog() { @@ -1686,3 +1686,16 @@ bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString return (visible || visibleChildCount); } #endif + +void SharedFilesDialog::updateFontSize() +{ + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); + QFont newFont = ui.dirTreeView->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + int iconHeight = fontMetrics.height(); + ui.dirTreeView->setFont(newFont); + ui.dirTreeView->setIconSize(QSize(iconHeight, iconHeight)); + } +} diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index c406821c9..7524d5035 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -117,6 +117,8 @@ protected: QModelIndexList getSelected(); + void updateFontSize(); + /** Defines the actions for the context menu for QTreeWidget */ QAction* copylinkAct; QAction* sendlinkAct; diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.ui b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.ui index b732d0464..dbcba0011 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.ui +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.ui @@ -356,11 +356,6 @@ border-image: url(:/images/closepressed.png) 0 - - - 11 - - Qt::CustomContextMenu diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index 429a5bfb4..065abacee 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -27,8 +27,8 @@ #include "ChatDialog.h" #include "PopupChatWindow.h" -Q_DECLARE_METATYPE(RsGxsId) -Q_DECLARE_METATYPE(QList) +// Q_DECLARE_METATYPE(RsGxsId) +// Q_DECLARE_METATYPE(QList) class GxsIdChooser ; class QToolButton; @@ -101,7 +101,7 @@ private: void muteParticipant(const RsGxsId& id); void unMuteParticipant(const RsGxsId& id); bool isNicknameInLobby(const RsGxsId& id); - + ChatLobbyId lobbyId; QString _lobby_name ; time_t lastUpdateListTime; @@ -117,7 +117,7 @@ private: /** Qt Designer generated object */ Ui::ChatLobbyDialog ui; - + /** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */ std::set mutedParticipants; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index a909e3e27..ab198fa33 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -474,6 +474,7 @@ void ChatWidget::processSettings(bool load) // state of splitter ui->chatVSplitter->restoreState(Settings->value("ChatSplitter").toByteArray()); } else { + shrinkChatTextEdit(false); // save settings // state of splitter @@ -643,6 +644,16 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event) } } else if (obj == ui->chatTextEdit) { + if (chatType() == CHATTYPE_LOBBY) { + #define EVENT_IS(q_event) (event->type() == QEvent::q_event) + if (EVENT_IS(FocusIn)) { + if (was_shrinked) { + shrinkChatTextEdit(false); + } + } + #undef EVENT_IS + } + if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast(event); @@ -905,11 +916,19 @@ void ChatWidget::showEvent(QShowEvent */*event*/) QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar(); bool is_scrollbar_at_end = scrollbar->value() == scrollbar->maximum(); bool is_chat_text_edit_empty = ui->chatTextEdit->toPlainText().isEmpty(); + // show event will not be called on every change of focus if (is_scrollbar_at_end || !is_chat_text_edit_empty) { + if (!firstShow) { + shrinkChatTextEdit(false); + } focusDialog(); } else { - // otherwise focus will be get even not chat itself + // otherwise, focus will not even be gotten by chat itself ui->textBrowser->setFocus(); + + if (!firstShow && !was_shrinked) { + shrinkChatTextEdit(true); + } } ChatUserNotify::clearWaitingChat(chatId); @@ -923,6 +942,11 @@ void ChatWidget::showEvent(QShowEvent */*event*/) void ChatWidget::resizeEvent(QResizeEvent */*event*/) { + // it's about resize all chat window, not about chattextedit + // just unshrink it and do not bother + if (was_shrinked) { + shrinkChatTextEdit(false); + } // Workaround: now the scroll position is correct calculated QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar(); scrollbar->setValue(scrollbar->maximum()); @@ -1967,3 +1991,50 @@ void ChatWidget::saveSticker() filename = Emoticons::importedStickerPath() + "/" + filename + ".png"; ImageUtil::extractImage(window(), cursor, filename); } + +void ChatWidget::shrinkChatTextEdit(bool shrink_me) +{ + // here and at eventfiltert check + if (chatType() != CHATTYPE_LOBBY) + return; + if (!Settings->getShrinkChatTextEdit()) { + if (was_shrinked) { + ui->chatVSplitter->setSizes(_chatvsplitter_saved_size); + } + _chatvsplitter_saved_size.clear(); + was_shrinked = false; + } + + if (Settings->getShrinkChatTextEdit()) { + if (shrink_me) { + if (!was_shrinked) { + _chatvsplitter_saved_size = ui->chatVSplitter->sizes(); + + QList shrinked_v_splitter_size = _chatvsplitter_saved_size; + // #define TEXT_BROWSER ui->chatVSplitter->indexOf(ui->textBrowser) + #define TEXT_BROWSER 0 + // when you will update the layout one more time change this appropriately + // #define BELOW_TEXT_BROWSER ui->chatVSplitter->indexOf(ui->chatVSplitter->widget(1)) + #define BELOW_TEXT_BROWSER 1 + int height_diff = shrinked_v_splitter_size[BELOW_TEXT_BROWSER] - ui->chatTextEdit->minimumHeight(); + shrinked_v_splitter_size[BELOW_TEXT_BROWSER] = ui->chatTextEdit->minimumHeight(); + shrinked_v_splitter_size[TEXT_BROWSER] += height_diff; + ui->chatVSplitter->setSizes( shrinked_v_splitter_size ); + #undef TEXT_BROWSER + #undef BELOW_TEXT_BROWSER + was_shrinked = true; + } + } else { // (!shrink_me) + if (was_shrinked) { + // to not shrink/unshrink at every entry into chat + // when unshrinked state is enough to a browser be scrollable, but shrinked - not + QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar(); + bool is_scrollbar_at_end = scrollbar->value() == scrollbar->maximum(); + ui->chatVSplitter->setSizes(_chatvsplitter_saved_size); + if (is_scrollbar_at_end) + scrollbar->setValue(scrollbar->maximum()); + was_shrinked = false; + } + } + } +} diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index b9ff7086f..82fb6a486 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -215,6 +215,8 @@ private: void completeNickname(bool reverse); QAbstractItemModel *modelFromPeers(); + void shrinkChatTextEdit(bool shrink_me); + ChatId chatId; QString title; QString name; @@ -264,6 +266,9 @@ private: QCompleter *completer; ImHistoryBrowser* imBrowser; + QList _chatvsplitter_saved_size; + bool was_shrinked = false; + QList mChatWidgetHolder; ChatLobbyUserNotify* notify; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index 879c99d00..d46093071 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -661,7 +661,7 @@ border-image: url(:/images/closepressed.png) 0 - 30 + 40 diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index f9324d5fc..1f15345b1 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -34,6 +34,7 @@ #include "util/misc.h" #include "rshare.h" +#include #include #include @@ -100,6 +101,17 @@ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WindowFlags f connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); + voteNegative = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), + tr("Ban this person (Sets negative opinion)"), this); + voteNeutral = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), + tr("Give neutral opinion"), this); + votePositive = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), + tr("Give positive opinion"), this); + + connect(votePositive, SIGNAL(triggered()), this, SLOT(voteParticipant())); + connect(voteNeutral, SIGNAL(triggered()), this, SLOT(voteParticipant())); + connect(voteNegative, SIGNAL(triggered()), this, SLOT(voteParticipant())); + connect(ui.tabWidget, SIGNAL(tabChanged(ChatDialog*)), this, SLOT(tabChanged(ChatDialog*))); connect(ui.tabWidget, SIGNAL(tabClosed(ChatDialog*)), this, SLOT(tabClosed(ChatDialog*))); @@ -116,6 +128,37 @@ void PopupChatWindow::showContextMenu(QPoint) QMenu contextMnu(this); contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/highlight.png"),tr("Choose window color..."),this,SLOT(setStyle())); + ChatId ch_id = getCurrentDialog()->getChatId(); + if (ch_id.isDistantChatId()) { + DistantChatPeerId dc_id = ch_id.toDistantChatId(); + DistantChatPeerInfo dc_info; + if(rsMsgs->getDistantChatStatus(dc_id, dc_info)) { + RsGxsId gxs_id = dc_info.to_id; + if(!gxs_id.isNull() && !rsIdentity->isOwnId(gxs_id)) { + contextMnu.addAction(votePositive); + contextMnu.addAction(voteNeutral); + contextMnu.addAction(voteNegative); + + votePositive->setEnabled(false); + voteNeutral ->setEnabled(false); + voteNegative->setEnabled(false); + + RsOpinion rs_rep; + rsReputations->getOwnOpinion(gxs_id, rs_rep); + if (rsReputations->getOwnOpinion(gxs_id, rs_rep)) { + votePositive->setEnabled(rs_rep != RsOpinion::POSITIVE); + voteNeutral->setEnabled( ( rs_rep == RsOpinion::POSITIVE ) + || ( rs_rep == RsOpinion::NEGATIVE ) ); + voteNegative->setEnabled(rs_rep != RsOpinion::NEGATIVE); + + votePositive->setData(QVariant::fromValue(gxs_id)); + voteNeutral ->setData(QVariant::fromValue(gxs_id)); + voteNegative->setData(QVariant::fromValue(gxs_id)); + } + } + } + } + if (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) { if(tabbedWindow) @@ -457,3 +500,17 @@ void PopupChatWindow::blink(bool on) setWindowIcon(on ? mBlinkIcon : *mEmptyIcon); } } + +void PopupChatWindow::voteParticipant() +{ + QAction *act = dynamic_cast(sender()) ; + if (!act) { + return ; + } + + RsOpinion opinion = RsOpinion::NEUTRAL; + if (act == voteNeutral) opinion = RsOpinion::NEUTRAL; + if (act == votePositive) opinion = RsOpinion::POSITIVE; + if (act == voteNegative) opinion = RsOpinion::NEGATIVE; + rsReputations->setOwnOpinion(act->data().value(), opinion); +} diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.h b/retroshare-gui/src/gui/chat/PopupChatWindow.h index 86f8ebc80..968531ea1 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.h +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.h @@ -27,6 +27,8 @@ #include "ui_PopupChatWindow.h" #include #include +Q_DECLARE_METATYPE(RsGxsId) +Q_DECLARE_METATYPE(QList) class ChatDialog; @@ -67,6 +69,7 @@ private slots: void setOnTop(); void blink(bool on); void showContextMenu(QPoint p); + void voteParticipant(); private: bool tabbedWindow; @@ -75,6 +78,9 @@ private: ChatDialog *chatDialog; QIcon mBlinkIcon; QIcon *mEmptyIcon; + QAction* votePositive; + QAction* voteNegative; + QAction* voteNeutral; ChatDialog *getCurrentDialog(); void saveSettings(); diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index b240e216d..86cfaf816 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -135,6 +135,7 @@ void ChatPage::updateChatParams() Settings->setChatSendAsPlainTextByDef(ui.sendAsPlainTextByDef->isChecked()); Settings->setChatLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); Settings->setChatDoNotSendIsTyping(ui.DontSendTyping->isChecked()); + Settings->setShrinkChatTextEdit(ui.shrinkChatTextEdit->isChecked()); } void ChatPage::updateChatSearchParams() @@ -248,6 +249,7 @@ ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.sendAsPlainTextByDef, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); connect(ui.loadEmbeddedImages, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); connect(ui.DontSendTyping, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); + connect(ui.shrinkChatTextEdit, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); connect(ui.sbSearch_CharToStart, SIGNAL(valueChanged(int)), this, SLOT(updateChatSearchParams())); connect(ui.cbSearch_CaseSensitively, SIGNAL(toggled(bool)), this, SLOT(updateChatSearchParams())); @@ -403,6 +405,7 @@ ChatPage::load() whileBlocking(ui.sendAsPlainTextByDef)->setChecked(Settings->getChatSendAsPlainTextByDef()); whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getChatLoadEmbeddedImages()); whileBlocking(ui.DontSendTyping)->setChecked(Settings->getChatDoNotSendIsTyping()); + whileBlocking(ui.shrinkChatTextEdit)->setChecked(Settings->getShrinkChatTextEdit()); std::string advsetting; if(rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES")) diff --git a/retroshare-gui/src/gui/settings/ChatPage.ui b/retroshare-gui/src/gui/settings/ChatPage.ui index f33362563..0f60752ac 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.ui +++ b/retroshare-gui/src/gui/settings/ChatPage.ui @@ -95,6 +95,16 @@ + + + + When focus on text browser after showing chat room + + + Shrink text edit field when not needed + + + diff --git a/retroshare-gui/src/gui/settings/TransferPage.cpp b/retroshare-gui/src/gui/settings/TransferPage.cpp index 2faa8d5f7..3575a5479 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.cpp +++ b/retroshare-gui/src/gui/settings/TransferPage.cpp @@ -53,6 +53,7 @@ TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags) QObject::connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) ); QObject::connect(ui.editShareButton, SIGNAL(clicked()), this, SLOT(editDirectories())); QObject::connect(ui.autoCheckDirectories_CB, SIGNAL(clicked(bool)), this, SLOT(toggleAutoCheckDirectories(bool))); + QObject::connect(ui.minimumFontSize_SB, SIGNAL(valueChanged(int)), this, SLOT(updateFontSize())) ; QObject::connect(ui.autoCheckDirectories_CB, SIGNAL(toggled(bool)), this,SLOT(updateAutoCheckDirectories())) ; QObject::connect(ui.autoCheckDirectoriesDelay_SB,SIGNAL(valueChanged(int)),this,SLOT(updateAutoScanDirectoriesPeriod())) ; @@ -188,6 +189,10 @@ void TransferPage::load() whileBlocking(ui.suffixesIgnoreList_CB)->setChecked( ignore_flags & RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES ) ; whileBlocking(ui.prefixesIgnoreList_LE)->setText( ignore_prefixes_string ); whileBlocking(ui.suffixesIgnoreList_LE)->setText( ignore_suffixes_string ); + + Settings->beginGroup(QString("File")); + whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 11 ).toInt()); + Settings->endGroup(); } void TransferPage::updateDefaultStrategy(int i) @@ -290,6 +295,13 @@ void TransferPage::editDirectories() ShareManager::showYourself() ; } +void TransferPage::updateFontSize() +{ + Settings->beginGroup(QString("File")); + Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); + Settings->endGroup(); +} + void TransferPage::updateAutoCheckDirectories() { rsFiles->setWatchEnabled(ui.autoCheckDirectories_CB->isChecked()) ; } void TransferPage::updateAutoScanDirectoriesPeriod() { rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()); } void TransferPage::updateShareDownloadDirectory() { rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked());} diff --git a/retroshare-gui/src/gui/settings/TransferPage.h b/retroshare-gui/src/gui/settings/TransferPage.h index 19ceedfca..1a88d29d5 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.h +++ b/retroshare-gui/src/gui/settings/TransferPage.h @@ -58,6 +58,7 @@ class TransferPage: public ConfigPage void updateAutoDLColl(); void setPartialsDirectory(); void toggleAutoCheckDirectories(bool); + void updateFontSize(); void updateAutoCheckDirectories() ; void updateAutoScanDirectoriesPeriod() ; diff --git a/retroshare-gui/src/gui/settings/TransferPage.ui b/retroshare-gui/src/gui/settings/TransferPage.ui index 982df905e..282c5ff51 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.ui +++ b/retroshare-gui/src/gui/settings/TransferPage.ui @@ -299,6 +299,40 @@ p, li { white-space: pre-wrap; } + + + + + Minimum font size for Shared Files + + + + + + + 11 + + + 64 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + Qt::Vertical diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 3411c78f7..586d4df4f 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -537,6 +537,16 @@ void RshareSettings::setChatSendAsPlainTextByDef(bool bValue) setValueToGroup("Chat", "SendAsPlainTextByDef", bValue); } +bool RshareSettings::getShrinkChatTextEdit() +{ + return valueFromGroup("Chat", "ShrinkChatTextEdit", false).toBool(); +} + +void RshareSettings::setShrinkChatTextEdit(bool bValue) +{ + setValueToGroup("Chat", "ShrinkChatTextEdit", bValue); +} + bool RshareSettings::getChatSearchShowBarByDefault() { return valueFromGroup("Chat", "SearchShowBarByDefault", false).toBool(); diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index abf728391..362e52606 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -217,6 +217,9 @@ public: bool getChatSendAsPlainTextByDef(); void setChatSendAsPlainTextByDef(bool bValue); + bool getShrinkChatTextEdit(); + void setShrinkChatTextEdit(bool bValue); + bool getChatSearchShowBarByDefault(); void setChatSearchShowBarByDefault(bool bValue);