1
0
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:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-18 23:23:34 +01:00
commit e8234dec89
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
11 changed files with 62 additions and 17 deletions

View File

@ -340,6 +340,11 @@ void Core::bootstrapDht()
QList<Settings::DhtServer> dhtServerList = s.getDhtServerList();
int listSize = dhtServerList.size();
if (listSize == 0)
{
qDebug() << "Settings: no bootstrap list?!?";
return;
}
static int j = qrand() % listSize;
qDebug() << "Core: Bootstraping to the DHT ...";

View File

@ -129,8 +129,9 @@ void CroppingLabel::hideTextEdit(bool acceptText)
{
if (acceptText)
{
emit textChanged(textEdit->text(), origText);
setText(textEdit->text());
QString oldOrigText = origText;
setText(textEdit->text()); // set before emitting so we don't override external reactions to signal
emit textChanged(textEdit->text(), oldOrigText);
}
textEdit->hide();

View File

@ -76,6 +76,8 @@ ChatForm::ChatForm(Friend* chatFriend)
connect(chatWidget, &ChatAreaWidget::onFileTranfertInterract, this, &ChatForm::onFileTansBtnClicked);
connect(Core::getInstance(), &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
connect(this, SIGNAL(chatAreaCleared()), this, SLOT(clearReciepts()));
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString text, QString orig)
{if (text != orig) emit aliasChanged(text);} );
setAcceptDrops(true);
}

View File

@ -49,6 +49,7 @@ signals:
void cancelCall(int callId, int friendId);
void micMuteToggle(int callId);
void volMuteToggle(int callId);
void aliasChanged(const QString& alias);
public slots:
void deliverOfflineMsgs();

View File

@ -47,6 +47,7 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
nameLabel = new CroppingLabel();
nameLabel->setObjectName("nameLabel");
nameLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
nameLabel->setEditable(true);
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout();

View File

@ -52,7 +52,6 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
}
nameLabel->setText(group->widget->getName());
nameLabel->setEditable(true);
nusersLabel->setFont(Style::getFont(Style::Medium));
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(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
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);
}

View File

@ -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()
{
bool ok;
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);
if (ok)
{
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();
}
setAlias(alias);
}

View File

@ -44,6 +44,7 @@ signals:
public slots:
void onAvatarChange(int FriendId, const QPixmap& pic);
void onAvatarRemoved(int FriendId);
void setAlias(const QString& alias);
protected:
void mousePressEvent(QMouseEvent* ev);

View File

@ -27,6 +27,7 @@
#include <QContextMenuEvent>
#include <QMimeData>
#include <QDragEnterEvent>
#include <QInputDialog>
#include "ui_mainwindow.h"
@ -51,10 +52,25 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
QPoint pos = event->globalPos();
QMenu menu;
QAction* quitGroup = menu.addAction(tr("Quit group","Menu to quit a groupchat"));
QAction* setAlias = menu.addAction(tr("Set title..."));
QAction* selectedItem = menu.exec(pos);
if (selectedItem)
{
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()

View File

@ -466,11 +466,24 @@ void Widget::onSelfAvatarLoaded(const QPixmap& pic)
void Widget::onConnected()
{
ui->statusButton->setEnabled(true);
if (beforeDisconnect == Status::Offline)
emit statusSet(Status::Online);
else
emit statusSet(beforeDisconnect);
}
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);
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(micMuteToggle(int)), core, SLOT(micMuteToggle(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::avInvite, newfriend->getChatForm(), &ChatForm::onAvInvite);
connect(core, &Core::avStart, newfriend->getChatForm(), &ChatForm::onAvStart);

View File

@ -163,6 +163,7 @@ private:
MaskablePixmapWidget* profilePicture;
bool notify(QObject *receiver, QEvent *event);
bool autoAwayActive = false;
Status beforeDisconnect = Status::Offline;
QTimer* idleTimer;
QTranslator* translator;
};