[PD] missing changed from commit d4be4a02
(key event handling for more dialogs)
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QKeyEvent>
|
||||
# include <QListWidget>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
@@ -86,21 +87,21 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q
|
||||
this, SLOT(onButtonRefRemove(bool)));
|
||||
|
||||
// Create context menu
|
||||
QAction* action = new QAction(tr("Remove"), this);
|
||||
action->setShortcut(QKeySequence::Delete);
|
||||
deleteAction = new QAction(tr("Remove"), this);
|
||||
deleteAction->setShortcut(QKeySequence::Delete);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
// display shortcut behind the context menu entry
|
||||
action->setShortcutVisibleInContextMenu(true);
|
||||
deleteAction->setShortcutVisibleInContextMenu(true);
|
||||
#endif
|
||||
ui->listWidgetReferences->addAction(action);
|
||||
ui->listWidgetReferences->addAction(deleteAction);
|
||||
// if there is only one item, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
}
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
connect(deleteAction, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)),
|
||||
@@ -119,13 +120,12 @@ void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
if (referenceSelected(msg)) {
|
||||
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
|
||||
if (selectionMode == refAdd) {
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
|
||||
// it might be the second one so we can enable the context menu
|
||||
if (ui->listWidgetReferences->count() > 1) {
|
||||
action->setEnabled(true);
|
||||
action->setStatusTip(QString());
|
||||
deleteAction->setEnabled(true);
|
||||
deleteAction->setStatusTip(QString());
|
||||
ui->buttonRefRemove->setEnabled(true);
|
||||
ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection"));
|
||||
}
|
||||
@@ -136,8 +136,8 @@ void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
Gui::Selection().clearSelection();
|
||||
// if there is only one item left, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
// we must also end the selection mode
|
||||
@@ -195,9 +195,8 @@ void TaskChamferParameters::onRefDeleted(void)
|
||||
|
||||
// if there is only one item left, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
}
|
||||
@@ -224,6 +223,31 @@ TaskChamferParameters::~TaskChamferParameters()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool TaskChamferParameters::event(QEvent *e)
|
||||
{
|
||||
// in case another instance takes key events, accept the overridden key event
|
||||
if (e && e->type() == QEvent::ShortcutOverride) {
|
||||
QKeyEvent * kevent = static_cast<QKeyEvent*>(e);
|
||||
if (kevent->modifiers() == Qt::NoModifier) {
|
||||
if (kevent->key() == Qt::Key_Delete) {
|
||||
kevent->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if we have a Del key, trigger the deleteAction
|
||||
else if (e && e->type() == QEvent::KeyPress) {
|
||||
QKeyEvent * kevent = static_cast<QKeyEvent*>(e);
|
||||
if (kevent->key() == Qt::Key_Delete) {
|
||||
if (deleteAction->isEnabled())
|
||||
deleteAction->trigger();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return TaskDressUpParameters::event(e);
|
||||
}
|
||||
|
||||
void TaskChamferParameters::changeEvent(QEvent *e)
|
||||
{
|
||||
TaskBox::changeEvent(e);
|
||||
|
||||
@@ -47,11 +47,13 @@ private Q_SLOTS:
|
||||
|
||||
protected:
|
||||
virtual void clearButtons(const selectionModes notThis);
|
||||
bool event(QEvent *e);
|
||||
void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
double getLength(void) const;
|
||||
|
||||
private:
|
||||
QAction* deleteAction;
|
||||
Ui_TaskChamferParameters* ui;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
# include <QAction>
|
||||
# include <QKeyEvent>
|
||||
# include <QListWidget>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
@@ -100,21 +101,21 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidg
|
||||
this, SLOT(onButtonLine(bool)));
|
||||
|
||||
// Create context menu
|
||||
QAction* action = new QAction(tr("Remove"), this);
|
||||
action->setShortcut(QKeySequence::Delete);
|
||||
deleteAction = new QAction(tr("Remove"), this);
|
||||
deleteAction->setShortcut(QKeySequence::Delete);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
// display shortcut behind the context menu entry
|
||||
action->setShortcutVisibleInContextMenu(true);
|
||||
deleteAction->setShortcutVisibleInContextMenu(true);
|
||||
#endif
|
||||
ui->listWidgetReferences->addAction(action);
|
||||
ui->listWidgetReferences->addAction(deleteAction);
|
||||
// if there is only one item, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
}
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
connect(deleteAction, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)),
|
||||
@@ -141,13 +142,12 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
if (referenceSelected(msg)) {
|
||||
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
|
||||
if (selectionMode == refAdd) {
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
|
||||
// it might be the second one so we can enable the context menu
|
||||
if (ui->listWidgetReferences->count() > 1) {
|
||||
action->setEnabled(true);
|
||||
action->setStatusTip(QString());
|
||||
deleteAction->setEnabled(true);
|
||||
deleteAction->setStatusTip(QString());
|
||||
ui->buttonRefRemove->setEnabled(true);
|
||||
ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection"));
|
||||
}
|
||||
@@ -158,8 +158,8 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
Gui::Selection().clearSelection();
|
||||
// if there is only one item left, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
// we must also end the selection mode
|
||||
@@ -269,9 +269,8 @@ void TaskDraftParameters::onRefDeleted(void)
|
||||
|
||||
// if there is only one item left, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
}
|
||||
@@ -330,6 +329,31 @@ TaskDraftParameters::~TaskDraftParameters()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool TaskDraftParameters::event(QEvent *e)
|
||||
{
|
||||
// in case another instance takes key events, accept the overridden key event
|
||||
if (e && e->type() == QEvent::ShortcutOverride) {
|
||||
QKeyEvent * kevent = static_cast<QKeyEvent*>(e);
|
||||
if (kevent->modifiers() == Qt::NoModifier) {
|
||||
if (kevent->key() == Qt::Key_Delete) {
|
||||
kevent->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if we have a Del key, trigger the deleteAction
|
||||
else if (e && e->type() == QEvent::KeyPress) {
|
||||
QKeyEvent * kevent = static_cast<QKeyEvent*>(e);
|
||||
if (kevent->key() == Qt::Key_Delete) {
|
||||
if (deleteAction->isEnabled())
|
||||
deleteAction->trigger();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return TaskDressUpParameters::event(e);
|
||||
}
|
||||
|
||||
void TaskDraftParameters::changeEvent(QEvent *e)
|
||||
{
|
||||
TaskBox::changeEvent(e);
|
||||
|
||||
@@ -55,10 +55,12 @@ private Q_SLOTS:
|
||||
|
||||
protected:
|
||||
virtual void clearButtons(const selectionModes notThis);
|
||||
bool event(QEvent *e);
|
||||
void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
private:
|
||||
QAction* deleteAction;
|
||||
Ui_TaskDraftParameters* ui;
|
||||
};
|
||||
|
||||
|
||||
@@ -226,6 +226,7 @@ TaskFilletParameters::~TaskFilletParameters()
|
||||
|
||||
bool TaskFilletParameters::event(QEvent *e)
|
||||
{
|
||||
// in case another instance takes key events, accept the overridden key event
|
||||
if (e && e->type() == QEvent::ShortcutOverride) {
|
||||
QKeyEvent * kevent = static_cast<QKeyEvent*>(e);
|
||||
if (kevent->modifiers() == Qt::NoModifier) {
|
||||
@@ -235,6 +236,7 @@ bool TaskFilletParameters::event(QEvent *e)
|
||||
}
|
||||
}
|
||||
}
|
||||
// if we have a Del key, trigger the deleteAction
|
||||
else if (e && e->type() == QEvent::KeyPress) {
|
||||
QKeyEvent * kevent = static_cast<QKeyEvent*>(e);
|
||||
if (kevent->key() == Qt::Key_Delete) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QKeyEvent>
|
||||
# include <QListWidget>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
@@ -102,21 +103,21 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie
|
||||
this, SLOT(onJoinTypeChanged(int)));
|
||||
|
||||
// Create context menu
|
||||
QAction* action = new QAction(tr("Remove"), this);
|
||||
action->setShortcut(QKeySequence::Delete);
|
||||
deleteAction = new QAction(tr("Remove"), this);
|
||||
deleteAction->setShortcut(QKeySequence::Delete);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
// display shortcut behind the context menu entry
|
||||
action->setShortcutVisibleInContextMenu(true);
|
||||
deleteAction->setShortcutVisibleInContextMenu(true);
|
||||
#endif
|
||||
ui->listWidgetReferences->addAction(action);
|
||||
ui->listWidgetReferences->addAction(deleteAction);
|
||||
// if there is only one item, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
}
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
connect(deleteAction, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)),
|
||||
@@ -141,13 +142,12 @@ void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& ms
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
if (referenceSelected(msg)) {
|
||||
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
|
||||
if (selectionMode == refAdd) {
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
|
||||
// it might be the second one so we can enable the context menu
|
||||
if (ui->listWidgetReferences->count() > 1) {
|
||||
action->setEnabled(true);
|
||||
action->setStatusTip(QString());
|
||||
deleteAction->setEnabled(true);
|
||||
deleteAction->setStatusTip(QString());
|
||||
ui->buttonRefRemove->setEnabled(true);
|
||||
ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection"));
|
||||
}
|
||||
@@ -158,8 +158,8 @@ void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& ms
|
||||
Gui::Selection().clearSelection();
|
||||
// if there is only one item left, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
// we must also end the selection mode
|
||||
@@ -217,9 +217,8 @@ void TaskThicknessParameters::onRefDeleted(void)
|
||||
|
||||
// if there is only one item left, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
|
||||
action->setEnabled(false);
|
||||
action->setStatusTip(tr("There must be at least one item"));
|
||||
deleteAction->setEnabled(false);
|
||||
deleteAction->setStatusTip(tr("There must be at least one item"));
|
||||
ui->buttonRefRemove->setEnabled(false);
|
||||
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
|
||||
}
|
||||
@@ -252,7 +251,6 @@ void TaskThicknessParameters::onModeChanged(int mode) {
|
||||
pcThickness->getDocument()->recomputeFeature(pcThickness);
|
||||
}
|
||||
|
||||
|
||||
double TaskThicknessParameters::getValue(void) const
|
||||
{
|
||||
return ui->Value->value().getValue();
|
||||
@@ -302,6 +300,31 @@ TaskThicknessParameters::~TaskThicknessParameters()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool TaskThicknessParameters::event(QEvent *e)
|
||||
{
|
||||
// in case another instance takes key events, accept the overridden key event
|
||||
if (e && e->type() == QEvent::ShortcutOverride) {
|
||||
QKeyEvent * kevent = static_cast<QKeyEvent*>(e);
|
||||
if (kevent->modifiers() == Qt::NoModifier) {
|
||||
if (kevent->key() == Qt::Key_Delete) {
|
||||
kevent->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if we have a Del key, trigger the deleteAction
|
||||
else if (e && e->type() == QEvent::KeyPress) {
|
||||
QKeyEvent * kevent = static_cast<QKeyEvent*>(e);
|
||||
if (kevent->key() == Qt::Key_Delete) {
|
||||
if (deleteAction->isEnabled())
|
||||
deleteAction->trigger();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return TaskDressUpParameters::event(e);
|
||||
}
|
||||
|
||||
void TaskThicknessParameters::changeEvent(QEvent *e)
|
||||
{
|
||||
TaskBox::changeEvent(e);
|
||||
|
||||
@@ -55,10 +55,12 @@ private Q_SLOTS:
|
||||
|
||||
protected:
|
||||
virtual void clearButtons(const selectionModes notThis);
|
||||
bool event(QEvent *e);
|
||||
void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
private:
|
||||
QAction* deleteAction;
|
||||
Ui_TaskThicknessParameters* ui;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user