Skip to content

Commit

Permalink
let dialogs ignore escape key when embedded in other dialog. this pre…
Browse files Browse the repository at this point in the history
…vents that they get closed leaving blank space in the parent dialog.

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11910 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 3, 2009
1 parent 4654732 commit 5e9a058
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <QStandardItemModel>
#include <QStandardItem>
#include <QKeyEvent>

QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent, bool embedded)
: QDialog(parent), mStyle(style)
Expand Down Expand Up @@ -556,3 +557,16 @@ void QgsRendererV2PropertiesDialog::symbolLevels()
mRenderer->setUsingSymbolLevels( dlg.usingLevels() );
}
}

void QgsRendererV2PropertiesDialog::keyPressEvent( QKeyEvent * e )
{
// Ignore the ESC key to avoid close the dialog without the properties window
if ( !isWindow() && e->key() == Qt::Key_Escape )
{
e->ignore();
}
else
{
QDialog::keyPressEvent(e);
}
}
5 changes: 4 additions & 1 deletion src/gui/symbology-ng/qgsrendererv2propertiesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public slots:
void apply();

protected:


//! Reimplements dialog keyPress event so we can ignore it
void keyPressEvent( QKeyEvent * event );

//! update UI to reflect changes in renderer
void updateUiFromRenderer();

Expand Down
16 changes: 16 additions & 0 deletions src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QFile>
#include <QStandardItem>
#include <QKeyEvent>

#include "qgssymbollayerv2.h"
#include "qgssymbolv2.h"
Expand Down Expand Up @@ -367,3 +368,18 @@ void QgsSymbolV2PropertiesDialog::lockLayer()

layer->setLocked( btnLock->isChecked() );
}

#include "qgslogger.h"

void QgsSymbolV2PropertiesDialog::keyPressEvent( QKeyEvent * e )
{
// Ignore the ESC key to avoid close the dialog without the properties window
if ( !isWindow() && e->key() == Qt::Key_Escape )
{
e->ignore();
}
else
{
QDialog::keyPressEvent(e);
}
}
3 changes: 3 additions & 0 deletions src/gui/symbology-ng/qgssymbolv2propertiesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public slots:

protected:

//! Reimplements dialog keyPress event so we can ignore it
void keyPressEvent( QKeyEvent * event );

void loadSymbol();

void populateLayerTypes();
Expand Down
14 changes: 14 additions & 0 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QPainter>
#include <QStandardItemModel>
#include <QInputDialog>
#include <QKeyEvent>

QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent, bool embedded)
: QDialog(parent)
Expand Down Expand Up @@ -202,3 +203,16 @@ void QgsSymbolV2SelectorDialog::addSymbolToStyle()

populateSymbolView();
}

void QgsSymbolV2SelectorDialog::keyPressEvent( QKeyEvent * e )
{
// Ignore the ESC key to avoid close the dialog without the properties window
if ( !isWindow() && e->key() == Qt::Key_Escape )
{
e->ignore();
}
else
{
QDialog::keyPressEvent(e);
}
}
2 changes: 2 additions & 0 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymbolV2Selecto
void updateSymbolColor();
void updateSymbolInfo();

//! Reimplements dialog keyPress event so we can ignore it
void keyPressEvent( QKeyEvent * event );

public slots:
void changeSymbolProperties();
Expand Down

0 comments on commit 5e9a058

Please sign in to comment.