mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Move the identity settings tab into its own dedicated profile page
Make the page directly accessible from the main screen by clicking the avatar or the username. Changing the avatar or the username are now possible only from the profile page
This commit is contained in:
parent
75a0e8ac2e
commit
b155830e4c
4
qtox.pro
4
qtox.pro
|
@ -315,10 +315,10 @@ contains(ENABLE_SYSTRAY_GTK_BACKEND, NO) {
|
||||||
src/widget/form/settingswidget.h \
|
src/widget/form/settingswidget.h \
|
||||||
src/widget/form/settings/genericsettings.h \
|
src/widget/form/settings/genericsettings.h \
|
||||||
src/widget/form/settings/generalform.h \
|
src/widget/form/settings/generalform.h \
|
||||||
src/widget/form/settings/identityform.h \
|
|
||||||
src/widget/form/settings/privacyform.h \
|
src/widget/form/settings/privacyform.h \
|
||||||
src/widget/form/settings/avform.h \
|
src/widget/form/settings/avform.h \
|
||||||
src/widget/form/filesform.h \
|
src/widget/form/filesform.h \
|
||||||
|
src/widget/form/profileform.h \
|
||||||
src/widget/tool/chattextedit.h \
|
src/widget/tool/chattextedit.h \
|
||||||
src/widget/tool/friendrequestdialog.h \
|
src/widget/tool/friendrequestdialog.h \
|
||||||
src/widget/friendwidget.h \
|
src/widget/friendwidget.h \
|
||||||
|
@ -343,9 +343,9 @@ contains(ENABLE_SYSTRAY_GTK_BACKEND, NO) {
|
||||||
src/widget/form/addfriendform.cpp \
|
src/widget/form/addfriendform.cpp \
|
||||||
src/widget/form/settingswidget.cpp \
|
src/widget/form/settingswidget.cpp \
|
||||||
src/widget/form/settings/generalform.cpp \
|
src/widget/form/settings/generalform.cpp \
|
||||||
src/widget/form/settings/identityform.cpp \
|
|
||||||
src/widget/form/settings/privacyform.cpp \
|
src/widget/form/settings/privacyform.cpp \
|
||||||
src/widget/form/settings/avform.cpp \
|
src/widget/form/settings/avform.cpp \
|
||||||
|
src/widget/form/profileform.cpp \
|
||||||
src/widget/form/filesform.cpp \
|
src/widget/form/filesform.cpp \
|
||||||
src/widget/tool/chattextedit.cpp \
|
src/widget/tool/chattextedit.cpp \
|
||||||
src/widget/tool/friendrequestdialog.cpp \
|
src/widget/tool/friendrequestdialog.cpp \
|
||||||
|
|
|
@ -855,6 +855,9 @@ QSplitter:handle{
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="cursor">
|
||||||
|
<cursorShape>PointingHandCursor</cursorShape>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Your name</string>
|
<string>Your name</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1037,8 +1040,8 @@ QSplitter:handle{
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>284</width>
|
<width>285</width>
|
||||||
<height>399</height>
|
<height>381</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
||||||
|
@ -1779,7 +1782,7 @@ QSplitter:handle{
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>775</width>
|
<width>775</width>
|
||||||
<height>20</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "src/core.h"
|
#include "src/core.h"
|
||||||
|
#include "src/nexus.h"
|
||||||
#include "ui_identitysettings.h"
|
#include "ui_identitysettings.h"
|
||||||
#include "identityform.h"
|
#include "profileform.h"
|
||||||
#include "src/widget/form/settingswidget.h"
|
#include "src/widget/form/settingswidget.h"
|
||||||
|
#include "src/widget/maskablepixmapwidget.h"
|
||||||
#include "src/misc/settings.h"
|
#include "src/misc/settings.h"
|
||||||
#include "src/widget/croppinglabel.h"
|
#include "src/widget/croppinglabel.h"
|
||||||
#include "src/widget/widget.h"
|
#include "src/widget/widget.h"
|
||||||
|
@ -26,13 +28,16 @@
|
||||||
#include "src/misc/style.h"
|
#include "src/misc/style.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QGroupBox>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QBuffer>
|
||||||
|
|
||||||
IdentityForm::IdentityForm() :
|
|
||||||
GenericForm(tr("Identity"), QPixmap(":/img/settings/identity.png"))
|
ProfileForm::ProfileForm(QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
bodyUI = new Ui::IdentitySettings;
|
bodyUI = new Ui::IdentitySettings;
|
||||||
bodyUI->setupUi(this);
|
bodyUI->setupUi(this);
|
||||||
|
@ -46,42 +51,50 @@ IdentityForm::IdentityForm() :
|
||||||
|
|
||||||
bodyUI->toxGroup->layout()->addWidget(toxId);
|
bodyUI->toxGroup->layout()->addWidget(toxId);
|
||||||
|
|
||||||
|
profilePicture = new MaskablePixmapWidget(this, QSize(64, 64), ":/img/avatar_mask.png");
|
||||||
|
profilePicture->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||||
|
profilePicture->setClickable(true);
|
||||||
|
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
|
||||||
|
QHBoxLayout *publicGrouplayout = qobject_cast<QHBoxLayout*>(bodyUI->publicGroup->layout());
|
||||||
|
publicGrouplayout->insertWidget(0, profilePicture);
|
||||||
|
publicGrouplayout->insertSpacing(1, 7);
|
||||||
|
|
||||||
timer.setInterval(750);
|
timer.setInterval(750);
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
connect(&timer, &QTimer::timeout, this, [=]() {bodyUI->toxIdLabel->setText(bodyUI->toxIdLabel->text().replace(" ✔", "")); hasCheck = false;});
|
connect(&timer, &QTimer::timeout, this, [=]() {bodyUI->toxIdLabel->setText(bodyUI->toxIdLabel->text().replace(" ✔", "")); hasCheck = false;});
|
||||||
|
|
||||||
connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
||||||
connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
||||||
connect(core, &Core::idSet, this, &IdentityForm::setToxId);
|
connect(core, &Core::idSet, this, &ProfileForm::setToxId);
|
||||||
connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited()));
|
connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited()));
|
||||||
connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited()));
|
connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited()));
|
||||||
connect(bodyUI->loadButton, &QPushButton::clicked, this, &IdentityForm::onLoadClicked);
|
connect(bodyUI->loadButton, &QPushButton::clicked, this, &ProfileForm::onLoadClicked);
|
||||||
connect(bodyUI->renameButton, &QPushButton::clicked, this, &IdentityForm::onRenameClicked);
|
connect(bodyUI->renameButton, &QPushButton::clicked, this, &ProfileForm::onRenameClicked);
|
||||||
connect(bodyUI->exportButton, &QPushButton::clicked, this, &IdentityForm::onExportClicked);
|
connect(bodyUI->exportButton, &QPushButton::clicked, this, &ProfileForm::onExportClicked);
|
||||||
connect(bodyUI->deleteButton, &QPushButton::clicked, this, &IdentityForm::onDeleteClicked);
|
connect(bodyUI->deleteButton, &QPushButton::clicked, this, &ProfileForm::onDeleteClicked);
|
||||||
connect(bodyUI->importButton, &QPushButton::clicked, this, &IdentityForm::onImportClicked);
|
connect(bodyUI->importButton, &QPushButton::clicked, this, &ProfileForm::onImportClicked);
|
||||||
connect(bodyUI->newButton, &QPushButton::clicked, this, &IdentityForm::onNewClicked);
|
connect(bodyUI->newButton, &QPushButton::clicked, this, &ProfileForm::onNewClicked);
|
||||||
|
|
||||||
connect(core, &Core::avStart, this, &IdentityForm::disableSwitching);
|
connect(core, &Core::avStart, this, &ProfileForm::disableSwitching);
|
||||||
connect(core, &Core::avStarting, this, &IdentityForm::disableSwitching);
|
connect(core, &Core::avStarting, this, &ProfileForm::disableSwitching);
|
||||||
connect(core, &Core::avInvite, this, &IdentityForm::disableSwitching);
|
connect(core, &Core::avInvite, this, &ProfileForm::disableSwitching);
|
||||||
connect(core, &Core::avRinging, this, &IdentityForm::disableSwitching);
|
connect(core, &Core::avRinging, this, &ProfileForm::disableSwitching);
|
||||||
connect(core, &Core::avCancel, this, &IdentityForm::enableSwitching);
|
connect(core, &Core::avCancel, this, &ProfileForm::enableSwitching);
|
||||||
connect(core, &Core::avEnd, this, &IdentityForm::enableSwitching);
|
connect(core, &Core::avEnd, this, &ProfileForm::enableSwitching);
|
||||||
connect(core, &Core::avEnding, this, &IdentityForm::enableSwitching);
|
connect(core, &Core::avEnding, this, &ProfileForm::enableSwitching);
|
||||||
connect(core, &Core::avPeerTimeout, this, &IdentityForm::enableSwitching);
|
connect(core, &Core::avPeerTimeout, this, &ProfileForm::enableSwitching);
|
||||||
connect(core, &Core::avRequestTimeout, this, &IdentityForm::enableSwitching);
|
connect(core, &Core::avRequestTimeout, this, &ProfileForm::enableSwitching);
|
||||||
|
|
||||||
connect(core, &Core::usernameSet, this, [=](const QString& val) { bodyUI->userName->setText(val); });
|
connect(core, &Core::usernameSet, this, [=](const QString& val) { bodyUI->userName->setText(val); });
|
||||||
connect(core, &Core::statusMessageSet, this, [=](const QString& val) { bodyUI->statusMessage->setText(val); });
|
connect(core, &Core::statusMessageSet, this, [=](const QString& val) { bodyUI->statusMessage->setText(val); });
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentityForm::~IdentityForm()
|
ProfileForm::~ProfileForm()
|
||||||
{
|
{
|
||||||
delete bodyUI;
|
delete bodyUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::copyIdClicked()
|
void ProfileForm::copyIdClicked()
|
||||||
{
|
{
|
||||||
toxId->selectAll();
|
toxId->selectAll();
|
||||||
QString txt = toxId->text();
|
QString txt = toxId->text();
|
||||||
|
@ -97,38 +110,75 @@ void IdentityForm::copyIdClicked()
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onUserNameEdited()
|
void ProfileForm::onUserNameEdited()
|
||||||
{
|
{
|
||||||
Core::getInstance()->setUsername(bodyUI->userName->text());
|
Core::getInstance()->setUsername(bodyUI->userName->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onStatusMessageEdited()
|
void ProfileForm::onStatusMessageEdited()
|
||||||
{
|
{
|
||||||
Core::getInstance()->setStatusMessage(bodyUI->statusMessage->text());
|
Core::getInstance()->setStatusMessage(bodyUI->statusMessage->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::present()
|
void ProfileForm::onSelfAvatarLoaded(const QPixmap& pic)
|
||||||
{
|
{
|
||||||
toxId->setText(Core::getInstance()->getSelfId().toString());
|
profilePicture->setPixmap(pic);
|
||||||
toxId->setCursorPosition(0);
|
|
||||||
bodyUI->profiles->clear();
|
|
||||||
for (QString profile : Settings::getInstance().searchProfiles())
|
|
||||||
bodyUI->profiles->addItem(profile);
|
|
||||||
QString current = Settings::getInstance().getCurrentProfile();
|
|
||||||
if (current != "")
|
|
||||||
bodyUI->profiles->setCurrentText(current);
|
|
||||||
|
|
||||||
bodyUI->userName->setText(Core::getInstance()->getUsername());
|
|
||||||
bodyUI->statusMessage->setText(Core::getInstance()->getStatusMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::setToxId(const QString& id)
|
void ProfileForm::setToxId(const QString& id)
|
||||||
{
|
{
|
||||||
toxId->setText(id);
|
toxId->setText(id);
|
||||||
toxId->setCursorPosition(0);
|
toxId->setCursorPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onLoadClicked()
|
void ProfileForm::onAvatarClicked()
|
||||||
|
{
|
||||||
|
QString filename = QFileDialog::getOpenFileName(this,
|
||||||
|
tr("Choose a profile picture"),
|
||||||
|
QDir::homePath(),
|
||||||
|
Nexus::getSupportedImageFilter());
|
||||||
|
if (filename.isEmpty())
|
||||||
|
return;
|
||||||
|
QFile file(filename);
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
if (!file.isOpen())
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Unable to open this file"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap pic;
|
||||||
|
if (!pic.loadFromData(file.readAll()))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Unable to read this image"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray bytes;
|
||||||
|
QBuffer buffer(&bytes);
|
||||||
|
buffer.open(QIODevice::WriteOnly);
|
||||||
|
pic.save(&buffer, "PNG");
|
||||||
|
buffer.close();
|
||||||
|
|
||||||
|
if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
|
||||||
|
{
|
||||||
|
pic = pic.scaled(64,64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
bytes.clear();
|
||||||
|
buffer.open(QIODevice::WriteOnly);
|
||||||
|
pic.save(&buffer, "PNG");
|
||||||
|
buffer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("This image is too big"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Nexus::getCore()->setAvatar(TOX_AVATAR_FORMAT_PNG, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProfileForm::onLoadClicked()
|
||||||
{
|
{
|
||||||
if (bodyUI->profiles->currentText() != Settings::getInstance().getCurrentProfile())
|
if (bodyUI->profiles->currentText() != Settings::getInstance().getCurrentProfile())
|
||||||
{
|
{
|
||||||
|
@ -141,7 +191,7 @@ void IdentityForm::onLoadClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onRenameClicked()
|
void ProfileForm::onRenameClicked()
|
||||||
{
|
{
|
||||||
QString cur = bodyUI->profiles->currentText();
|
QString cur = bodyUI->profiles->currentText();
|
||||||
QString title = tr("Rename \"%1\"", "renaming a profile").arg(cur);
|
QString title = tr("Rename \"%1\"", "renaming a profile").arg(cur);
|
||||||
|
@ -169,7 +219,7 @@ void IdentityForm::onRenameClicked()
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onExportClicked()
|
void ProfileForm::onExportClicked()
|
||||||
{
|
{
|
||||||
QString current = bodyUI->profiles->currentText() + Core::TOX_EXT;
|
QString current = bodyUI->profiles->currentText() + Core::TOX_EXT;
|
||||||
QString path = QFileDialog::getSaveFileName(this, tr("Export profile", "save dialog title"),
|
QString path = QFileDialog::getSaveFileName(this, tr("Export profile", "save dialog title"),
|
||||||
|
@ -194,7 +244,7 @@ void IdentityForm::onExportClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onDeleteClicked()
|
void ProfileForm::onDeleteClicked()
|
||||||
{
|
{
|
||||||
if (Settings::getInstance().getCurrentProfile() == bodyUI->profiles->currentText())
|
if (Settings::getInstance().getCurrentProfile() == bodyUI->profiles->currentText())
|
||||||
{
|
{
|
||||||
|
@ -219,7 +269,7 @@ void IdentityForm::onDeleteClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onImportClicked()
|
void ProfileForm::onImportClicked()
|
||||||
{
|
{
|
||||||
QString path = QFileDialog::getOpenFileName(this,
|
QString path = QFileDialog::getOpenFileName(this,
|
||||||
tr("Import profile", "import dialog title"),
|
tr("Import profile", "import dialog title"),
|
||||||
|
@ -249,18 +299,18 @@ void IdentityForm::onImportClicked()
|
||||||
bodyUI->profiles->addItem(profile);
|
bodyUI->profiles->addItem(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::onNewClicked()
|
void ProfileForm::onNewClicked()
|
||||||
{
|
{
|
||||||
emit Widget::getInstance()->changeProfile(QString());
|
emit Widget::getInstance()->changeProfile(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::disableSwitching()
|
void ProfileForm::disableSwitching()
|
||||||
{
|
{
|
||||||
bodyUI->loadButton->setEnabled(false);
|
bodyUI->loadButton->setEnabled(false);
|
||||||
bodyUI->newButton->setEnabled(false);
|
bodyUI->newButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentityForm::enableSwitching()
|
void ProfileForm::enableSwitching()
|
||||||
{
|
{
|
||||||
if (!core->anyActiveCalls())
|
if (!core->anyActiveCalls())
|
||||||
{
|
{
|
|
@ -17,15 +17,13 @@
|
||||||
#ifndef IDENTITYFORM_H
|
#ifndef IDENTITYFORM_H
|
||||||
#define IDENTITYFORM_H
|
#define IDENTITYFORM_H
|
||||||
|
|
||||||
#include "genericsettings.h"
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QTextEdit>
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
class CroppingLabel;
|
class CroppingLabel;
|
||||||
class Core;
|
class Core;
|
||||||
|
class MaskablePixmapWidget;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class IdentitySettings;
|
class IdentitySettings;
|
||||||
|
@ -42,22 +40,24 @@ protected:
|
||||||
void mouseReleaseEvent(QMouseEvent*) {emit clicked();}
|
void mouseReleaseEvent(QMouseEvent*) {emit clicked();}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IdentityForm : public GenericForm
|
class ProfileForm : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
IdentityForm();
|
ProfileForm(QWidget *parent = nullptr);
|
||||||
~IdentityForm();
|
~ProfileForm();
|
||||||
|
|
||||||
virtual void present();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void userNameChanged(QString);
|
void userNameChanged(QString);
|
||||||
void statusMessageChanged(QString);
|
void statusMessageChanged(QString);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onSelfAvatarLoaded(const QPixmap &pic);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setToxId(const QString& id);
|
void setToxId(const QString& id);
|
||||||
void copyIdClicked();
|
void copyIdClicked();
|
||||||
|
void onAvatarClicked();
|
||||||
void onUserNameEdited();
|
void onUserNameEdited();
|
||||||
void onStatusMessageEdited();
|
void onStatusMessageEdited();
|
||||||
void onLoadClicked();
|
void onLoadClicked();
|
||||||
|
@ -71,6 +71,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::IdentitySettings* bodyUI;
|
Ui::IdentitySettings* bodyUI;
|
||||||
|
MaskablePixmapWidget* profilePicture;
|
||||||
Core* core;
|
Core* core;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
bool hasCheck = false;
|
bool hasCheck = false;
|
|
@ -47,44 +47,48 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<item alignment="Qt::AlignTop">
|
<item>
|
||||||
<widget class="QGroupBox" name="publicGroup">
|
<widget class="QGroupBox" name="publicGroup">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Public Information</string>
|
<string>Public Information</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="userNameLabel">
|
<layout class="QVBoxLayout" name="publicFieldsLayout">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Name</string>
|
<widget class="QLabel" name="userNameLabel">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Name</string>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<widget class="QLineEdit" name="userName"/>
|
</item>
|
||||||
</item>
|
<item>
|
||||||
<item>
|
<widget class="QLineEdit" name="userName"/>
|
||||||
<widget class="QLabel" name="statusMessageLabel">
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Status</string>
|
<widget class="QLabel" name="statusMessageLabel">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Status</string>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<widget class="QLineEdit" name="statusMessage"/>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="statusMessage"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignTop">
|
<item alignment="Qt::AlignTop">
|
||||||
<widget class="QGroupBox" name="toxGroup">
|
<widget class="QGroupBox" name="toxGroup">
|
||||||
<property name="title">
|
|
||||||
<string>Tox ID</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string comment="Tox ID tooltip">This bunch of characters tells other Tox clients how to contact you.
|
<string comment="Tox ID tooltip">This bunch of characters tells other Tox clients how to contact you.
|
||||||
Share it with your friends to communicate.</string>
|
Share it with your friends to communicate.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Tox ID</string>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="CroppingLabel" name="toxIdLabel">
|
<widget class="CroppingLabel" name="toxIdLabel">
|
||||||
|
@ -113,15 +117,15 @@ Share it with your friends to communicate.</string>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="profiles">
|
<widget class="QComboBox" name="profiles">
|
||||||
<property name="toolTip">
|
|
||||||
<string comment="toolTip for currently set profile">Currently selected profile.</string>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string comment="toolTip for currently set profile">Currently selected profile.</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -140,23 +144,23 @@ Share it with your friends to communicate.</string>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="renameButton">
|
<widget class="QPushButton" name="renameButton">
|
||||||
<property name="text">
|
|
||||||
<string comment="rename profile button">Rename</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string comment="tooltip for renaming profile button">Rename selected profile.</string>
|
<string comment="tooltip for renaming profile button">Rename selected profile.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string comment="rename profile button">Rename</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="exportButton">
|
<widget class="QPushButton" name="exportButton">
|
||||||
<property name="text">
|
|
||||||
<string comment="export profile button">Export</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string comment="tooltip for profile exporting button">Allows you to export your Tox profile to a file.
|
<string comment="tooltip for profile exporting button">Allows you to export your Tox profile to a file.
|
||||||
Profile does not contain your history.</string>
|
Profile does not contain your history.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string comment="export profile button">Export</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -175,12 +179,12 @@ Profile does not contain your history.</string>
|
||||||
<layout class="QHBoxLayout" name="profilesButtonsLayout2">
|
<layout class="QHBoxLayout" name="profilesButtonsLayout2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="importButton">
|
<widget class="QPushButton" name="importButton">
|
||||||
<property name="text">
|
|
||||||
<string comment="import profile button">Import a profile</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string comment="tooltip for importing profile button">Import Tox profile from a .tox file.</string>
|
<string comment="tooltip for importing profile button">Import Tox profile from a .tox file.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string comment="import profile button">Import a profile</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "src/video/camera.h"
|
#include "src/video/camera.h"
|
||||||
#include "src/widget/form/settings/generalform.h"
|
#include "src/widget/form/settings/generalform.h"
|
||||||
#include "src/widget/form/settings/identityform.h"
|
|
||||||
#include "src/widget/form/settings/privacyform.h"
|
#include "src/widget/form/settings/privacyform.h"
|
||||||
#include "src/widget/form/settings/avform.h"
|
#include "src/widget/form/settings/avform.h"
|
||||||
#include "src/widget/form/settings/advancedform.h"
|
#include "src/widget/form/settings/advancedform.h"
|
||||||
|
@ -52,12 +51,11 @@ SettingsWidget::SettingsWidget(QWidget* parent)
|
||||||
bodyLayout->addWidget(settingsWidgets);
|
bodyLayout->addWidget(settingsWidgets);
|
||||||
|
|
||||||
GeneralForm* gfrm = new GeneralForm(this);
|
GeneralForm* gfrm = new GeneralForm(this);
|
||||||
IdentityForm* ifrm = new IdentityForm;
|
|
||||||
PrivacyForm* pfrm = new PrivacyForm;
|
PrivacyForm* pfrm = new PrivacyForm;
|
||||||
AVForm* avfrm = new AVForm;
|
AVForm* avfrm = new AVForm;
|
||||||
AdvancedForm *expfrm = new AdvancedForm;
|
AdvancedForm *expfrm = new AdvancedForm;
|
||||||
|
|
||||||
GenericForm* cfgForms[] = { gfrm, ifrm, pfrm, avfrm, expfrm };
|
GenericForm* cfgForms[] = { gfrm, pfrm, avfrm, expfrm };
|
||||||
for (GenericForm* cfgForm : cfgForms)
|
for (GenericForm* cfgForm : cfgForms)
|
||||||
settingsWidgets->addTab(cfgForm, cfgForm->getFormIcon(), cfgForm->getFormName());
|
settingsWidgets->addTab(cfgForm, cfgForm->getFormIcon(), cfgForm->getFormName());
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
class Camera;
|
class Camera;
|
||||||
class GenericForm;
|
class GenericForm;
|
||||||
class GeneralForm;
|
class GeneralForm;
|
||||||
class IdentityForm;
|
|
||||||
class PrivacyForm;
|
class PrivacyForm;
|
||||||
class AVForm;
|
class AVForm;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
|
|
@ -49,8 +49,6 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QInputDialog>
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
@ -189,7 +187,6 @@ void Widget::init()
|
||||||
ui->friendList->setWidget(contactListWidget);
|
ui->friendList->setWidget(contactListWidget);
|
||||||
ui->friendList->setLayoutDirection(Qt::RightToLeft);
|
ui->friendList->setLayoutDirection(Qt::RightToLeft);
|
||||||
|
|
||||||
ui->nameLabel->setEditable(true);
|
|
||||||
ui->statusLabel->setEditable(true);
|
ui->statusLabel->setEditable(true);
|
||||||
|
|
||||||
ui->statusPanel->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css"));
|
ui->statusPanel->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css"));
|
||||||
|
@ -215,17 +212,19 @@ void Widget::init()
|
||||||
|
|
||||||
filesForm = new FilesForm();
|
filesForm = new FilesForm();
|
||||||
addFriendForm = new AddFriendForm;
|
addFriendForm = new AddFriendForm;
|
||||||
|
profileForm = new ProfileForm();
|
||||||
settingsWidget = new SettingsWidget();
|
settingsWidget = new SettingsWidget();
|
||||||
|
|
||||||
Core* core = Nexus::getCore();
|
Core* core = Nexus::getCore();
|
||||||
connect(core, SIGNAL(fileDownloadFinished(const QString&)), filesForm, SLOT(onFileDownloadComplete(const QString&)));
|
connect(core, SIGNAL(fileDownloadFinished(const QString&)), filesForm, SLOT(onFileDownloadComplete(const QString&)));
|
||||||
connect(core, SIGNAL(fileUploadFinished(const QString&)), filesForm, SLOT(onFileUploadComplete(const QString&)));
|
connect(core, SIGNAL(fileUploadFinished(const QString&)), filesForm, SLOT(onFileUploadComplete(const QString&)));
|
||||||
connect(settingsWidget, &SettingsWidget::setShowSystemTray, this, &Widget::onSetShowSystemTray);
|
connect(settingsWidget, &SettingsWidget::setShowSystemTray, this, &Widget::onSetShowSystemTray);
|
||||||
|
connect(core, SIGNAL(selfAvatarChanged(QPixmap)), profileForm, SLOT(onSelfAvatarLoaded(QPixmap)));
|
||||||
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(onAddClicked()));
|
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(onAddClicked()));
|
||||||
connect(ui->groupButton, SIGNAL(clicked()), this, SLOT(onGroupClicked()));
|
connect(ui->groupButton, SIGNAL(clicked()), this, SLOT(onGroupClicked()));
|
||||||
connect(ui->transferButton, SIGNAL(clicked()), this, SLOT(onTransferClicked()));
|
connect(ui->transferButton, SIGNAL(clicked()), this, SLOT(onTransferClicked()));
|
||||||
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
|
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
|
||||||
connect(ui->nameLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onUsernameChanged(QString, QString)));
|
connect(ui->nameLabel, SIGNAL(clicked()), this, SLOT(onUsernameClicked()));
|
||||||
connect(ui->statusLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onStatusMessageChanged(QString, QString)));
|
connect(ui->statusLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onStatusMessageChanged(QString, QString)));
|
||||||
connect(ui->mainSplitter, &QSplitter::splitterMoved, this, &Widget::onSplitterMoved);
|
connect(ui->mainSplitter, &QSplitter::splitterMoved, this, &Widget::onSplitterMoved);
|
||||||
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
|
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
|
||||||
|
@ -283,6 +282,7 @@ Widget::~Widget()
|
||||||
AutoUpdater::abortUpdates();
|
AutoUpdater::abortUpdates();
|
||||||
icon->hide();
|
icon->hide();
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
|
delete profileForm;
|
||||||
delete settingsWidget;
|
delete settingsWidget;
|
||||||
delete addFriendForm;
|
delete addFriendForm;
|
||||||
delete filesForm;
|
delete filesForm;
|
||||||
|
@ -348,49 +348,7 @@ QString Widget::getUsername()
|
||||||
|
|
||||||
void Widget::onAvatarClicked()
|
void Widget::onAvatarClicked()
|
||||||
{
|
{
|
||||||
QString filename = QFileDialog::getOpenFileName(this,
|
showProfile();
|
||||||
tr("Choose a profile picture"),
|
|
||||||
QDir::homePath(),
|
|
||||||
Nexus::getSupportedImageFilter());
|
|
||||||
if (filename.isEmpty())
|
|
||||||
return;
|
|
||||||
QFile file(filename);
|
|
||||||
file.open(QIODevice::ReadOnly);
|
|
||||||
if (!file.isOpen())
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Unable to open this file"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap pic;
|
|
||||||
if (!pic.loadFromData(file.readAll()))
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Unable to read this image"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray bytes;
|
|
||||||
QBuffer buffer(&bytes);
|
|
||||||
buffer.open(QIODevice::WriteOnly);
|
|
||||||
pic.save(&buffer, "PNG");
|
|
||||||
buffer.close();
|
|
||||||
|
|
||||||
if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
|
|
||||||
{
|
|
||||||
pic = pic.scaled(64,64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
bytes.clear();
|
|
||||||
buffer.open(QIODevice::WriteOnly);
|
|
||||||
pic.save(&buffer, "PNG");
|
|
||||||
buffer.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("This image is too big"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Nexus::getCore()->setAvatar(TOX_AVATAR_FORMAT_PNG, bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onSelfAvatarLoaded(const QPixmap& pic)
|
void Widget::onSelfAvatarLoaded(const QPixmap& pic)
|
||||||
|
@ -588,6 +546,20 @@ void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUse
|
||||||
Nexus::getCore()->setUsername(newUsername);
|
Nexus::getCore()->setUsername(newUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::showProfile()
|
||||||
|
{
|
||||||
|
hideMainForms();
|
||||||
|
ui->mainContent->layout()->addWidget(profileForm);
|
||||||
|
profileForm->show();
|
||||||
|
setWindowTitle(tr("Profile"));
|
||||||
|
activeChatroomWidget = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::onUsernameClicked()
|
||||||
|
{
|
||||||
|
showProfile();
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::setUsername(const QString& username)
|
void Widget::setUsername(const QString& username)
|
||||||
{
|
{
|
||||||
ui->nameLabel->setText(username);
|
ui->nameLabel->setText(username);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "form/addfriendform.h"
|
#include "form/addfriendform.h"
|
||||||
#include "form/settingswidget.h"
|
#include "form/settingswidget.h"
|
||||||
#include "form/settings/identityform.h"
|
#include "form/profileform.h"
|
||||||
#include "form/filesform.h"
|
#include "form/filesform.h"
|
||||||
#include "src/corestructs.h"
|
#include "src/corestructs.h"
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ public:
|
||||||
|
|
||||||
void reloadTheme();
|
void reloadTheme();
|
||||||
|
|
||||||
|
void showProfile();
|
||||||
public slots:
|
public slots:
|
||||||
void onSettingsClicked();
|
void onSettingsClicked();
|
||||||
void setWindowTitle(const QString& title);
|
void setWindowTitle(const QString& title);
|
||||||
|
@ -120,6 +121,7 @@ private slots:
|
||||||
void onGroupClicked();
|
void onGroupClicked();
|
||||||
void onTransferClicked();
|
void onTransferClicked();
|
||||||
void onAvatarClicked();
|
void onAvatarClicked();
|
||||||
|
void onUsernameClicked();
|
||||||
void onUsernameChanged(const QString& newUsername, const QString& oldUsername);
|
void onUsernameChanged(const QString& newUsername, const QString& oldUsername);
|
||||||
void onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage);
|
void onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage);
|
||||||
void onChatroomWidgetClicked(GenericChatroomWidget *);
|
void onChatroomWidgetClicked(GenericChatroomWidget *);
|
||||||
|
@ -157,6 +159,7 @@ private:
|
||||||
QSplitter *centralLayout;
|
QSplitter *centralLayout;
|
||||||
QPoint dragPosition;
|
QPoint dragPosition;
|
||||||
AddFriendForm* addFriendForm;
|
AddFriendForm* addFriendForm;
|
||||||
|
ProfileForm* profileForm;
|
||||||
SettingsWidget* settingsWidget;
|
SettingsWidget* settingsWidget;
|
||||||
FilesForm* filesForm;
|
FilesForm* filesForm;
|
||||||
static Widget* instance;
|
static Widget* instance;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user