Skip to content

Commit a5e010f

Browse files
committed
add qdsdialog widget - generic dialog with layout and button box
1 parent 4327e44 commit a5e010f

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

src/gui/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ qgscursors.cpp
5151
qgsdetaileditemdelegate.cpp
5252
qgsdetaileditemwidget.cpp
5353
qgsdetaileditemdata.cpp
54+
qgsdialog.cpp
5455
qgsencodingfiledialog.cpp
5556
qgsfiledropedit.cpp
5657
qgsfieldvalidator.cpp
@@ -139,6 +140,7 @@ qgsattributeeditor.h
139140
qgscomposerview.h
140141
qgsdetaileditemdelegate.h
141142
qgsdetaileditemwidget.h
143+
qgsdialog.h
142144
qgslegendinterface.h
143145
qgisinterface.h
144146
qgsencodingfiledialog.h

src/gui/qgsdialog.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/***************************************************************************
2+
qgsdialog.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+
18+
#include "qgsdialog.h"
19+
20+
QgsDialog::QgsDialog( QWidget *parent, Qt::WFlags fl,
21+
QDialogButtonBox::StandardButtons buttons,
22+
Qt::Orientation orientation )
23+
: QDialog( parent, fl )
24+
{
25+
// create buttonbox
26+
mButtonBox = new QDialogButtonBox( buttons, orientation, this );
27+
connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
28+
connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
29+
30+
// layout
31+
QLayout *layout = 0;
32+
if ( orientation == Qt::Horizontal )
33+
layout = new QVBoxLayout();
34+
else
35+
layout = new QHBoxLayout();
36+
mLayout = new QVBoxLayout();
37+
layout->addItem( mLayout );
38+
layout->addWidget( mButtonBox );
39+
setLayout( layout );
40+
}
41+
42+
QgsDialog::~QgsDialog()
43+
{
44+
}
45+

src/gui/qgsdialog.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/***************************************************************************
2+
qgsdialog.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+
18+
#ifndef QGSDIALOG_H
19+
#define QGSDIALOG_H
20+
21+
#include "qgisgui.h"
22+
23+
#include <QDialog>
24+
#include <QDialogButtonBox>
25+
#include <QLayout>
26+
27+
/** \ingroup gui
28+
* A generic dialog with layout and button box
29+
*/
30+
class GUI_EXPORT QgsDialog : public QDialog
31+
{
32+
Q_OBJECT
33+
public:
34+
QgsDialog( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags,
35+
QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close,
36+
Qt::Orientation orientation = Qt::Horizontal );
37+
~QgsDialog();
38+
39+
//! Returns the central layout. Widgets added to it must have this dialog as parent.
40+
QVBoxLayout *layout() { return mLayout; }
41+
//! Returns the button box.
42+
QDialogButtonBox *buttonBox() { return mButtonBox; }
43+
44+
protected:
45+
QVBoxLayout *mLayout;
46+
QDialogButtonBox *mButtonBox;
47+
};
48+
49+
#endif

0 commit comments

Comments
 (0)