Skip to content
Permalink
Browse files

add qdsdialog widget - generic dialog with layout and button box

  • Loading branch information
etiennesky committed Jul 23, 2012
1 parent 4327e44 commit a5e010f735f11da1ee6ffe22c32bfaa788ab17bf
Showing with 96 additions and 0 deletions.
  1. +2 −0 src/gui/CMakeLists.txt
  2. +45 −0 src/gui/qgsdialog.cpp
  3. +49 −0 src/gui/qgsdialog.h
@@ -51,6 +51,7 @@ qgscursors.cpp
qgsdetaileditemdelegate.cpp
qgsdetaileditemwidget.cpp
qgsdetaileditemdata.cpp
qgsdialog.cpp
qgsencodingfiledialog.cpp
qgsfiledropedit.cpp
qgsfieldvalidator.cpp
@@ -139,6 +140,7 @@ qgsattributeeditor.h
qgscomposerview.h
qgsdetaileditemdelegate.h
qgsdetaileditemwidget.h
qgsdialog.h
qgslegendinterface.h
qgisinterface.h
qgsencodingfiledialog.h
@@ -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()
{
}

@@ -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.
You can’t perform that action at this time.