diff options
Diffstat (limited to 'src/frontend/bookshelfmanager/btconfigdialog.cpp')
-rw-r--r-- | src/frontend/bookshelfmanager/btconfigdialog.cpp | 145 |
1 files changed, 70 insertions, 75 deletions
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp index 87cb12e..0fcbc5a 100644 --- a/src/frontend/bookshelfmanager/btconfigdialog.cpp +++ b/src/frontend/bookshelfmanager/btconfigdialog.cpp @@ -26,93 +26,88 @@ #include <QEvent> BtConfigDialog::BtConfigDialog(QWidget* parent) - : QDialog(parent), - m_maxItemWidth(0), - m_previousPageIndex(-2) -{ - setWindowFlags(Qt::Window); - m_contentsList = new QListWidget(this); - m_contentsList->setViewMode(QListView::IconMode); - m_contentsList->setMovement(QListView::Static); - - m_pageWidget = new QStackedWidget(this); - m_pageWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - - QHBoxLayout *mainLayout = new QHBoxLayout; - setLayout(mainLayout); - mainLayout->addWidget(m_contentsList); - m_pageLayout = new QVBoxLayout; - mainLayout->addLayout(m_pageLayout); - - m_pageLayout->addWidget(m_pageWidget); - - // Horizontal line - QFrame* line = new QFrame(); - line->setGeometry(QRect(1, 1, 1, 3)); + : QDialog(parent), + m_maxItemWidth(0), + m_previousPageIndex(-2) { + setWindowFlags(Qt::Window); + m_contentsList = new QListWidget(this); + m_contentsList->setViewMode(QListView::IconMode); + m_contentsList->setMovement(QListView::Static); + + m_pageWidget = new QStackedWidget(this); + m_pageWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + + QHBoxLayout *mainLayout = new QHBoxLayout; + setLayout(mainLayout); + mainLayout->addWidget(m_contentsList); + m_pageLayout = new QVBoxLayout; + mainLayout->addLayout(m_pageLayout); + + m_pageLayout->addWidget(m_pageWidget); + + // Horizontal line + QFrame* line = new QFrame(); + line->setGeometry(QRect(1, 1, 1, 3)); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); - line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - m_pageLayout->addWidget(line); - - connect(m_contentsList, - SIGNAL(currentRowChanged(int)), - this, SLOT(slotChangePage(int)) - ); - + line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + m_pageLayout->addWidget(line); + + connect(m_contentsList, + SIGNAL(currentRowChanged(int)), + this, SLOT(slotChangePage(int)) + ); + } BtConfigDialog::~BtConfigDialog() {} -void BtConfigDialog::addPage(BtConfigPage* pageWidget) -{ - // this is a friend - pageWidget->m_parentDialog = this; - - QVBoxLayout* containerLayout = new QVBoxLayout; - QLabel* headerLabel = CToolClass::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label()); - containerLayout->addWidget(headerLabel); - containerLayout->addWidget(pageWidget); - QWidget* containerWidget = new QWidget(m_pageWidget); - containerWidget->setLayout(containerLayout); - m_pageWidget->addWidget(containerWidget); - - - QListWidgetItem* item = new QListWidgetItem(m_contentsList); - item->setIcon(util::filesystem::DirectoryUtil::getIcon(pageWidget->iconName())); - item->setText(pageWidget->header()); - item->setTextAlignment(Qt::AlignHCenter); - item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - //set the list width - it may bee too wide (if there were no pages) or too narrow - if (m_maxItemWidth < m_contentsList->visualItemRect(item).width()) { - m_maxItemWidth = m_contentsList->visualItemRect(item).width(); - m_contentsList->setFixedWidth( m_maxItemWidth + (m_contentsList->frameWidth()*2) ); - } - // all items should has the same width - for(int i = 0; i < m_contentsList->count(); ++i) { - m_contentsList->item(i)->setSizeHint(QSize(m_maxItemWidth, m_contentsList->visualItemRect(m_contentsList->item(i)).height()) ); - } - - slotChangePage(m_contentsList->row(item)); +void BtConfigDialog::addPage(BtConfigPage* pageWidget) { + // this is a friend + pageWidget->m_parentDialog = this; + + QVBoxLayout* containerLayout = new QVBoxLayout; + QLabel* headerLabel = CToolClass::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label()); + containerLayout->addWidget(headerLabel); + containerLayout->addWidget(pageWidget); + QWidget* containerWidget = new QWidget(m_pageWidget); + containerWidget->setLayout(containerLayout); + m_pageWidget->addWidget(containerWidget); + + + QListWidgetItem* item = new QListWidgetItem(m_contentsList); + item->setIcon(util::filesystem::DirectoryUtil::getIcon(pageWidget->iconName())); + item->setText(pageWidget->header()); + item->setTextAlignment(Qt::AlignHCenter); + item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + //set the list width - it may bee too wide (if there were no pages) or too narrow + if (m_maxItemWidth < m_contentsList->visualItemRect(item).width()) { + m_maxItemWidth = m_contentsList->visualItemRect(item).width(); + m_contentsList->setFixedWidth( m_maxItemWidth + (m_contentsList->frameWidth()*2) ); + } + // all items should has the same width + for (int i = 0; i < m_contentsList->count(); ++i) { + m_contentsList->item(i)->setSizeHint(QSize(m_maxItemWidth, m_contentsList->visualItemRect(m_contentsList->item(i)).height()) ); + } + + slotChangePage(m_contentsList->row(item)); } -void BtConfigDialog::addButtonBox(QDialogButtonBox* box) -{ - m_pageLayout->addWidget(box); +void BtConfigDialog::addButtonBox(QDialogButtonBox* box) { + m_pageLayout->addWidget(box); } -BtConfigPage* BtConfigDialog::currentPage() -{ - return dynamic_cast<BtConfigPage*>(m_pageWidget->currentWidget()); +BtConfigPage* BtConfigDialog::currentPage() { + return dynamic_cast<BtConfigPage*>(m_pageWidget->currentWidget()); } -void BtConfigDialog::slotChangePage(int newIndex) -{ - if (m_previousPageIndex != newIndex) { - m_previousPageIndex = newIndex; - m_contentsList->setCurrentRow(newIndex); - m_pageWidget->setCurrentIndex(newIndex); - } +void BtConfigDialog::slotChangePage(int newIndex) { + if (m_previousPageIndex != newIndex) { + m_previousPageIndex = newIndex; + m_contentsList->setCurrentRow(newIndex); + m_pageWidget->setCurrentIndex(newIndex); + } } |