mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr804'
This commit is contained in:
commit
e8234dec89
|
@ -340,6 +340,11 @@ void Core::bootstrapDht()
|
||||||
QList<Settings::DhtServer> dhtServerList = s.getDhtServerList();
|
QList<Settings::DhtServer> dhtServerList = s.getDhtServerList();
|
||||||
|
|
||||||
int listSize = dhtServerList.size();
|
int listSize = dhtServerList.size();
|
||||||
|
if (listSize == 0)
|
||||||
|
{
|
||||||
|
qDebug() << "Settings: no bootstrap list?!?";
|
||||||
|
return;
|
||||||
|
}
|
||||||
static int j = qrand() % listSize;
|
static int j = qrand() % listSize;
|
||||||
|
|
||||||
qDebug() << "Core: Bootstraping to the DHT ...";
|
qDebug() << "Core: Bootstraping to the DHT ...";
|
||||||
|
|
|
@ -129,8 +129,9 @@ void CroppingLabel::hideTextEdit(bool acceptText)
|
||||||
{
|
{
|
||||||
if (acceptText)
|
if (acceptText)
|
||||||
{
|
{
|
||||||
emit textChanged(textEdit->text(), origText);
|
QString oldOrigText = origText;
|
||||||
setText(textEdit->text());
|
setText(textEdit->text()); // set before emitting so we don't override external reactions to signal
|
||||||
|
emit textChanged(textEdit->text(), oldOrigText);
|
||||||
}
|
}
|
||||||
|
|
||||||
textEdit->hide();
|
textEdit->hide();
|
||||||
|
|
|
@ -76,6 +76,8 @@ ChatForm::ChatForm(Friend* chatFriend)
|
||||||
connect(chatWidget, &ChatAreaWidget::onFileTranfertInterract, this, &ChatForm::onFileTansBtnClicked);
|
connect(chatWidget, &ChatAreaWidget::onFileTranfertInterract, this, &ChatForm::onFileTansBtnClicked);
|
||||||
connect(Core::getInstance(), &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
|
connect(Core::getInstance(), &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
|
||||||
connect(this, SIGNAL(chatAreaCleared()), this, SLOT(clearReciepts()));
|
connect(this, SIGNAL(chatAreaCleared()), this, SLOT(clearReciepts()));
|
||||||
|
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString text, QString orig)
|
||||||
|
{if (text != orig) emit aliasChanged(text);} );
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ signals:
|
||||||
void cancelCall(int callId, int friendId);
|
void cancelCall(int callId, int friendId);
|
||||||
void micMuteToggle(int callId);
|
void micMuteToggle(int callId);
|
||||||
void volMuteToggle(int callId);
|
void volMuteToggle(int callId);
|
||||||
|
void aliasChanged(const QString& alias);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void deliverOfflineMsgs();
|
void deliverOfflineMsgs();
|
||||||
|
|
|
@ -47,6 +47,7 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
||||||
nameLabel = new CroppingLabel();
|
nameLabel = new CroppingLabel();
|
||||||
nameLabel->setObjectName("nameLabel");
|
nameLabel->setObjectName("nameLabel");
|
||||||
nameLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
nameLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
||||||
|
nameLabel->setEditable(true);
|
||||||
|
|
||||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||||
QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout();
|
QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout();
|
||||||
|
|
|
@ -52,7 +52,6 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
nameLabel->setText(group->widget->getName());
|
nameLabel->setText(group->widget->getName());
|
||||||
nameLabel->setEditable(true);
|
|
||||||
|
|
||||||
nusersLabel->setFont(Style::getFont(Style::Medium));
|
nusersLabel->setFont(Style::getFont(Style::Medium));
|
||||||
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
||||||
|
@ -82,7 +81,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
|
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
|
||||||
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
|
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
|
||||||
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString text, QString orig)
|
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString text, QString orig)
|
||||||
{if (text != orig) emit groupTitleChanged(group->groupId, text);} );
|
{if (text != orig) emit groupTitleChanged(group->groupId, text.left(128));} );
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,22 +218,26 @@ void FriendWidget::mouseMoveEvent(QMouseEvent *ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FriendWidget::setAlias(const QString& _alias)
|
||||||
|
{
|
||||||
|
QString alias = _alias.trimmed();
|
||||||
|
alias.remove(QRegExp("[\\t\\n\\v\\f\\r\\x0000]")); // we should really treat regular names this way as well (*ahem* zetok)
|
||||||
|
alias = alias.left(128); // same as TOX_MAX_NAME_LENGTH
|
||||||
|
Friend* f = FriendList::findFriend(friendId);
|
||||||
|
f->setAlias(alias);
|
||||||
|
Settings::getInstance().setFriendAlias(f->getToxID(), alias);
|
||||||
|
hide();
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
void FriendWidget::setFriendAlias()
|
void FriendWidget::setFriendAlias()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
Friend* f = FriendList::findFriend(friendId);
|
Friend* f = FriendList::findFriend(friendId);
|
||||||
|
|
||||||
QString alias = QInputDialog::getText(nullptr, tr("User alias"), tr("Alias:"), QLineEdit::Normal,
|
QString alias = QInputDialog::getText(nullptr, tr("User alias"), tr("You can also set this by clicking the chat form name.\nAlias:"), QLineEdit::Normal,
|
||||||
f->getDisplayedName(), &ok);
|
f->getDisplayedName(), &ok);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
setAlias(alias);
|
||||||
alias = alias.trimmed();
|
|
||||||
alias.remove(QRegExp("[\t\n\v\f\r]"));
|
|
||||||
alias = alias.left(128); // same as TOX_MAX_NAME_LENGTH
|
|
||||||
f->setAlias(alias);
|
|
||||||
Settings::getInstance().setFriendAlias(f->getToxID(), alias);
|
|
||||||
hide();
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ signals:
|
||||||
public slots:
|
public slots:
|
||||||
void onAvatarChange(int FriendId, const QPixmap& pic);
|
void onAvatarChange(int FriendId, const QPixmap& pic);
|
||||||
void onAvatarRemoved(int FriendId);
|
void onAvatarRemoved(int FriendId);
|
||||||
|
void setAlias(const QString& alias);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent* ev);
|
void mousePressEvent(QMouseEvent* ev);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
|
#include <QInputDialog>
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
@ -51,10 +52,25 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
QPoint pos = event->globalPos();
|
QPoint pos = event->globalPos();
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction* quitGroup = menu.addAction(tr("Quit group","Menu to quit a groupchat"));
|
QAction* quitGroup = menu.addAction(tr("Quit group","Menu to quit a groupchat"));
|
||||||
|
QAction* setAlias = menu.addAction(tr("Set title..."));
|
||||||
|
|
||||||
QAction* selectedItem = menu.exec(pos);
|
QAction* selectedItem = menu.exec(pos);
|
||||||
if (selectedItem == quitGroup)
|
if (selectedItem)
|
||||||
emit removeGroup(groupId);
|
{
|
||||||
|
if (selectedItem == quitGroup)
|
||||||
|
emit removeGroup(groupId);
|
||||||
|
else if (selectedItem == setAlias)
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
Group* g = GroupList::findGroup(groupId);
|
||||||
|
|
||||||
|
QString alias = QInputDialog::getText(nullptr, tr("Group title"), tr("You can also set this by clicking the chat form name.\nTitle:"), QLineEdit::Normal,
|
||||||
|
nameLabel->fullText(), &ok);
|
||||||
|
|
||||||
|
if (ok && alias != nameLabel->fullText())
|
||||||
|
emit g->chatForm->groupTitleChanged(groupId, alias.left(128));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::onUserListChanged()
|
void GroupWidget::onUserListChanged()
|
||||||
|
|
|
@ -466,11 +466,24 @@ void Widget::onSelfAvatarLoaded(const QPixmap& pic)
|
||||||
void Widget::onConnected()
|
void Widget::onConnected()
|
||||||
{
|
{
|
||||||
ui->statusButton->setEnabled(true);
|
ui->statusButton->setEnabled(true);
|
||||||
emit statusSet(Status::Online);
|
if (beforeDisconnect == Status::Offline)
|
||||||
|
emit statusSet(Status::Online);
|
||||||
|
else
|
||||||
|
emit statusSet(beforeDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onDisconnected()
|
void Widget::onDisconnected()
|
||||||
{
|
{
|
||||||
|
QString stat = ui->statusButton->property("status").toString();
|
||||||
|
if (stat == "online")
|
||||||
|
beforeDisconnect = Status::Online;
|
||||||
|
else if (stat == "busy")
|
||||||
|
beforeDisconnect = Status::Busy;
|
||||||
|
else if (stat == "away")
|
||||||
|
beforeDisconnect = Status::Away;
|
||||||
|
else
|
||||||
|
beforeDisconnect = Status::Offline;
|
||||||
|
|
||||||
ui->statusButton->setEnabled(false);
|
ui->statusButton->setEnabled(false);
|
||||||
emit statusSet(Status::Offline);
|
emit statusSet(Status::Offline);
|
||||||
}
|
}
|
||||||
|
@ -633,6 +646,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
||||||
connect(newfriend->getChatForm(), SIGNAL(cancelCall(int,int)), core, SLOT(cancelCall(int,int)));
|
connect(newfriend->getChatForm(), SIGNAL(cancelCall(int,int)), core, SLOT(cancelCall(int,int)));
|
||||||
connect(newfriend->getChatForm(), SIGNAL(micMuteToggle(int)), core, SLOT(micMuteToggle(int)));
|
connect(newfriend->getChatForm(), SIGNAL(micMuteToggle(int)), core, SLOT(micMuteToggle(int)));
|
||||||
connect(newfriend->getChatForm(), SIGNAL(volMuteToggle(int)), core, SLOT(volMuteToggle(int)));
|
connect(newfriend->getChatForm(), SIGNAL(volMuteToggle(int)), core, SLOT(volMuteToggle(int)));
|
||||||
|
connect(newfriend->getChatForm(), &ChatForm::aliasChanged, newfriend->getFriendWidget(), &FriendWidget::setAlias);
|
||||||
connect(core, &Core::fileReceiveRequested, newfriend->getChatForm(), &ChatForm::onFileRecvRequest);
|
connect(core, &Core::fileReceiveRequested, newfriend->getChatForm(), &ChatForm::onFileRecvRequest);
|
||||||
connect(core, &Core::avInvite, newfriend->getChatForm(), &ChatForm::onAvInvite);
|
connect(core, &Core::avInvite, newfriend->getChatForm(), &ChatForm::onAvInvite);
|
||||||
connect(core, &Core::avStart, newfriend->getChatForm(), &ChatForm::onAvStart);
|
connect(core, &Core::avStart, newfriend->getChatForm(), &ChatForm::onAvStart);
|
||||||
|
|
|
@ -163,6 +163,7 @@ private:
|
||||||
MaskablePixmapWidget* profilePicture;
|
MaskablePixmapWidget* profilePicture;
|
||||||
bool notify(QObject *receiver, QEvent *event);
|
bool notify(QObject *receiver, QEvent *event);
|
||||||
bool autoAwayActive = false;
|
bool autoAwayActive = false;
|
||||||
|
Status beforeDisconnect = Status::Offline;
|
||||||
QTimer* idleTimer;
|
QTimer* idleTimer;
|
||||||
QTranslator* translator;
|
QTranslator* translator;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user