Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(settings): Deleted settings header
Browse files Browse the repository at this point in the history
  • Loading branch information
Diadlo committed Aug 26, 2016
1 parent 9c9f1c1 commit a1041ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
39 changes: 7 additions & 32 deletions src/widget/form/settingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand All @@ -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;
}

Expand All @@ -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());
}
2 changes: 0 additions & 2 deletions src/widget/form/settingswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ private slots:
void retranslateUi();

private:
QWidget *head, *body;
QTabWidget *settingsWidgets;
QLabel *nameLabel, *imgLabel;
std::array<GenericForm*, 6> cfgForms;
int currentIndex;
};
Expand Down

0 comments on commit a1041ed

Please sign in to comment.