Skip to content

Commit ee3bf0e

Browse files
committedJul 23, 2012
use QgsDialog ; formatting cleanup
1 parent a5e010f commit ee3bf0e

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "qgsproject.h"
2828

2929
#include "qgsrasterformatoptionswidget.h"
30+
#include "qgsdialog.h"
3031

3132
#include <QInputDialog>
3233
#include <QFileDialog>
@@ -1093,30 +1094,23 @@ void QgsOptions::editGdalDriver( const QString& driverName )
10931094
if ( driverName.isEmpty() )
10941095
return;
10951096

1096-
QDialog dlg( this );
1097-
QVBoxLayout *layout = new QVBoxLayout();
1097+
QgsDialog dlg( this, 0, QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
1098+
QVBoxLayout *layout = dlg.layout();
10981099
QString title = tr( "Create Options - %1 Driver" ).arg( driverName );
10991100
if ( driverName == "_pyramids" )
11001101
title = tr( "Create Options - pyramids" );
11011102
dlg.setWindowTitle( title );
1102-
QLabel *label = new QLabel( title );
1103+
QLabel *label = new QLabel( title, &dlg );
11031104
label->setAlignment( Qt::AlignHCenter );
11041105
layout->addWidget( label );
1105-
QgsRasterFormatOptionsWidget* optionsWidget = new QgsRasterFormatOptionsWidget( 0, driverName, "gdal" );
1106+
QgsRasterFormatOptionsWidget* optionsWidget = new QgsRasterFormatOptionsWidget( &dlg, driverName, "gdal" );
11061107
layout->addWidget( optionsWidget );
11071108
optionsWidget->showProfileButtons( true );
1108-
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
1109-
connect( buttonBox, SIGNAL( accepted() ), &dlg, SLOT( accept() ) );
1110-
connect( buttonBox, SIGNAL( rejected() ), &dlg, SLOT( reject() ) );
1111-
layout->addWidget( buttonBox );
1112-
dlg.setLayout( layout );
11131109

11141110
if ( dlg.exec() == QDialog::Accepted )
11151111
{
1116-
// perhaps setting should not be applied already, but this is easier
11171112
optionsWidget->apply();
11181113
}
1119-
delete optionsWidget;
11201114
}
11211115

11221116
// Return state of the visibility flag for newly added layers. If

‎src/gui/raster/qgsrasterformatoptionswidget.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1+
/***************************************************************************
2+
qgsrasterformatoptionswidget.cpp
3+
-------------------
4+
begin : July 2012
5+
copyright : (C) 2012 by Etienne Tourigny
6+
email : etourigny dot dev at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
118
#include "qgsrasterformatoptionswidget.h"
219
#include "qgslogger.h"
20+
#include "qgsdialog.h"
321

422
#include "gdal.h"
523
#include "cpl_string.h"
@@ -10,7 +28,6 @@
1028
#include <QInputDialog>
1129
#include <QMessageBox>
1230
#include <QTextEdit>
13-
#include <QDialogButtonBox>
1431

1532
// todo put this somewhere else - how can we access gdal provider?
1633
char** papszFromStringList( const QStringList& list )
@@ -187,18 +204,12 @@ void QgsRasterFormatOptionsWidget::optionsHelp()
187204
else
188205
message = tr( "No help available" );
189206

190-
// show simple noon-modal dialog - should we make this basic xml pretty?
191-
QDialog *dlg = new QDialog( this );
192-
QVBoxLayout *layout = new QVBoxLayout();
207+
// show simple non-modal dialog - should we make the basic xml prettier?
208+
QgsDialog *dlg = new QgsDialog( this );
193209
QTextEdit *textEdit = new QTextEdit( dlg );
194-
layout->addWidget( textEdit );
195210
textEdit->setReadOnly( true );
196211
textEdit->setText( message );
197-
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Close );
198-
connect( buttonBox, SIGNAL( accepted() ), dlg, SLOT( accept() ) );
199-
connect( buttonBox, SIGNAL( rejected() ), dlg, SLOT( reject() ) );
200-
layout->addWidget( buttonBox );
201-
dlg->setLayout( layout );
212+
dlg->layout()->addWidget( textEdit );
202213
dlg->resize( 600, 600 );
203214
dlg->show(); //non modal
204215
}

‎src/gui/raster/qgsrasterformatoptionswidget.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
/***************************************************************************
2+
qgsrasterformatoptionswidget.h
3+
-------------------
4+
begin : July 2012
5+
copyright : (C) 2012 by Etienne Tourigny
6+
email : etourigny dot dev at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
118
#ifndef QGSRASTERFORMATOPTIONSWIDGET_H
219
#define QGSRASTERFORMATOPTIONSWIDGET_H
320

421
#include "ui_qgsrasterformatoptionswidgetbase.h"
522

6-
//class QgsRasterDataProvider;
7-
823
class GUI_EXPORT QgsRasterFormatOptionsWidget: public QWidget, private Ui::QgsRasterFormatOptionsWidgetBase
924
{
1025
Q_OBJECT

0 commit comments

Comments
 (0)
Please sign in to comment.