mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Preferecnes: add the initial skeleton
This Preferences dialog should be visually similar to the old one - the main difference is how it acts on the preferences. It's also not based on .ui files since it's a very simple widget I prefered to mount it by hand - no more than 6 lines of c++ code. Right now we have only one preference page on this, and nothing is hoocked up. I've also changed mainwindow a bit to only show this dialog for testing purposes. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
255325e219
commit
b7a476169d
5 changed files with 118 additions and 1 deletions
83
desktop-widgets/preferences/preferencesdialog.cpp
Normal file
83
desktop-widgets/preferences/preferencesdialog.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "preferencesdialog.h"
|
||||
|
||||
#include "abstractpreferenceswidget.h"
|
||||
#include "preferences_language.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QListWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
PreferencesDialogV2::PreferencesDialogV2()
|
||||
{
|
||||
pagesList = new QListWidget();
|
||||
pagesStack = new QStackedWidget();
|
||||
buttonBox = new QDialogButtonBox(QDialogButtonBox::Apply|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Cancel);
|
||||
|
||||
pagesList->setMinimumWidth(120);
|
||||
pagesList->setMaximumWidth(120);
|
||||
|
||||
QHBoxLayout *h = new QHBoxLayout();
|
||||
h->addWidget(pagesList);
|
||||
h->addWidget(pagesStack);
|
||||
|
||||
QVBoxLayout *v = new QVBoxLayout();
|
||||
v->addLayout(h);
|
||||
v->addWidget(buttonBox);
|
||||
|
||||
setLayout(v);
|
||||
|
||||
addPreferencePage(new PreferencesLanguage());
|
||||
refreshPages();
|
||||
connect(pagesList, &QListWidget::currentRowChanged,
|
||||
pagesStack, &QStackedWidget::setCurrentIndex);
|
||||
}
|
||||
|
||||
PreferencesDialogV2::~PreferencesDialogV2()
|
||||
{
|
||||
}
|
||||
|
||||
bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2)
|
||||
{
|
||||
return p1->positionHeight() <= p2->positionHeight();
|
||||
}
|
||||
|
||||
void PreferencesDialogV2::addPreferencePage(AbstractPreferencesWidget *page)
|
||||
{
|
||||
pages.push_back(page);
|
||||
qSort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan);
|
||||
}
|
||||
|
||||
void PreferencesDialogV2::refreshPages()
|
||||
{
|
||||
// Remove things
|
||||
pagesList->clear();
|
||||
while(pagesStack->count()) {
|
||||
QWidget *curr = pagesStack->widget(0);
|
||||
pagesStack->removeWidget(curr);
|
||||
curr->setParent(0);
|
||||
}
|
||||
|
||||
// Readd things.
|
||||
Q_FOREACH(AbstractPreferencesWidget *page, pages) {
|
||||
QListWidgetItem *item = new QListWidgetItem(page->icon(), page->name());
|
||||
pagesList->addItem(item);
|
||||
pagesStack->addWidget(page);
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialogV2::applyRequested()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void PreferencesDialogV2::cancelRequested()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void PreferencesDialogV2::defaultsRequested()
|
||||
{
|
||||
//TODO
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue