Ignore key events in dialogs and let parent task panel handle them

The affected dialogs are:
* Texture mapping
* Cross-sections
* Extrusion
* Revolution
This commit is contained in:
wmayer
2018-09-13 11:13:33 +02:00
parent ba2cdde66e
commit 88babaf60a
8 changed files with 47 additions and 1 deletions

View File

@@ -29,6 +29,7 @@
# include <QImage>
# include <QMessageBox>
# include <QImageReader>
# include <QKeyEvent>
#endif
#include <Inventor/nodes/SoTextureCoordinateEnvironment.h>
@@ -55,6 +56,9 @@ TextureMapping::TextureMapping(QWidget* parent, Qt::WindowFlags fl)
ui->setupUi(this);
ui->checkGlobal->hide();
// set a dummy string which is not a valid file name
fileName = QLatin1String("<>");
// add all supported QImage formats
QStringList formats;
QList<QByteArray> qtformats = QImageReader::supportedImageFormats();
@@ -111,11 +115,25 @@ void TextureMapping::changeEvent(QEvent *e)
}
}
void TextureMapping::keyPressEvent(QKeyEvent *e)
{
// The texture mapping dialog is embedded into a task panel
// which is a parent widget and will handle the event
e->ignore();
}
void TextureMapping::on_fileChooser_fileNameSelected(const QString& s)
{
QImage image;
if (!image.load(s)) {
QMessageBox::warning(this, tr("No image"), tr("The specified file is not a valid image file."));
// This slot is always invoked when leaving the focus of the line edit
// and to avoid to run into an infinite loop of popping up the dialog
// there is a check to report the last selected file name (which might
// be an empty string) only once.
if (fileName != s) {
QMessageBox::warning(this, tr("No image"), tr("The specified file is not a valid image file."));
fileName = s;
}
return;
}

View File

@@ -50,11 +50,13 @@ private Q_SLOTS:
protected:
void changeEvent(QEvent *e);
void keyPressEvent(QKeyEvent *e);
private:
SoGroup* grp;
SoTexture2* tex;
SoTextureCoordinateEnvironment* env;
QString fileName;
Ui_TextureMapping* ui;
};

View File

@@ -34,6 +34,7 @@
# include <cfloat>
# include <QFuture>
# include <QFutureWatcher>
# include <QKeyEvent>
# include <QtConcurrentMap>
# include <boost/bind.hpp>
# include <Python.h>
@@ -176,6 +177,13 @@ void CrossSections::changeEvent(QEvent *e)
}
}
void CrossSections::keyPressEvent(QKeyEvent* ke)
{
// The cross-sections dialog is embedded into a task panel
// which is a parent widget and will handle the event
ke->ignore();
}
void CrossSections::accept()
{
apply();

View File

@@ -51,6 +51,7 @@ public:
protected:
void changeEvent(QEvent *e);
void keyPressEvent(QKeyEvent*);
private Q_SLOTS:
void on_xyPlane_clicked();

View File

@@ -34,6 +34,7 @@
# include <TopExp_Explorer.hxx>
# include <ShapeExtend_Explorer.hxx>
# include <TopTools_HSequenceOfShape.hxx>
# include <QKeyEvent>
# include <QMessageBox>
# include <Python.h>
# include <Inventor/system/inttypes.h>
@@ -147,6 +148,13 @@ void DlgExtrusion::changeEvent(QEvent *e)
QDialog::changeEvent(e);
}
void DlgExtrusion::keyPressEvent(QKeyEvent* ke)
{
// The extrusion dialog is embedded into a task panel
// which is a parent widget and will handle the event
ke->ignore();
}
void DlgExtrusion::on_rbDirModeCustom_toggled(bool on)
{
if(on) //this check prevents dual fire of dirmode changed - on radio buttons, one will come on, and other will come off, causing two events.

View File

@@ -65,6 +65,7 @@ protected:
void findShapes();
bool canExtrude(const TopoDS_Shape&) const;
void changeEvent(QEvent *e);
void keyPressEvent(QKeyEvent*);
private Q_SLOTS:
void on_rbDirModeCustom_toggled(bool on);

View File

@@ -315,6 +315,13 @@ void DlgRevolution::changeEvent(QEvent *e)
}
}
void DlgRevolution::keyPressEvent(QKeyEvent* ke)
{
// The revolution dialog is embedded into a task panel
// which is a parent widget and will handle the event
ke->ignore();
}
void DlgRevolution::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();

View File

@@ -56,6 +56,7 @@ public:
protected:
void changeEvent(QEvent *e);
void keyPressEvent(QKeyEvent*);
private Q_SLOTS:
void on_selectLine_clicked();