From fb63232318c20fee03fac9836671e075cddd40c9 Mon Sep 17 00:00:00 2001 From: Dubslow Date: Tue, 10 Mar 2015 21:01:13 -0500 Subject: [PATCH] Tidying new profile form Fixing up Widget code for simplicity and consistency, add picture to form heading --- src/widget/form/profileform.cpp | 20 +++++++++++++++----- src/widget/form/profileform.h | 2 -- src/widget/widget.cpp | 31 ++++++++++--------------------- src/widget/widget.h | 4 +--- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index 906d52855..631ec6212 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -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(); } diff --git a/src/widget/form/profileform.h b/src/widget/form/profileform.h index b8d0e91ad..830e486db 100644 --- a/src/widget/form/profileform.h +++ b/src/widget/form/profileform.h @@ -82,8 +82,6 @@ private: Ui::IdentitySettings* bodyUI; MaskablePixmapWidget* profilePicture; QWidget *head; - QLabel headLabel; - QVBoxLayout headLayout; Core* core; QTimer timer; bool hasCheck = false; diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index e8dcf8529..a3d08b981 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -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); diff --git a/src/widget/widget.h b/src/widget/widget.h index f8a00d714..e019b0915 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -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 *);