mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: remove getInstance from AddFriendForm
This commit is contained in:
parent
c73cedf2a0
commit
19f4a6c4e0
|
@ -61,10 +61,12 @@ namespace
|
||||||
* @brief Cached username so we can retranslate the invite message
|
* @brief Cached username so we can retranslate the invite message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
AddFriendForm::AddFriendForm()
|
AddFriendForm::AddFriendForm(ToxId _ownId)
|
||||||
|
: ownId{_ownId}
|
||||||
{
|
{
|
||||||
tabWidget = new QTabWidget();
|
tabWidget = new QTabWidget();
|
||||||
main = new QWidget(tabWidget), head = new QWidget();
|
main = new QWidget(tabWidget);
|
||||||
|
head = new QWidget();
|
||||||
QFont bold;
|
QFont bold;
|
||||||
bold.setBold(true);
|
bold.setBold(true);
|
||||||
headLabel.setFont(bold);
|
headLabel.setFont(bold);
|
||||||
|
@ -206,7 +208,7 @@ void AddFriendForm::addFriend(const QString& idText)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteFriendRequest(friendId);
|
deleteFriendRequest(friendId);
|
||||||
if (friendId == Core::getInstance()->getSelfId()) {
|
if (friendId == ownId) {
|
||||||
GUI::showWarning(tr("Couldn't add friend"),
|
GUI::showWarning(tr("Couldn't add friend"),
|
||||||
//: When trying to add your own Tox ID as friend
|
//: When trying to add your own Tox ID as friend
|
||||||
tr("You can't add yourself as a friend!"));
|
tr("You can't add yourself as a friend!"));
|
||||||
|
@ -301,8 +303,7 @@ void AddFriendForm::setIdFromClipboard()
|
||||||
const QClipboard* clipboard = QApplication::clipboard();
|
const QClipboard* clipboard = QApplication::clipboard();
|
||||||
const QString trimmedId = clipboard->text().trimmed();
|
const QString trimmedId = clipboard->text().trimmed();
|
||||||
const QString strippedId = getToxId(trimmedId);
|
const QString strippedId = getToxId(trimmedId);
|
||||||
const Core* core = Core::getInstance();
|
const bool isSelf = ToxId::isToxId(strippedId) && ToxId(strippedId) != ownId;
|
||||||
const bool isSelf = ToxId::isToxId(strippedId) && ToxId(strippedId) != core->getSelfId();
|
|
||||||
if (!strippedId.isEmpty() && ToxId::isToxId(strippedId) && isSelf) {
|
if (!strippedId.isEmpty() && ToxId::isToxId(strippedId) && isSelf) {
|
||||||
toxId.setText(trimmedId);
|
toxId.setText(trimmedId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
FriendRequest = 2
|
FriendRequest = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
AddFriendForm();
|
AddFriendForm(ToxId _ownId);
|
||||||
AddFriendForm(const AddFriendForm&) = delete;
|
AddFriendForm(const AddFriendForm&) = delete;
|
||||||
AddFriendForm& operator=(const AddFriendForm&) = delete;
|
AddFriendForm& operator=(const AddFriendForm&) = delete;
|
||||||
~AddFriendForm();
|
~AddFriendForm();
|
||||||
|
@ -111,4 +111,6 @@ private:
|
||||||
QList<QPushButton*> acceptButtons;
|
QList<QPushButton*> acceptButtons;
|
||||||
QList<QPushButton*> rejectButtons;
|
QList<QPushButton*> rejectButtons;
|
||||||
QList<QString> contactsToImport;
|
QList<QString> contactsToImport;
|
||||||
|
|
||||||
|
ToxId ownId;
|
||||||
};
|
};
|
||||||
|
|
|
@ -275,7 +275,7 @@ void Widget::init()
|
||||||
Style::setThemeColor(settings.getThemeColor());
|
Style::setThemeColor(settings.getThemeColor());
|
||||||
|
|
||||||
filesForm = new FilesForm();
|
filesForm = new FilesForm();
|
||||||
addFriendForm = new AddFriendForm;
|
addFriendForm = new AddFriendForm(core->getSelfId());
|
||||||
groupInviteForm = new GroupInviteForm;
|
groupInviteForm = new GroupInviteForm;
|
||||||
|
|
||||||
core = &profile.getCore();
|
core = &profile.getCore();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user