mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Settings: use QTabWidget, IdentityForm: cleanup
This commit is contained in:
parent
87132389aa
commit
6e61da68e4
|
@ -21,6 +21,7 @@
|
|||
#include "src/misc/settings.h"
|
||||
#include "src/widget/croppinglabel.h"
|
||||
#include "src/widget/widget.h"
|
||||
#include "src/misc/style.h"
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QApplication>
|
||||
|
@ -37,16 +38,9 @@ IdentityForm::IdentityForm() :
|
|||
|
||||
// tox
|
||||
toxId = new ClickableTE();
|
||||
QFont small;
|
||||
small.setPixelSize(13);
|
||||
small.setKerning(false);
|
||||
|
||||
// toxId->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
toxId->setReadOnly(true);
|
||||
toxId->setFrame(false);
|
||||
// toxId->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
// toxId->setFixedHeight(toxId->document()->size().height()*2);
|
||||
toxId->setFont(small);
|
||||
toxId->setFont(Style::getFont(Style::Small));
|
||||
|
||||
bodyUI->toxGroup->layout()->addWidget(toxId);
|
||||
|
||||
|
@ -59,6 +53,9 @@ IdentityForm::IdentityForm() :
|
|||
connect(bodyUI->exportButton, &QPushButton::clicked, this, &IdentityForm::onExportClicked);
|
||||
connect(bodyUI->deleteButton, &QPushButton::clicked, this, &IdentityForm::onDeleteClicked);
|
||||
connect(bodyUI->importButton, &QPushButton::clicked, this, &IdentityForm::onImportClicked);
|
||||
|
||||
connect(Core::getInstance(), &Core::usernameSet, this, [=](const QString& val) { bodyUI->userName->setText(val); });
|
||||
connect(Core::getInstance(), &Core::statusMessageSet, this, [=](const QString& val) { bodyUI->statusMessage->setText(val); });
|
||||
}
|
||||
|
||||
IdentityForm::~IdentityForm()
|
||||
|
@ -94,6 +91,9 @@ void IdentityForm::present()
|
|||
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::setUserName(const QString &name)
|
||||
|
|
|
@ -22,18 +22,17 @@
|
|||
#include "src/widget/form/settings/identityform.h"
|
||||
#include "src/widget/form/settings/privacyform.h"
|
||||
#include "src/widget/form/settings/avform.h"
|
||||
#include <QTabBar>
|
||||
#include <QStackedWidget>
|
||||
#include <QTabWidget>
|
||||
|
||||
SettingsWidget::SettingsWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
body = new QWidget(this);
|
||||
QVBoxLayout *bodyLayout = new QVBoxLayout();
|
||||
QVBoxLayout* bodyLayout = new QVBoxLayout();
|
||||
body->setLayout(bodyLayout);
|
||||
|
||||
head = new QWidget(this);
|
||||
QHBoxLayout *headLayout = new QHBoxLayout();
|
||||
QHBoxLayout* headLayout = new QHBoxLayout();
|
||||
head->setLayout(headLayout);
|
||||
|
||||
imgLabel = new QLabel();
|
||||
|
@ -46,27 +45,21 @@ SettingsWidget::SettingsWidget(QWidget* parent)
|
|||
headLayout->addWidget(nameLabel);
|
||||
headLayout->addStretch(1);
|
||||
|
||||
settingsWidgets = new QStackedWidget;
|
||||
settingsWidgets = new QTabWidget(this);
|
||||
settingsWidgets->setTabPosition(QTabWidget::South);
|
||||
|
||||
bodyLayout->addWidget(settingsWidgets);
|
||||
|
||||
tabBar = new QTabBar;
|
||||
bodyLayout->addWidget(tabBar);
|
||||
GeneralForm* gfrm = new GeneralForm(this);
|
||||
IdentityForm* ifrm = new IdentityForm;
|
||||
PrivacyForm* pfrm = new PrivacyForm;
|
||||
AVForm* avfrm = new AVForm;
|
||||
|
||||
GeneralForm *gfrm = new GeneralForm(this);
|
||||
ifrm = new IdentityForm;
|
||||
PrivacyForm *pfrm = new PrivacyForm;
|
||||
AVForm *avfrm = new AVForm;
|
||||
GenericForm* cfgForms[] = { gfrm, ifrm, pfrm, avfrm };
|
||||
for (GenericForm* cfgForm : cfgForms)
|
||||
settingsWidgets->addTab(cfgForm, cfgForm->getFormIcon(), cfgForm->getFormName());
|
||||
|
||||
GenericForm *cfgForms[] = {gfrm, ifrm, pfrm, avfrm};
|
||||
for (auto cfgForm : cfgForms)
|
||||
{
|
||||
tabBar->addTab(cfgForm->getFormIcon(), "");
|
||||
settingsWidgets->addWidget(cfgForm);
|
||||
}
|
||||
tabBar->setIconSize(QSize(20, 20));
|
||||
tabBar->setShape(QTabBar::RoundedSouth);
|
||||
|
||||
connect(tabBar, &QTabBar::currentChanged, this, &SettingsWidget::onTabChanged);
|
||||
connect(settingsWidgets, &QTabWidget::currentChanged, this, &SettingsWidget::onTabChanged);
|
||||
}
|
||||
|
||||
SettingsWidget::~SettingsWidget()
|
||||
|
@ -85,7 +78,7 @@ void SettingsWidget::show(Ui::MainWindow& ui)
|
|||
ui.mainHead->layout()->addWidget(head);
|
||||
body->show();
|
||||
head->show();
|
||||
onTabChanged(tabBar->currentIndex());
|
||||
onTabChanged(settingsWidgets->currentIndex());
|
||||
}
|
||||
|
||||
void SettingsWidget::onTabChanged(int index)
|
||||
|
|
|
@ -27,9 +27,8 @@ class GeneralForm;
|
|||
class IdentityForm;
|
||||
class PrivacyForm;
|
||||
class AVForm;
|
||||
class QTabBar;
|
||||
class QStackedWidget;
|
||||
class QLabel;
|
||||
class QTabWidget;
|
||||
|
||||
namespace Ui {class MainWindow;}
|
||||
|
||||
|
@ -41,7 +40,6 @@ public:
|
|||
~SettingsWidget();
|
||||
|
||||
void show(Ui::MainWindow &ui);
|
||||
IdentityForm *getIdentityForm() {return ifrm;}
|
||||
void setBodyHeadStyle(QString style);
|
||||
|
||||
private slots:
|
||||
|
@ -50,8 +48,7 @@ private slots:
|
|||
private:
|
||||
QWidget *head, *body; // keep the others private
|
||||
IdentityForm *ifrm;
|
||||
QStackedWidget *settingsWidgets;
|
||||
QTabBar *tabBar;
|
||||
QTabWidget *settingsWidgets;
|
||||
QLabel *nameLabel, *imgLabel;
|
||||
};
|
||||
|
||||
|
|
|
@ -118,8 +118,6 @@ void Widget::init()
|
|||
ui->statusButton->setProperty("status", "offline");
|
||||
Style::repolish(ui->statusButton);
|
||||
|
||||
settingsWidget = new SettingsWidget();
|
||||
|
||||
// Disable some widgets until we're connected to the DHT
|
||||
ui->statusButton->setEnabled(false);
|
||||
|
||||
|
@ -184,8 +182,6 @@ void Widget::init()
|
|||
connect(ui->statusLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onStatusMessageChanged(QString,QString)));
|
||||
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
|
||||
connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
|
||||
// connect(settingsWidget->getIdentityForm(), &IdentityForm::userNameChanged, Core::getInstance(), &Core::setUsername);
|
||||
// connect(settingsWidget->getIdentityForm(), &IdentityForm::statusMessageChanged, Core::getInstance(), &Core::setStatusMessage);
|
||||
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
||||
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
||||
connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString)));
|
||||
|
@ -193,6 +189,7 @@ void Widget::init()
|
|||
|
||||
coreThread->start();
|
||||
|
||||
settingsWidget = new SettingsWidget();
|
||||
friendForm.show(*ui);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ public:
|
|||
QThread* getCoreThread();
|
||||
Camera* getCamera();
|
||||
static Widget* getInstance();
|
||||
void init();
|
||||
void newMessageAlert();
|
||||
bool isFriendWidgetCurActiveWidget(Friend* f);
|
||||
bool getIsWindowMinimized();
|
||||
|
@ -115,6 +114,7 @@ private slots:
|
|||
void onUserAway();
|
||||
|
||||
private:
|
||||
void init();
|
||||
void hideMainForms();
|
||||
virtual bool event(QEvent * e);
|
||||
Group* createGroup(int groupId);
|
||||
|
|
Loading…
Reference in New Issue
Block a user