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

feat(settings): Deleted settings header

This commit is contained in:
Diadlo 2016-07-09 23:50:27 +03:00
parent 9c9f1c11d1
commit a1041ed11a
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
2 changed files with 7 additions and 34 deletions

View File

@ -40,27 +40,10 @@ SettingsWidget::SettingsWidget(QWidget* parent)
// block all signals during initialization, including child widgets // block all signals during initialization, including child widgets
blockSignals(true); blockSignals(true);
body = new QWidget();
QVBoxLayout* bodyLayout = new QVBoxLayout(); QVBoxLayout* bodyLayout = new QVBoxLayout();
body->setLayout(bodyLayout);
head = new QWidget(this);
QHBoxLayout* headLayout = new QHBoxLayout();
head->setLayout(headLayout);
imgLabel = new QLabel();
headLayout->addWidget(imgLabel);
nameLabel = new QLabel();
QFont bold;
bold.setBold(true);
nameLabel->setFont(bold);
headLayout->addWidget(nameLabel);
headLayout->addStretch(1);
settingsWidgets = new QTabWidget(this); settingsWidgets = new QTabWidget(this);
settingsWidgets->setTabPosition(QTabWidget::North); settingsWidgets->setTabPosition(QTabWidget::North);
bodyLayout->addWidget(settingsWidgets); bodyLayout->addWidget(settingsWidgets);
GeneralForm* gfrm = new GeneralForm(this); GeneralForm* gfrm = new GeneralForm(this);
@ -88,8 +71,7 @@ SettingsWidget::~SettingsWidget()
void SettingsWidget::setBodyHeadStyle(QString style) void SettingsWidget::setBodyHeadStyle(QString style)
{ {
head->setStyle(QStyleFactory::create(style)); settingsWidgets->setStyle(QStyleFactory::create(style));
body->setStyle(QStyleFactory::create(style));
} }
void SettingsWidget::showAbout() void SettingsWidget::showAbout()
@ -99,9 +81,9 @@ void SettingsWidget::showAbout()
bool SettingsWidget::isShown() const bool SettingsWidget::isShown() const
{ {
if (body->isVisible()) if (settingsWidgets->isVisible())
{ {
body->window()->windowHandle()->alert(0); settingsWidgets->window()->windowHandle()->alert(0);
return true; return true;
} }
@ -110,25 +92,18 @@ bool SettingsWidget::isShown() const
void SettingsWidget::show(ContentLayout* contentLayout) void SettingsWidget::show(ContentLayout* contentLayout)
{ {
contentLayout->mainContent->layout()->addWidget(body); contentLayout->mainContent->layout()->addWidget(settingsWidgets);
contentLayout->mainHead->layout()->addWidget(head); settingsWidgets->show();
body->show();
head->show();
onTabChanged(settingsWidgets->currentIndex()); onTabChanged(settingsWidgets->currentIndex());
} }
void SettingsWidget::onTabChanged(int index) void SettingsWidget::onTabChanged(int index)
{ {
this->settingsWidgets->setCurrentIndex(index); settingsWidgets->setCurrentIndex(index);
GenericForm* currentWidget = static_cast<GenericForm*>(this->settingsWidgets->widget(index));
nameLabel->setText(currentWidget->getFormName());
imgLabel->setPixmap(currentWidget->getFormIcon().scaledToHeight(40, Qt::SmoothTransformation));
} }
void SettingsWidget::retranslateUi() void SettingsWidget::retranslateUi()
{ {
GenericForm* currentWidget = static_cast<GenericForm*>(settingsWidgets->currentWidget()); for (size_t i = 0; i < cfgForms.size(); i++)
nameLabel->setText(currentWidget->getFormName());
for (size_t i=0; i<cfgForms.size(); i++)
settingsWidgets->setTabText(i, cfgForms[i]->getFormName()); settingsWidgets->setTabText(i, cfgForms[i]->getFormName());
} }

View File

@ -54,9 +54,7 @@ private:
void retranslateUi(); void retranslateUi();
private: private:
QWidget *head, *body;
QTabWidget *settingsWidgets; QTabWidget *settingsWidgets;
QLabel *nameLabel, *imgLabel;
std::array<GenericForm*, 6> cfgForms; std::array<GenericForm*, 6> cfgForms;
int currentIndex; int currentIndex;
}; };