mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Preferences: Hook up the dialog buttons and make it work
Since I'm using a dialog created by hand, I also need to hook things by hand. the code is very simple - debug output kept in just to make sure things are indeed working. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									b7a476169d
								
							
						
					
					
						commit
						b7daffbf08
					
				
					 2 changed files with 25 additions and 7 deletions
				
			
		|  | @ -8,12 +8,17 @@ | ||||||
| #include <QListWidget> | #include <QListWidget> | ||||||
| #include <QStackedWidget> | #include <QStackedWidget> | ||||||
| #include <QDialogButtonBox> | #include <QDialogButtonBox> | ||||||
|  | #include <QAbstractButton> | ||||||
|  | #include <QDebug> | ||||||
| 
 | 
 | ||||||
| PreferencesDialogV2::PreferencesDialogV2() | PreferencesDialogV2::PreferencesDialogV2() | ||||||
| { | { | ||||||
| 	pagesList = new QListWidget(); | 	pagesList = new QListWidget(); | ||||||
| 	pagesStack = new QStackedWidget(); | 	pagesStack = new QStackedWidget(); | ||||||
| 	buttonBox = new QDialogButtonBox(QDialogButtonBox::Apply|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Cancel); | 	buttonBox = new QDialogButtonBox( | ||||||
|  | 		QDialogButtonBox::Save | | ||||||
|  | 		QDialogButtonBox::RestoreDefaults | | ||||||
|  | 		QDialogButtonBox::Cancel); | ||||||
| 
 | 
 | ||||||
| 	pagesList->setMinimumWidth(120); | 	pagesList->setMinimumWidth(120); | ||||||
| 	pagesList->setMaximumWidth(120); | 	pagesList->setMaximumWidth(120); | ||||||
|  | @ -21,7 +26,6 @@ PreferencesDialogV2::PreferencesDialogV2() | ||||||
| 	QHBoxLayout *h = new QHBoxLayout(); | 	QHBoxLayout *h = new QHBoxLayout(); | ||||||
| 	h->addWidget(pagesList); | 	h->addWidget(pagesList); | ||||||
| 	h->addWidget(pagesStack); | 	h->addWidget(pagesStack); | ||||||
| 
 |  | ||||||
| 	QVBoxLayout *v = new QVBoxLayout(); | 	QVBoxLayout *v = new QVBoxLayout(); | ||||||
| 	v->addLayout(h); | 	v->addLayout(h); | ||||||
| 	v->addWidget(buttonBox); | 	v->addWidget(buttonBox); | ||||||
|  | @ -30,14 +34,27 @@ PreferencesDialogV2::PreferencesDialogV2() | ||||||
| 
 | 
 | ||||||
| 	addPreferencePage(new PreferencesLanguage()); | 	addPreferencePage(new PreferencesLanguage()); | ||||||
| 	refreshPages(); | 	refreshPages(); | ||||||
|  | 
 | ||||||
| 	connect(pagesList, &QListWidget::currentRowChanged, | 	connect(pagesList, &QListWidget::currentRowChanged, | ||||||
| 		pagesStack, &QStackedWidget::setCurrentIndex); | 		pagesStack, &QStackedWidget::setCurrentIndex); | ||||||
|  | 	connect(buttonBox, &QDialogButtonBox::clicked, | ||||||
|  | 		this, &PreferencesDialogV2::buttonClicked); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| PreferencesDialogV2::~PreferencesDialogV2() | PreferencesDialogV2::~PreferencesDialogV2() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void PreferencesDialogV2::buttonClicked(QAbstractButton* btn) | ||||||
|  | { | ||||||
|  | 	QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(btn); | ||||||
|  | 	switch(role) { | ||||||
|  | 		case QDialogButtonBox::AcceptRole : applyRequested(); return; | ||||||
|  | 		case QDialogButtonBox::RejectRole : cancelRequested(); return; | ||||||
|  | 		case QDialogButtonBox::ResetRole : defaultsRequested(); return; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2) | bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2) | ||||||
| { | { | ||||||
| 	return p1->positionHeight() <= p2->positionHeight(); | 	return p1->positionHeight() <= p2->positionHeight(); | ||||||
|  | @ -69,15 +86,15 @@ void PreferencesDialogV2::refreshPages() | ||||||
| 
 | 
 | ||||||
| void PreferencesDialogV2::applyRequested() | void PreferencesDialogV2::applyRequested() | ||||||
| { | { | ||||||
| 	//TODO
 | 	qDebug() << "Apply Clicked"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PreferencesDialogV2::cancelRequested() | void PreferencesDialogV2::cancelRequested() | ||||||
| { | { | ||||||
| 	//TODO
 | 	qDebug() << "Cancel Clicked"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PreferencesDialogV2::defaultsRequested() | void PreferencesDialogV2::defaultsRequested() | ||||||
| { | { | ||||||
| 	//TODO
 | 	qDebug() << "Defaults Clicked"; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ class AbstractPreferencesWidget; | ||||||
| class QListWidget; | class QListWidget; | ||||||
| class QStackedWidget; | class QStackedWidget; | ||||||
| class QDialogButtonBox; | class QDialogButtonBox; | ||||||
|  | class QAbstractButton; | ||||||
| 
 | 
 | ||||||
| class PreferencesDialogV2 : public QDialog { | class PreferencesDialogV2 : public QDialog { | ||||||
| 	Q_OBJECT | 	Q_OBJECT | ||||||
|  | @ -20,7 +21,7 @@ private: | ||||||
| 	void cancelRequested(); | 	void cancelRequested(); | ||||||
| 	void applyRequested(); | 	void applyRequested(); | ||||||
| 	void defaultsRequested(); | 	void defaultsRequested(); | ||||||
| 
 | 	void buttonClicked(QAbstractButton *btn); | ||||||
| 	QList<AbstractPreferencesWidget*> pages; | 	QList<AbstractPreferencesWidget*> pages; | ||||||
| 	QListWidget *pagesList; | 	QListWidget *pagesList; | ||||||
| 	QStackedWidget *pagesStack; | 	QStackedWidget *pagesStack; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue