|
|
|
@ -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)
|
|
|
|
|