mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(groupinviteform): translation invite message
Fix #3083. * Add time in GrupInvite struct * Add translation to invite message * Add set of invite message * Add correct removing invite message
This commit is contained in:
parent
24b28b1e51
commit
24efaf0594
|
@ -96,6 +96,7 @@ void GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray
|
|||
QHBoxLayout* groupLayout = new QHBoxLayout(groupWidget);
|
||||
|
||||
CroppingLabel* groupLabel = new CroppingLabel(this);
|
||||
groupLabels.insert(groupLabel);
|
||||
QString name = Nexus::getCore()->getFriendUsername(friendId);
|
||||
QString time = QDateTime::currentDateTime().toString();
|
||||
groupLabel->setText(tr("Invited by <b>%1</b> on %2.").arg(name, time));
|
||||
|
@ -119,6 +120,7 @@ void GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray
|
|||
group.friendId = friendId;
|
||||
group.type = type;
|
||||
group.invite = invite;
|
||||
group.time = QDateTime::currentDateTime();
|
||||
groupInvites.push_front(group);
|
||||
|
||||
if (isVisible())
|
||||
|
@ -151,7 +153,6 @@ void GroupInviteForm::onGroupInviteRejected()
|
|||
int index = inviteLayout->indexOf(groupWidget);
|
||||
groupInvites.removeAt(index);
|
||||
|
||||
|
||||
deleteInviteButtons(groupWidget);
|
||||
}
|
||||
|
||||
|
@ -170,6 +171,9 @@ void GroupInviteForm::deleteInviteButtons(QWidget* widget)
|
|||
rejectButtons.remove(buttons.at(0));
|
||||
}
|
||||
|
||||
QList<CroppingLabel*> labels = widget->findChildren<CroppingLabel*>();
|
||||
groupLabels.remove(labels.at(0));
|
||||
|
||||
widget->deleteLater();
|
||||
inviteLayout->removeWidget(widget);
|
||||
}
|
||||
|
@ -188,6 +192,20 @@ void GroupInviteForm::retranslateUi()
|
|||
|
||||
for (QPushButton* rejectButton : rejectButtons)
|
||||
retranslateRejectButton(rejectButton);
|
||||
|
||||
for (CroppingLabel* label : groupLabels)
|
||||
retranslateGroupLabel(label);
|
||||
}
|
||||
|
||||
void GroupInviteForm::retranslateGroupLabel(CroppingLabel* label)
|
||||
{
|
||||
QWidget* groupWidget = label->parentWidget();
|
||||
int index = inviteLayout->indexOf(groupWidget);
|
||||
GroupInvite invite = groupInvites.at(index);
|
||||
|
||||
QString name = Nexus::getCore()->getFriendUsername(invite.friendId);
|
||||
QString date = invite.time.toString();
|
||||
label->setText(tr("Invited by <b>%1</b> on %2.").arg(name, date));
|
||||
}
|
||||
|
||||
void GroupInviteForm::retranslateAcceptButton(QPushButton* acceptButton)
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#ifndef GROUPINVITEFORM_H
|
||||
#define GROUPINVITEFORM_H
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QWidget>
|
||||
#include <QDateTime>
|
||||
#include <QSet>
|
||||
#include <src/widget/tool/croppinglabel.h>
|
||||
#include "src/widget/tool/croppinglabel.h"
|
||||
#include "src/widget/gui.h"
|
||||
|
||||
class QLabel;
|
||||
|
@ -63,6 +63,7 @@ private:
|
|||
void retranslateUi();
|
||||
void retranslateAcceptButton(QPushButton* acceptButton);
|
||||
void retranslateRejectButton(QPushButton* rejectButton);
|
||||
void retranslateGroupLabel(CroppingLabel* label);
|
||||
void deleteInviteButtons(QWidget* widget);
|
||||
|
||||
private:
|
||||
|
@ -71,6 +72,7 @@ private:
|
|||
int32_t friendId;
|
||||
uint8_t type;
|
||||
QByteArray invite;
|
||||
QDateTime time;
|
||||
};
|
||||
|
||||
QWidget* headWidget;
|
||||
|
@ -80,6 +82,7 @@ private:
|
|||
QVBoxLayout* inviteLayout;
|
||||
QSet<QPushButton*> acceptButtons;
|
||||
QSet<QPushButton*> rejectButtons;
|
||||
QSet<CroppingLabel*> groupLabels;
|
||||
QList<GroupInvite> groupInvites;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user