Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(groupinviteform): translation invite message
Browse files Browse the repository at this point in the history
Fix #3083.
* Add time in GrupInvite struct
* Add translation to invite message
* Add set of invite message
* Add correct removing invite message
  • Loading branch information
Diadlo committed Apr 13, 2016
1 parent 24b28b1 commit 24efaf0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
20 changes: 19 additions & 1 deletion src/widget/form/groupinviteform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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())
Expand Down Expand Up @@ -151,7 +153,6 @@ void GroupInviteForm::onGroupInviteRejected()
int index = inviteLayout->indexOf(groupWidget);
groupInvites.removeAt(index);


deleteInviteButtons(groupWidget);
}

Expand All @@ -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);
}
Expand All @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions src/widget/form/groupinviteform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,7 +43,7 @@ class GroupInviteForm : public QWidget
GroupInviteForm();
~GroupInviteForm();

void show(ContentLayout *contentLayout);
void show(ContentLayout* contentLayout);
void addGroupInvite(int32_t friendId, uint8_t type, QByteArray invite);
bool isShown() const;

Expand All @@ -63,6 +63,7 @@ private slots:
void retranslateUi();
void retranslateAcceptButton(QPushButton* acceptButton);
void retranslateRejectButton(QPushButton* rejectButton);
void retranslateGroupLabel(CroppingLabel* label);
void deleteInviteButtons(QWidget* widget);

private:
Expand All @@ -71,6 +72,7 @@ private slots:
int32_t friendId;
uint8_t type;
QByteArray invite;
QDateTime time;
};

QWidget* headWidget;
Expand All @@ -80,6 +82,7 @@ private slots:
QVBoxLayout* inviteLayout;
QSet<QPushButton*> acceptButtons;
QSet<QPushButton*> rejectButtons;
QSet<CroppingLabel*> groupLabels;
QList<GroupInvite> groupInvites;
};

Expand Down

0 comments on commit 24efaf0

Please sign in to comment.