2014-09-15 18:45:59 +08:00
|
|
|
/*
|
|
|
|
Copyright (C) 2014 by Project Tox <https://tox.im>
|
|
|
|
|
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
|
|
|
This program is libre software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the COPYING file for more details.
|
|
|
|
*/
|
|
|
|
|
2014-10-06 00:30:31 +08:00
|
|
|
#include "core.h"
|
2014-10-06 00:17:01 +08:00
|
|
|
#include "ui_identitysettings.h"
|
2014-09-15 18:45:59 +08:00
|
|
|
#include "identityform.h"
|
|
|
|
#include "widget/form/settingswidget.h"
|
2014-09-30 17:44:27 +08:00
|
|
|
#include "widget/croppinglabel.h"
|
|
|
|
#include "core.h"
|
2014-09-15 18:45:59 +08:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
2014-09-30 17:44:27 +08:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QClipboard>
|
2014-09-15 18:45:59 +08:00
|
|
|
|
2014-10-06 00:17:01 +08:00
|
|
|
IdentityForm::IdentityForm() :
|
|
|
|
GenericForm(tr("Your identity"), QPixmap(":/img/settings/identity.png"))
|
2014-09-15 18:45:59 +08:00
|
|
|
{
|
2014-10-06 00:17:01 +08:00
|
|
|
bodyUI = new Ui::IdentitySettings;
|
|
|
|
bodyUI->setupUi(this);
|
2014-09-30 17:44:27 +08:00
|
|
|
|
|
|
|
// tox
|
|
|
|
toxId = new ClickableTE();
|
|
|
|
QFont small;
|
|
|
|
small.setPixelSize(13);
|
|
|
|
small.setKerning(false);
|
2014-10-06 00:17:01 +08:00
|
|
|
|
2014-10-06 02:02:12 +08:00
|
|
|
// toxId->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
2014-09-30 17:44:27 +08:00
|
|
|
toxId->setReadOnly(true);
|
2014-10-06 02:02:12 +08:00
|
|
|
// toxId->setFrameStyle(QFrame::NoFrame);
|
|
|
|
// toxId->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
// toxId->setFixedHeight(toxId->document()->size().height()*2);
|
2014-09-30 17:44:27 +08:00
|
|
|
toxId->setFont(small);
|
|
|
|
|
2014-10-06 00:17:01 +08:00
|
|
|
bodyUI->toxGroup->layout()->addWidget(toxId);
|
2014-09-30 17:44:27 +08:00
|
|
|
|
2014-10-06 00:17:01 +08:00
|
|
|
connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
2014-09-30 17:44:27 +08:00
|
|
|
connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
2014-10-06 00:17:01 +08:00
|
|
|
connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited()));
|
|
|
|
connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited()));
|
2014-09-15 18:45:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
IdentityForm::~IdentityForm()
|
|
|
|
{
|
|
|
|
}
|
2014-09-30 17:44:27 +08:00
|
|
|
|
|
|
|
void IdentityForm::copyIdClicked()
|
|
|
|
{
|
|
|
|
toxId->selectAll();
|
2014-10-06 02:02:12 +08:00
|
|
|
QString txt = toxId->text();
|
2014-09-30 17:44:27 +08:00
|
|
|
txt.replace('\n',"");
|
|
|
|
QApplication::clipboard()->setText(txt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdentityForm::onUserNameEdited()
|
|
|
|
{
|
2014-10-06 00:30:31 +08:00
|
|
|
Core::getInstance()->setUsername(bodyUI->userName->text());
|
2014-09-30 17:44:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void IdentityForm::onStatusMessageEdited()
|
|
|
|
{
|
2014-10-06 00:30:31 +08:00
|
|
|
Core::getInstance()->setStatusMessage(bodyUI->statusMessage->text());
|
2014-09-30 17:44:27 +08:00
|
|
|
}
|
|
|
|
|
2014-10-06 00:30:31 +08:00
|
|
|
void IdentityForm::updateContent()
|
2014-09-30 17:44:27 +08:00
|
|
|
{
|
|
|
|
toxId->setText(Core::getInstance()->getSelfId().toString());
|
|
|
|
}
|
2014-10-06 00:17:01 +08:00
|
|
|
|
|
|
|
void IdentityForm::setUserName(const QString &name)
|
|
|
|
{
|
|
|
|
bodyUI->userName->setText(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IdentityForm::setStatusMessage(const QString &msg)
|
|
|
|
{
|
|
|
|
bodyUI->statusMessage->setText(msg);
|
|
|
|
}
|