Skip to content

Commit 5e9a058

Browse files
author
wonder
committedNov 3, 2009
let dialogs ignore escape key when embedded in other dialog. this prevents 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

6 files changed

+53
-1
lines changed
 

‎src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <QStandardItemModel>
2323
#include <QStandardItem>
24+
#include <QKeyEvent>
2425

2526
QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent, bool embedded)
2627
: QDialog(parent), mStyle(style)
@@ -556,3 +557,16 @@ void QgsRendererV2PropertiesDialog::symbolLevels()
556557
mRenderer->setUsingSymbolLevels( dlg.usingLevels() );
557558
}
558559
}
560+
561+
void QgsRendererV2PropertiesDialog::keyPressEvent( QKeyEvent * e )
562+
{
563+
// Ignore the ESC key to avoid close the dialog without the properties window
564+
if ( !isWindow() && e->key() == Qt::Key_Escape )
565+
{
566+
e->ignore();
567+
}
568+
else
569+
{
570+
QDialog::keyPressEvent(e);
571+
}
572+
}

‎src/gui/symbology-ng/qgsrendererv2propertiesdialog.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public slots:
4242
void apply();
4343

4444
protected:
45-
45+
46+
//! Reimplements dialog keyPress event so we can ignore it
47+
void keyPressEvent( QKeyEvent * event );
48+
4649
//! update UI to reflect changes in renderer
4750
void updateUiFromRenderer();
4851

‎src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <QFile>
55
#include <QStandardItem>
6+
#include <QKeyEvent>
67

78
#include "qgssymbollayerv2.h"
89
#include "qgssymbolv2.h"
@@ -367,3 +368,18 @@ void QgsSymbolV2PropertiesDialog::lockLayer()
367368

368369
layer->setLocked( btnLock->isChecked() );
369370
}
371+
372+
#include "qgslogger.h"
373+
374+
void QgsSymbolV2PropertiesDialog::keyPressEvent( QKeyEvent * e )
375+
{
376+
// Ignore the ESC key to avoid close the dialog without the properties window
377+
if ( !isWindow() && e->key() == Qt::Key_Escape )
378+
{
379+
e->ignore();
380+
}
381+
else
382+
{
383+
QDialog::keyPressEvent(e);
384+
}
385+
}

‎src/gui/symbology-ng/qgssymbolv2propertiesdialog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public slots:
3939

4040
protected:
4141

42+
//! Reimplements dialog keyPress event so we can ignore it
43+
void keyPressEvent( QKeyEvent * event );
44+
4245
void loadSymbol();
4346

4447
void populateLayerTypes();

‎src/gui/symbology-ng/qgssymbolv2selectordialog.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <QPainter>
1414
#include <QStandardItemModel>
1515
#include <QInputDialog>
16+
#include <QKeyEvent>
1617

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

203204
populateSymbolView();
204205
}
206+
207+
void QgsSymbolV2SelectorDialog::keyPressEvent( QKeyEvent * e )
208+
{
209+
// Ignore the ESC key to avoid close the dialog without the properties window
210+
if ( !isWindow() && e->key() == Qt::Key_Escape )
211+
{
212+
e->ignore();
213+
}
214+
else
215+
{
216+
QDialog::keyPressEvent(e);
217+
}
218+
}

‎src/gui/symbology-ng/qgssymbolv2selectordialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymbolV2Selecto
2222
void updateSymbolColor();
2323
void updateSymbolInfo();
2424

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

2628
public slots:
2729
void changeSymbolProperties();

0 commit comments

Comments
 (0)
Please sign in to comment.