1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Tidying new profile form

Fixing up Widget code for simplicity and consistency, add picture to form heading
This commit is contained in:
Dubslow 2015-03-10 21:01:13 -05:00
parent 114ddd8c50
commit fb63232318
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
4 changed files with 26 additions and 31 deletions

View File

@ -54,13 +54,22 @@ ProfileForm::ProfileForm(QWidget *parent) :
bodyUI->setupUi(this);
core = Core::getInstance();
head = new QWidget();
head = new QWidget(this);
QHBoxLayout* headLayout = new QHBoxLayout();
head->setLayout(headLayout);
QLabel* imgLabel = new QLabel();
headLayout->addWidget(imgLabel);
QLabel* nameLabel = new QLabel();
QFont bold;
bold.setBold(true);
head->setLayout(&headLayout);
headLabel.setText(tr("User Profile"));
headLabel.setFont(bold);
headLayout.addWidget(&headLabel);
nameLabel->setFont(bold);
headLayout->addWidget(nameLabel);
headLayout->addStretch(1);
nameLabel->setText(tr("User Profile"));
imgLabel->setPixmap(QPixmap(":/img/settings/identity.png").scaledToHeight(40, Qt::SmoothTransformation));
// tox
toxId = new ClickableTE();
@ -118,6 +127,7 @@ ProfileForm::~ProfileForm()
void ProfileForm::show(Ui::MainWindow &ui)
{
ui.mainHead->layout()->addWidget(head);
ui.mainContent->layout()->addWidget(this);
head->show();
QWidget::show();
}

View File

@ -82,8 +82,6 @@ private:
Ui::IdentitySettings* bodyUI;
MaskablePixmapWidget* profilePicture;
QWidget *head;
QLabel headLabel;
QVBoxLayout headLayout;
Core* core;
QTimer timer;
bool hasCheck = false;

View File

@ -184,10 +184,10 @@ void Widget::init()
connect(ui->groupButton, SIGNAL(clicked()), this, SLOT(onGroupClicked()));
connect(ui->transferButton, SIGNAL(clicked()), this, SLOT(onTransferClicked()));
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
connect(ui->nameLabel, SIGNAL(clicked()), this, SLOT(onUsernameClicked()));
connect(profilePicture, &MaskablePixmapWidget::clicked, this, &Widget::showProfile);
connect(ui->nameLabel, &CroppingLabel::clicked, this, &Widget::showProfile);
connect(ui->statusLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onStatusMessageChanged(QString, QString)));
connect(ui->mainSplitter, &QSplitter::splitterMoved, this, &Widget::onSplitterMoved);
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
connect(addFriendForm, SIGNAL(friendRequested(QString, QString)), this, SIGNAL(friendRequested(QString, QString)));
connect(timer, &QTimer::timeout, this, &Widget::onUserAwayCheck);
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick);
@ -310,11 +310,6 @@ QString Widget::getUsername()
return Nexus::getCore()->getUsername();
}
void Widget::onAvatarClicked()
{
showProfile();
}
void Widget::onSelfAvatarLoaded(const QPixmap& pic)
{
profilePicture->setPixmap(pic);
@ -490,6 +485,14 @@ void Widget::onSettingsClicked()
activeChatroomWidget = nullptr;
}
void Widget::showProfile() // onAvatarClicked, onUsernameClicked
{
hideMainForms();
profileForm->show(*ui);
setWindowTitle(tr("Profile"));
activeChatroomWidget = nullptr;
}
void Widget::hideMainForms()
{
QLayoutItem* item;
@ -510,20 +513,6 @@ void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUse
Nexus::getCore()->setUsername(newUsername);
}
void Widget::showProfile()
{
hideMainForms();
ui->mainContent->layout()->addWidget(profileForm);
profileForm->show(*ui);
setWindowTitle(tr("Profile"));
activeChatroomWidget = nullptr;
}
void Widget::onUsernameClicked()
{
showProfile();
}
void Widget::setUsername(const QString& username)
{
ui->nameLabel->setText(username);

View File

@ -77,7 +77,6 @@ public:
void reloadTheme();
void showProfile();
public slots:
void onSettingsClicked();
void setWindowTitle(const QString& title);
@ -122,8 +121,7 @@ private slots:
void onAddClicked();
void onGroupClicked();
void onTransferClicked();
void onAvatarClicked();
void onUsernameClicked();
void showProfile();
void onUsernameChanged(const QString& newUsername, const QString& oldUsername);
void onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage);
void onChatroomWidgetClicked(GenericChatroomWidget *);