Skip to content

Commit

Permalink
add qdsdialog widget - generic dialog with layout and button box
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed Jul 23, 2012
1 parent 4327e44 commit a5e010f
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -51,6 +51,7 @@ qgscursors.cpp
qgsdetaileditemdelegate.cpp
qgsdetaileditemwidget.cpp
qgsdetaileditemdata.cpp
qgsdialog.cpp
qgsencodingfiledialog.cpp
qgsfiledropedit.cpp
qgsfieldvalidator.cpp
Expand Down Expand Up @@ -139,6 +140,7 @@ qgsattributeeditor.h
qgscomposerview.h
qgsdetaileditemdelegate.h
qgsdetaileditemwidget.h
qgsdialog.h
qgslegendinterface.h
qgisinterface.h
qgsencodingfiledialog.h
Expand Down
45 changes: 45 additions & 0 deletions src/gui/qgsdialog.cpp
@@ -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()
{
}

49 changes: 49 additions & 0 deletions src/gui/qgsdialog.h
@@ -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

0 comments on commit a5e010f

Please sign in to comment.