#include "qlopsettingsdialog.h" #include "ui_qlopsettingsdialog.h" QLopSettingsDialog::QLopSettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::QLopSettingsDialog) { ui->setupUi(this); connect(ui->contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*))); ui->contentsWidget->setViewMode(QListView::IconMode); ui->contentsWidget->setIconSize(QSize(96, 84)); ui->contentsWidget->setMovement(QListView::Static); ui->contentsWidget->setSpacing(12); } QLopSettingsDialog::~QLopSettingsDialog() { delete ui; } void QLopSettingsDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; } } void QLopSettingsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) { if (!current) current = previous; ui->pagesWidget->setCurrentIndex(ui->contentsWidget->row(current)); } bool QLopSettingsDialog::registerConfigEntry(QWidget *configEntry, QIcon icon, QString text) { if(configEntry!=NULL) { ui->pagesWidget->addWidget(configEntry); QListWidgetItem *configButton = new QListWidgetItem(ui->contentsWidget); configButton->setIcon(icon); configButton->setText(text); configButton->setTextAlignment(Qt::AlignHCenter); configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); return true; } return false; } void QLopSettingsDialog::popConfigDialog(QWidget *selectedConfigEntry) { if(selectedConfigEntry!=NULL) { for(int i=0;ipagesWidget->count();i++) { if(ui->pagesWidget->widget(i)==selectedConfigEntry) { ui->pagesWidget->setCurrentIndex(i); } } } this->show(); }