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