Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add qdsdialog widget - generic dialog with layout and button box
- Loading branch information
1 parent
4327e44
commit a5e010f
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*************************************************************************** | ||
qgsdialog.cpp | ||
------------------- | ||
begin : July 2012 | ||
copyright : (C) 2012 by Etienne Tourigny | ||
email : etourigny dot dev at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsdialog.h" | ||
|
||
QgsDialog::QgsDialog( QWidget *parent, Qt::WFlags fl, | ||
QDialogButtonBox::StandardButtons buttons, | ||
Qt::Orientation orientation ) | ||
: QDialog( parent, fl ) | ||
{ | ||
// create buttonbox | ||
mButtonBox = new QDialogButtonBox( buttons, orientation, this ); | ||
connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); | ||
connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); | ||
|
||
// layout | ||
QLayout *layout = 0; | ||
if ( orientation == Qt::Horizontal ) | ||
layout = new QVBoxLayout(); | ||
else | ||
layout = new QHBoxLayout(); | ||
mLayout = new QVBoxLayout(); | ||
layout->addItem( mLayout ); | ||
layout->addWidget( mButtonBox ); | ||
setLayout( layout ); | ||
} | ||
|
||
QgsDialog::~QgsDialog() | ||
{ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*************************************************************************** | ||
qgsdialog.h | ||
------------------- | ||
begin : July 2012 | ||
copyright : (C) 2012 by Etienne Tourigny | ||
email : etourigny dot dev at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSDIALOG_H | ||
#define QGSDIALOG_H | ||
|
||
#include "qgisgui.h" | ||
|
||
#include <QDialog> | ||
#include <QDialogButtonBox> | ||
#include <QLayout> | ||
|
||
/** \ingroup gui | ||
* A generic dialog with layout and button box | ||
*/ | ||
class GUI_EXPORT QgsDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsDialog( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags, | ||
QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close, | ||
Qt::Orientation orientation = Qt::Horizontal ); | ||
~QgsDialog(); | ||
|
||
//! Returns the central layout. Widgets added to it must have this dialog as parent. | ||
QVBoxLayout *layout() { return mLayout; } | ||
//! Returns the button box. | ||
QDialogButtonBox *buttonBox() { return mButtonBox; } | ||
|
||
protected: | ||
QVBoxLayout *mLayout; | ||
QDialogButtonBox *mButtonBox; | ||
}; | ||
|
||
#endif |