merged upstream/master

This commit is contained in:
csoler 2018-01-16 23:03:26 +01:00
commit 95e8fc4404
38 changed files with 785 additions and 340 deletions

View file

@ -1,28 +1,33 @@
#include <QTreeWidget>
#include <QTextBrowser>
#include <QTimer>
#include <QMenu>
#include <QMessageBox>
#include <time.h>
#include <algorithm>
#include "ChatLobbyWidget.h"
#include "chat/CreateLobbyDialog.h"
#include "chat/ChatTabWidget.h"
#include "common/RSTreeWidgetItem.h"
#include "notifyqt.h"
#include "chat/ChatLobbyDialog.h"
#include "chat/ChatLobbyUserNotify.h"
#include "util/HandleRichText.h"
#include "util/QtVersion.h"
#include "gui/settings/rsharesettings.h"
#include "chat/ChatTabWidget.h"
#include "chat/CreateLobbyDialog.h"
#include "common/RSTreeWidgetItem.h"
#include "gui/gxs/GxsIdDetails.h"
#include "gui/Identity/IdEditDialog.h"
#include "gui/settings/rsharesettings.h"
#include "util/HandleRichText.h"
#include "util/QtVersion.h"
#include "retroshare/rsmsgs.h"
#include "retroshare/rspeers.h"
#include "retroshare/rsnotify.h"
#include "retroshare/rsidentity.h"
#include <QGridLayout>
#include <QMenu>
#include <QMessageBox>
#include <QTextBrowser>
#include <QTimer>
#include <QTreeWidget>
#include <algorithm>
#include <time.h>
//#define CHAT_LOBBY_GUI_DEBUG 1
#define COLUMN_NAME 0
@ -61,6 +66,8 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
m_bProcessSettings = false;
myChatLobbyUserNotify = NULL;
myInviteYesButton = NULL;
myInviteIdChooser = NULL;
QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged()));
QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&)), this, SLOT(displayChatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&)));
@ -1081,8 +1088,8 @@ void ChatLobbyWidget::readChatLobbyInvites()
std::list<ChatLobbyId> subscribed_lobbies ;
rsMsgs->getChatLobbyList(subscribed_lobbies) ;
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it)
{
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it)
{
// first check if the lobby is already subscribed. If so, just ignore the request.
bool found = false ;
@ -1097,8 +1104,8 @@ void ChatLobbyWidget::readChatLobbyInvites()
QMessageBox::Question, QMessageBox::Yes,QMessageBox::No, 0);
QLabel *label ;
GxsIdChooser *idchooser = new GxsIdChooser ;
QLabel *label;
GxsIdChooser *idchooser = new GxsIdChooser;
if( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED )
{
@ -1110,18 +1117,24 @@ void ChatLobbyWidget::readChatLobbyInvites()
idchooser->loadIds(IDCHOOSER_ID_REQUIRED,default_id) ;
label = new QLabel(tr("Choose an identity for this chat room:"));
}
myInviteYesButton = mb.button(QMessageBox::Yes);
myInviteIdChooser = idchooser;
connect(idchooser, SIGNAL(currentIndexChanged(int)), this, SLOT(idChooserCurrentIndexChanged(int)));
idChooserCurrentIndexChanged(0);
QGridLayout* layout = qobject_cast<QGridLayout*>(mb.layout());
if (layout) {
layout->addWidget(label, layout->rowCount(), 0, 1, layout->columnCount(), Qt::AlignHCenter ) ;
layout->addWidget(idchooser, layout->rowCount(), 0, 1, layout->columnCount(), Qt::AlignRight ) ;
} else {
//Not QGridLayout so add at end
mb.layout()->addWidget(label) ;
mb.layout()->addWidget(idchooser) ;
}
QGridLayout* layout = qobject_cast<QGridLayout*>(mb.layout());
if (layout) {
layout->addWidget(label, layout->rowCount(), 0, 1, layout->columnCount(), Qt::AlignHCenter ) ;
layout->addWidget(idchooser, layout->rowCount(), 0, 1, layout->columnCount(), Qt::AlignRight ) ;
} else {
//Not QGridLayout so add at end
mb.layout()->addWidget(label) ;
mb.layout()->addWidget(idchooser) ;
}
int res = mb.exec() ;
int res = mb.exec();
myInviteYesButton = NULL;
myInviteIdChooser = NULL;
if (res == QMessageBox::No)
{
@ -1144,6 +1157,28 @@ void ChatLobbyWidget::readChatLobbyInvites()
std::cerr << "Can't join chat room with id 0x" << std::hex << (*it).lobby_id << std::dec << std::endl;
}
myInviteYesButton = NULL;
myInviteIdChooser = NULL;
}
void ChatLobbyWidget::idChooserCurrentIndexChanged(int /*index*/)
{
if (myInviteYesButton && myInviteIdChooser)
{
RsGxsId chosen_id;
switch (myInviteIdChooser->getChosenId(chosen_id))
{
case GxsIdChooser::KnowId:
case GxsIdChooser::UnKnowId:
myInviteYesButton->setEnabled(true);
break;
case GxsIdChooser::NoId:
case GxsIdChooser::None:
default: ;
myInviteYesButton->setEnabled(false);
}
}
}
void ChatLobbyWidget::filterColumnChanged(int)

View file

@ -1,10 +1,16 @@
#pragma once
#include <QTreeWidget>
#include <retroshare/rsmsgs.h>
#include "ui_ChatLobbyWidget.h"
#include "RsAutoUpdatePage.h"
#include "chat/ChatLobbyUserNotify.h"
#include "gui/gxs/GxsIdChooser.h"
#include <retroshare/rsmsgs.h>
#include <QAbstractButton>
#include <QTreeWidget>
#define IMAGE_CHATLOBBY ":/icons/png/chat-lobbies.png"
@ -82,6 +88,7 @@ private slots:
void setShowSubscribeColumn(bool show);
void updateNotify(ChatLobbyId id, unsigned int count) ;
void idChooserCurrentIndexChanged(int index);
private:
void autoSubscribeLobby(QTreeWidgetItem *item);
@ -114,6 +121,9 @@ private:
ChatLobbyUserNotify* myChatLobbyUserNotify;
QAbstractButton* myInviteYesButton;
GxsIdChooser* myInviteIdChooser;
/* UI - from Designer */
Ui::ChatLobbyWidget ui;
};

View file

@ -966,7 +966,7 @@ int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
QString fileName = QString::fromUtf8(fileInfo.fname.c_str());
DLListModel->setData(DLListModel->index(row, COLUMN_NAME), fileName);
DLListModel->setData(DLListModel->index(row, COLUMN_NAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(row, COLUMN_NAME), icon_cache.get_icon(fileName), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(row, COLUMN_COMPLETED), QVariant((qlonglong)completed));
DLListModel->setData(DLListModel->index(row, COLUMN_DLSPEED), QVariant((double)fileDlspeed));
@ -1166,7 +1166,7 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
//ULListModel->setItem(row, COLUMN_UPROGRESS, new ProgressItem(NULL));
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), fileName);
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), icon_cache.get_icon((fileName)), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash);
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash, Qt::UserRole);
}
@ -2288,3 +2288,65 @@ void TransfersDialog::filterChanged(const QString& /*text*/)
DLLFilterModel->setFilterKeyColumn(filterColumn);
DLLFilterModel->setFilterRegExp(text);
}
//shitcode begin
TransfersDialog_dirty_icon_cache::TransfersDialog_dirty_icon_cache() :
FileTypePicture(":/images/FileTypePicture.png"), FileTypeVideo(":/images/FileTypeVideo.png"), FileTypeAudio(":/images/FileTypeAudio.png"),
FileTypeArchive(":/images/FileTypeArchive.png"), FileTypeProgram(":/images/FileTypeProgram.png"), FileTypeCDImage(":/images/FileTypeCDImage.png"),
FileTypeDocument(":/images/FileTypeDocument.png"), pdf(":/images/mimetypes/pdf.png"), rscollection_16(":/images/mimetypes/rscollection-16.png"),
FileTypeAny(":/images/FileTypeAny.png"), patch(":/images/mimetypes/patch.png"), source_cpp(":/images/mimetypes/source_cpp.png"),
source_h(":/images/mimetypes/source_h.png"), source_c(":/images/mimetypes/source_c.png")
{
}
QIcon& TransfersDialog_dirty_icon_cache::get_icon(const QString& filename)
{
//mostly copypaste from static QString getInfoFromFilename(const QString& filename, bool anyForUnknown, bool image)
QString ext = QFileInfo(filename).suffix().toLower();
if (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "png" || ext == "gif" || ext == "bmp" || ext == "ico" || ext == "svg") {
return FileTypePicture;
} else if (ext == "avi" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "divx" || ext == "ts" ||
ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov" || ext == "asf" || ext == "xvid" ||
ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp" || ext == "ogm") {
return FileTypeVideo;
} else if (ext == "ogg" || ext == "mp3" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma" || ext == "m4a" || ext == "flac" ||ext == "xpm") {
return FileTypeAudio;
} else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "7z" || ext == "msi" ||
ext == "rar" || ext == "rpm" || ext == "ace" || ext == "jar" || ext == "tgz" || ext == "lha" ||
ext == "cab" || ext == "cbz"|| ext == "cbr" || ext == "alz" || ext == "sit" || ext == "arj" || ext == "deb") {
return FileTypeArchive;
} else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com" ||
ext == "exe" || ext == "js" || ext == "pif" ||
ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws") {
return FileTypeProgram;
} else if (ext == "iso" || ext == "nrg" || ext == "mdf" || ext == "img" || ext == "dmg" || ext == "bin" || ext == "uif") {
return FileTypeCDImage;
} else if (ext == "txt" || ext == "ui" ||
ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls" || ext == "pps" || ext == "xml" || ext == "nfo" ||
ext == "reg" || ext == "sxc" || ext == "odt" || ext == "ods" || ext == "dot" || ext == "ppt" || ext == "css" || ext == "crt" ||
ext == "html" || ext == "htm" || ext == "php") {
return FileTypeDocument;
} else if (ext == "pdf") {
return pdf;
} else if (ext == RsCollection::ExtensionString) {
return rscollection_16;
} else if (ext == "sub" || ext == "srt") {
return FileTypeAny;
} else if (ext == "nds") {
return FileTypeAny;
} else if (ext == "patch" || ext == "diff") {
return patch;
} else if (ext == "cpp") {
return source_cpp;
} else if (ext == "h") {
return source_h;
} else if (ext == "c") {
return source_c;
}
return FileTypeAny;
}
//shitcode end

View file

@ -45,6 +45,20 @@ class SearchDialog;
class LocalSharedFilesDialog;
class RemoteSharedFilesDialog;
//shitcode begin
class TransfersDialog_dirty_icon_cache
{
public:
TransfersDialog_dirty_icon_cache();
QIcon& get_icon(const QString& filename);
private:
QIcon FileTypePicture, FileTypeVideo, FileTypeAudio, FileTypeArchive, FileTypeProgram, FileTypeCDImage, FileTypeDocument, \
pdf, rscollection_16, FileTypeAny, patch, source_cpp, source_h, source_c;
};
//shitcode end
class TransfersDialog : public RsAutoUpdatePage
{
Q_OBJECT
@ -247,6 +261,8 @@ private:
QTreeView *downloadList;
TransfersDialog_dirty_icon_cache icon_cache;
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);

View file

@ -731,15 +731,6 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
}
}
} else {
if (event->type() == QEvent::WindowActivate) {
if (isVisible() && (window() == NULL || window()->isActiveWindow())) {
newMessages = false;
emit infoChanged(this);
focusDialog();
ChatUserNotify::clearWaitingChat(chatId);
}
}
}
// pass the event on to the parent class
return QWidget::eventFilter(obj, event);
@ -889,7 +880,17 @@ void ChatWidget::showEvent(QShowEvent */*event*/)
{
newMessages = false;
emit infoChanged(this);
focusDialog();
// if user waded through the jungle of history just let him on
// own decide whether to continue the journey or start typing
QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar();
bool is_scrollbar_at_end = scrollbar->value() == scrollbar->maximum();
bool is_chat_text_edit_empty = ui->chatTextEdit->toPlainText().isEmpty();
if (is_scrollbar_at_end || !is_chat_text_edit_empty) {
focusDialog();
} else {
// otherwise focus will be get even not chat itself
ui->textBrowser->setFocus();
}
ChatUserNotify::clearWaitingChat(chatId);
if (firstShow) {

View file

@ -25,13 +25,14 @@
#include "GxsIdDetails.h"
#include "RsGxsUpdateBroadcastBase.h"
#include "gui/Identity/IdEditDialog.h"
#include "util/misc.h"
#include <retroshare/rspeers.h>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <algorithm>
#include <retroshare/rspeers.h>
#include <iostream>
#define ROLE_SORT Qt::UserRole + 1 // Qt::UserRole is reserved for data
@ -247,7 +248,10 @@ uint32_t GxsIdChooser::countEnabledEntries() const
void GxsIdChooser::loadPrivateIds()
{
if (mFirstLoad) {
//whileBlocking doesn't work here.
bool prev = this->blockSignals(true);
clear();
this->blockSignals(prev);
}
std::list<RsGxsId> ids;

View file

@ -74,6 +74,15 @@ QWidget:item:selected
stop: 0 #78879b, stop: 1 #78879b);
}
QTableWidget::item {
color: #C0C0C0;
background-color: #201F1F;
}
QTableWidget::item:selected {
color: black;
}
ForumsDialog, GxsForumThreadWidget
{
qproperty-textColorRead: darkgray;
@ -824,6 +833,14 @@ QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
background: rgba(255, 255, 255, 10);
}
FriendList {
qproperty-textColorStatusAway: lightgray;
qproperty-textColorStatusBusy: lightgray;
qproperty-textColorStatusOnline: green;
qproperty-textColorStatusInactive: lightgray;
qproperty-textColorStatusOffline: gray;
}
QTreeView, QListView
{
border: 1px solid #78879b;
@ -834,10 +851,22 @@ QTreeView::item {
background-color: #201F1F;
}
QTreeView::item:!selected {
QTreeView::item:selected {
color: black;
}
RSTreeWidget#idTreeWidget::item:!selected {
color: #C0C0C0;
}
NetworkDialog {
qproperty-backgroundColorSelf: darkred;
qproperty-backgroundColorOwnSign: darkred;
qproperty-backgroundColorAcceptConnection: black;
qproperty-backgroundColorHasSignedMe: darkred;
qproperty-backgroundColorDenied: #201F1F;
}
QTreeView:branch:selected, QTreeView:branch:hover
{
background: url(qdarkstyle/transparent.png);