user settings UI layout improvements

loadfix
Marc Zinnschlag 10 years ago
parent dc788512e2
commit e20fa209cc

@ -1,10 +1,13 @@
#include "dialog.hpp"
#include <algorithm>
#include <QListWidgetItem>
#include <QApplication>
#include <QWidget>
#include <QStackedWidget>
#include <QtGui>
#include <QSplitter>
#include "../../model/settings/usersettings.hpp"
@ -12,8 +15,6 @@
#include <QApplication>
#include <QSplitter>
#include <QTreeView>
#include <QListView>
#include <QTableView>
@ -26,6 +27,10 @@ CSVSettings::Dialog::Dialog(QMainWindow *parent)
{
setWindowTitle(QString::fromUtf8 ("User Settings"));
setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setMinimumSize (600, 400);
setupDialog();
connect (mPageListWidget,
@ -39,20 +44,14 @@ void CSVSettings::Dialog::slotChangePage
{
mStackedWidget->changePage
(mPageListWidget->row (cur), mPageListWidget->row (prev));
layout()->activate();
setFixedSize(minimumSizeHint());
}
void CSVSettings::Dialog::setupDialog()
{
//create central widget with it's layout and immediate children
QWidget *centralWidget = new QGroupBox (this);
QSplitter *centralWidget = new QSplitter (this);
centralWidget->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
centralWidget->setLayout (new QHBoxLayout());
centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred);
setCentralWidget (centralWidget);
setDockOptions (QMainWindow::AllowNestedDocks);
buildPageListWidget (centralWidget);
buildStackedWidget (centralWidget);
@ -64,37 +63,41 @@ void CSVSettings::Dialog::buildPages()
QFontMetrics fm (QApplication::font());
int maxWidth = 1;
foreach (Page *page, SettingWindow::pages())
{
QString pageName = page->objectName();
int textWidth = fm.width(pageName);
maxWidth = std::max (maxWidth, fm.width(pageName));
new QListWidgetItem (pageName, mPageListWidget);
mPageListWidget->setFixedWidth (textWidth + 50);
mStackedWidget->addWidget (&dynamic_cast<QWidget &>(*(page)));
mStackedWidget->addWidget (page);
}
mPageListWidget->setMaximumWidth (maxWidth + 50);
resize (mStackedWidget->sizeHint());
}
void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget)
void CSVSettings::Dialog::buildPageListWidget (QSplitter *centralWidget)
{
mPageListWidget = new QListWidget (centralWidget);
mPageListWidget->setMinimumWidth(50);
mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding);
mPageListWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems);
centralWidget->layout()->addWidget(mPageListWidget);
centralWidget->addWidget(mPageListWidget);
}
void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget)
void CSVSettings::Dialog::buildStackedWidget (QSplitter *centralWidget)
{
mStackedWidget = new ResizeableStackedWidget (centralWidget);
mStackedWidget->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Expanding);
centralWidget->layout()->addWidget (mStackedWidget);
centralWidget->addWidget (mStackedWidget);
}
void CSVSettings::Dialog::closeEvent (QCloseEvent *event)

@ -8,6 +8,7 @@
class QStackedWidget;
class QListWidget;
class QListWidgetItem;
class QSplitter;
namespace CSVSettings {
@ -39,8 +40,8 @@ namespace CSVSettings {
private:
void buildPages();
void buildPageListWidget (QWidget *centralWidget);
void buildStackedWidget (QWidget *centralWidget);
void buildPageListWidget (QSplitter *centralWidget);
void buildStackedWidget (QSplitter *centralWidget);
public slots:

@ -39,7 +39,7 @@ void CSVSettings::Frame::hideWidgets()
QWidget *widg = static_cast <QWidget *> (obj);
if (widg->property("sizePolicy").isValid())
widg->setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Ignored);
widg->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
}
layout()->activate();

@ -34,7 +34,6 @@ void CSVSettings::ResizeableStackedWidget::changePage
curPage->showWidgets();
layout()->activate();
setFixedSize(minimumSizeHint());
setCurrentIndex (current);
}

Loading…
Cancel
Save