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
blockSignals(true);
body = new QWidget();
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->setTabPosition(QTabWidget::North);
bodyLayout->addWidget(settingsWidgets);
GeneralForm* gfrm = new GeneralForm(this);
@ -88,8 +71,7 @@ SettingsWidget::~SettingsWidget()
void SettingsWidget::setBodyHeadStyle(QString style)
{
head->setStyle(QStyleFactory::create(style));
body->setStyle(QStyleFactory::create(style));
settingsWidgets->setStyle(QStyleFactory::create(style));
}
void SettingsWidget::showAbout()
@ -99,9 +81,9 @@ void SettingsWidget::showAbout()
bool SettingsWidget::isShown() const
{
if (body->isVisible())
if (settingsWidgets->isVisible())
{
body->window()->windowHandle()->alert(0);
settingsWidgets->window()->windowHandle()->alert(0);
return true;
}
@ -110,25 +92,18 @@ bool SettingsWidget::isShown() const
void SettingsWidget::show(ContentLayout* contentLayout)
{
contentLayout->mainContent->layout()->addWidget(body);
contentLayout->mainHead->layout()->addWidget(head);
body->show();
head->show();
contentLayout->mainContent->layout()->addWidget(settingsWidgets);
settingsWidgets->show();
onTabChanged(settingsWidgets->currentIndex());
}
void SettingsWidget::onTabChanged(int index)
{
this->settingsWidgets->setCurrentIndex(index);
GenericForm* currentWidget = static_cast<GenericForm*>(this->settingsWidgets->widget(index));
nameLabel->setText(currentWidget->getFormName());
imgLabel->setPixmap(currentWidget->getFormIcon().scaledToHeight(40, Qt::SmoothTransformation));
settingsWidgets->setCurrentIndex(index);
}
void SettingsWidget::retranslateUi()
{
GenericForm* currentWidget = static_cast<GenericForm*>(settingsWidgets->currentWidget());
nameLabel->setText(currentWidget->getFormName());
for (size_t i=0; i<cfgForms.size(); i++)
for (size_t i = 0; i < cfgForms.size(); i++)
settingsWidgets->setTabText(i, cfgForms[i]->getFormName());
}

View File

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