1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'master' of https://github.com/tux3/qTox into FriendListLayoutFix

This commit is contained in:
bitok 2015-10-08 22:55:42 +03:00
commit af7b8b7a25
13 changed files with 921 additions and 834 deletions

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
{
case ACTION:
senderText = "*";
text = wrapDiv(QString("%1 %2").arg(sender, text), "action");
text = wrapDiv(QString("%1 %2").arg(sender.toHtmlEscaped(), text), "action");
msg->setAsAction();
break;
case ALERT:

View File

@ -188,7 +188,7 @@ bool IPC::waitUntilAccepted(time_t postTime, int32_t timeout/*=-1*/)
while (!(result = isEventAccepted(postTime)))
{
qApp->processEvents();
QThread::sleep(10);
QThread::msleep(10);
if (timeout > 0 && difftime(time(0), start) >= timeout)
break;
}

View File

@ -858,6 +858,9 @@ QSplitter:handle{
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
<item>
@ -937,6 +940,9 @@ QSplitter:handle{
<pointsize>8</pointsize>
</font>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
</layout>

View File

@ -1003,7 +1003,7 @@ void ChatForm::setFriendTyping(bool isTyping)
chatWidget->setTypingNotificationVisible(isTyping);
Text* text = static_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>");
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName().toHtmlEscaped()) + "</div>");
}
void ChatForm::show(ContentLayout* contentLayout)
@ -1093,5 +1093,17 @@ void ChatForm::hideNetcam()
void ChatForm::retranslateUi()
{
QString volObjectName = volButton->objectName();
QString micObjectName = micButton->objectName();
loadHistoryAction->setText(tr("Load chat history..."));
if (volObjectName == QStringLiteral("green"))
volButton->setToolTip(tr("Mute call"));
else if (volObjectName == QStringLiteral("red"))
volButton->setToolTip(tr("Unmute call"));
if (micObjectName == QStringLiteral("green"))
micButton->setToolTip(tr("Mute microphone"));
else if (micObjectName == QStringLiteral("red"))
micButton->setToolTip(tr("Unmute microphone"));
}

View File

@ -254,7 +254,7 @@ QDate GenericChatForm::getLatestDate() const
void GenericChatForm::setName(const QString &newName)
{
nameLabel->setText(newName);
nameLabel->setToolTip(newName); // for overlength names
nameLabel->setToolTip(newName.toHtmlEscaped()); // for overlength names
}
void GenericChatForm::show(ContentLayout* contentLayout)
@ -294,17 +294,18 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos)
ChatMessage::Ptr GenericChatForm::addMessage(const ToxId& author, const QString &message, bool isAction,
const QDateTime &datetime, bool isSent)
{
QString authorStr = author.isActiveProfile() ? Core::getInstance()->getUsername() : resolveToxId(author);
bool authorIsActiveProfile = author.isActiveProfile();
QString authorStr = authorIsActiveProfile ? Core::getInstance()->getUsername() : resolveToxId(author);
ChatMessage::Ptr msg;
if (isAction)
{
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ACTION, false);
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ACTION, authorIsActiveProfile);
previousId.clear();
}
else
{
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL, author.isActiveProfile());
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL, authorIsActiveProfile);
if ( (author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter) )
msg->hideSender();
@ -512,12 +513,27 @@ bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
void GenericChatForm::retranslateUi()
{
QString callObjectName = callButton->objectName();
QString videoObjectName = videoButton->objectName();
if (callObjectName == QStringLiteral("green"))
callButton->setToolTip(tr("Start audio call"));
else if (callObjectName == QStringLiteral("yellow"))
callButton->setToolTip(tr("Accept audio call"));
else if (callObjectName == QStringLiteral("red"))
callButton->setToolTip(tr("End audio call"));
if (videoObjectName == QStringLiteral("green"))
videoButton->setToolTip(tr("Start video call"));
else if (videoObjectName == QStringLiteral("yellow"))
videoButton->setToolTip(tr("Accept video call"));
else if (videoObjectName == QStringLiteral("red"))
videoButton->setToolTip(tr("End video call"));
sendButton->setToolTip(tr("Send message"));
emoteButton->setToolTip(tr("Smileys"));
fileButton->setToolTip(tr("Send file(s)"));
screenshotButton->setToolTip(tr("Send a screenshot"));
callButton->setToolTip(tr("Start an audio call"));
videoButton->setToolTip(tr("Start a video call"));
saveChatAction->setText(tr("Save chat log"));
clearAction->setText(tr("Clear displayed messages"));
}

View File

@ -164,7 +164,11 @@ void GroupChatForm::onSendTriggered()
void GroupChatForm::onUserListChanged()
{
nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(group->getPeersCount()));
int peersCount = group->getPeersCount();
if (peersCount == 1)
nusersLabel->setText(tr("1 user in chat", "Number of users in chat"));
else
nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(peersCount));
QLayoutItem *child;
while ((child = namesListLayout->takeAt(0)))
@ -204,7 +208,7 @@ void GroupChatForm::onUserListChanged()
}
// Enable or disable call button
if (group->getPeersCount() != 1)
if (peersCount != 1)
{
callButton->setEnabled(true);
callButton->setObjectName("green");
@ -367,5 +371,9 @@ void GroupChatForm::keyReleaseEvent(QKeyEvent* ev)
void GroupChatForm::retranslateUi()
{
nusersLabel->setText(GroupChatForm::tr("%1 users in chat", "Number of users in chat").arg(group->getPeersCount()));
int peersCount = group->getPeersCount();
if (peersCount == 1)
nusersLabel->setText(tr("1 user in chat", "Number of users in chat"));
else
nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(peersCount));
}

View File

@ -479,5 +479,7 @@ bool GeneralForm::eventFilter(QObject *o, QEvent *e)
void GeneralForm::retranslateUi()
{
int proxyType = bodyUI->proxyType->currentIndex();
bodyUI->retranslateUi(this);
bodyUI->proxyType->setCurrentIndex(proxyType);
}

View File

@ -27,6 +27,7 @@
#include "src/widget/style.h"
#include "src/core/core.h"
#include "tool/croppinglabel.h"
#include "src/widget/translator.h"
#include <QPalette>
#include <QMenu>
#include <QContextMenuEvent>
@ -56,6 +57,7 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128));
}
});
Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this);
}
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
@ -82,7 +84,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
menu.addSeparator();
QAction* setTitle = menu.addAction(tr("Set title..."));
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* selectedItem = menu.exec(event->globalPos());
@ -145,9 +147,13 @@ void GroupWidget::onUserListChanged()
{
Group* g = GroupList::findGroup(groupId);
if (g)
statusMessageLabel->setText(tr("%1 users in chat").arg(g->getPeersCount()));
else
statusMessageLabel->setText(tr("0 users in chat"));
{
int peersCount = g->getPeersCount();
if (peersCount == 1)
statusMessageLabel->setText(tr("1 user in chat"));
else
statusMessageLabel->setText(tr("%1 users in chat").arg(peersCount));
}
}
void GroupWidget::setAsActiveChatroom()
@ -249,3 +255,16 @@ void GroupWidget::setName(const QString& name)
{
nameLabel->setText(name);
}
void GroupWidget::retranslateUi()
{
Group* g = GroupList::findGroup(groupId);
if (g)
{
int peersCount = g->getPeersCount();
if (peersCount == 1)
statusMessageLabel->setText(tr("1 user in chat"));
else
statusMessageLabel->setText(tr("%1 users in chat").arg(peersCount));
}
}

View File

@ -52,6 +52,9 @@ protected:
void dragLeaveEvent(QDragLeaveEvent* ev) override;
void dropEvent(QDropEvent* ev) override;
private:
void retranslateUi();
public:
int groupId;
};

View File

@ -8,7 +8,7 @@ RemoveFriendDialog::RemoveFriendDialog(QWidget *parent, const Friend *f)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setAttribute(Qt::WA_QuitOnClose, false);
ui.setupUi(this);
ui.label->setText(ui.label->text().replace("&lt;name&gt;", f->getDisplayedName()));
ui.label->setText(ui.label->text().replace("&lt;name&gt;", f->getDisplayedName().toHtmlEscaped()));
auto removeButton = ui.buttonBox->button(QDialogButtonBox::Ok);
auto cancelButton = ui.buttonBox->button(QDialogButtonBox::Cancel);
removeButton->setText(tr("Remove"));

View File

@ -341,7 +341,16 @@ void Widget::init()
//restore window state
restoreGeometry(Settings::getInstance().getWindowGeometry());
restoreState(Settings::getInstance().getWindowState());
ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState());
if (!ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState()))
{
// Set the status panel (friendlist) to a reasonnable width by default/on first start
constexpr int spWidthPc = 33;
ui->mainSplitter->resize(size());
QList<int> sizes = ui->mainSplitter->sizes();
sizes[0] = ui->mainSplitter->width()*spWidthPc/100;
sizes[1] = ui->mainSplitter->width() - sizes[0];
ui->mainSplitter->setSizes(sizes);
}
connect(settingsWidget, &SettingsWidget::compactToggled, contactListWidget, &FriendListWidget::onCompactChanged);
connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged);
@ -451,6 +460,16 @@ Widget* Widget::getInstance()
return instance;
}
void Widget::moveEvent(QMoveEvent *event)
{
if (event->type() == QEvent::Move)
{
saveWindowGeometry();
saveSplitterGeometry();
}
QWidget::moveEvent(event);
}
void Widget::closeEvent(QCloseEvent *event)
{
if (Settings::getInstance().getShowSystemTray() && Settings::getInstance().getCloseToTray() == true)
@ -801,7 +820,7 @@ void Widget::setUsername(const QString& username)
else
{
ui->nameLabel->setText(username);
ui->nameLabel->setToolTip(username); // for overlength names
ui->nameLabel->setToolTip(username.toHtmlEscaped()); // for overlength names
}
QString sanename = username;
@ -826,7 +845,7 @@ void Widget::setStatusMessage(const QString &statusMessage)
else
{
ui->statusLabel->setText(statusMessage);
ui->statusLabel->setToolTip(statusMessage); // for overlength messsages
ui->statusLabel->setToolTip(statusMessage.toHtmlEscaped()); // for overlength messsages
}
}
@ -1425,7 +1444,7 @@ void Widget::onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray in
{
if (type == TOX_GROUPCHAT_TYPE_TEXT || type == TOX_GROUPCHAT_TYPE_AV)
{
if (GUI::askQuestion(tr("Group invite", "popup title"), tr("%1 has invited you to a groupchat. Would you like to join?", "popup text").arg(Nexus::getCore()->getFriendUsername(friendId)), true, false))
if (GUI::askQuestion(tr("Group invite", "popup title"), tr("%1 has invited you to a groupchat. Would you like to join?", "popup text").arg(Nexus::getCore()->getFriendUsername(friendId).toHtmlEscaped()), true, false))
{
int groupId = Nexus::getCore()->joinGroupchat(friendId, type, (uint8_t*)invite.data(), invite.length());
if (groupId < 0)

View File

@ -157,6 +157,7 @@ protected:
virtual void closeEvent(QCloseEvent *event) final override;
virtual void changeEvent(QEvent *event) final override;
virtual void resizeEvent(QResizeEvent *event) final override;
virtual void moveEvent(QMoveEvent *event) final override;
private slots:
void onAddClicked();