ui: renamed undo&redo to back&forward, control back&forward via mouse and backspace
* the key codes for mouse back and forward buttons can be defined in the ApplicationSettings * fixed only left mouse button allowed for graph interactions
This commit is contained in:
@@ -49,4 +49,9 @@
|
||||
<plugin_port><!-- INTEGER: port the plugin listens to, standard is 6666 --></plugin_port>
|
||||
<coati_port><!-- INTEGER: port coati is listening to, standard is 6667 --></coati_port>
|
||||
</network>
|
||||
|
||||
<controls>
|
||||
<mouse_back_button><!-- INTEGER: mouse button code of back button, default is 8 --></mouse_back_button>
|
||||
<mouse_forward_button><!-- INTEGER: mouse button code of forward button, default is 16 --></mouse_forward_button>
|
||||
</controls>
|
||||
</config>
|
||||
|
||||
@@ -149,4 +149,14 @@ int ApplicationSettings::getCoatiPort() const
|
||||
void ApplicationSettings::setCoatiPort(const int coatiPort)
|
||||
{
|
||||
setValue<int>("network/coati_port", coatiPort);
|
||||
}
|
||||
}
|
||||
|
||||
int ApplicationSettings::getControlsMouseBackButton() const
|
||||
{
|
||||
return getValue<int>("controls/mouse_back_button", 0x8);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getControlsMouseForwardButton() const
|
||||
{
|
||||
return getValue<int>("controls/mouse_forward_button", 0x16);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,10 @@ public:
|
||||
int getCoatiPort() const;
|
||||
void setCoatiPort(const int coatiPort);
|
||||
|
||||
// controls
|
||||
int getControlsMouseBackButton() const;
|
||||
int getControlsMouseForwardButton() const;
|
||||
|
||||
private:
|
||||
ApplicationSettings();
|
||||
ApplicationSettings(const ApplicationSettings&);
|
||||
|
||||
@@ -16,13 +16,13 @@ QtUndoRedo::QtUndoRedo()
|
||||
|
||||
m_undoButton = new QPushButton(this);
|
||||
m_undoButton->setObjectName("undo_button");
|
||||
m_undoButton->setToolTip("undo");
|
||||
m_undoButton->setToolTip("back");
|
||||
m_undoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_undoButton->setEnabled(false);
|
||||
|
||||
m_redoButton = new QPushButton(this);
|
||||
m_redoButton->setObjectName("redo_button");
|
||||
m_redoButton->setToolTip("redo");
|
||||
m_redoButton->setToolTip("forward");
|
||||
m_redoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_redoButton->setEnabled(false);
|
||||
|
||||
|
||||
@@ -265,6 +265,11 @@ void QtGraphNode::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
event->ignore();
|
||||
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::shared_ptr<QtGraphNodeComponent> component : m_components)
|
||||
{
|
||||
component->nodeMousePressEvent(event);
|
||||
@@ -303,6 +308,11 @@ void QtGraphNode::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
event->ignore();
|
||||
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::shared_ptr<QtGraphNodeComponent> component : m_components)
|
||||
{
|
||||
component->nodeMouseReleaseEvent(event);
|
||||
|
||||
@@ -45,6 +45,39 @@ void QtViewToggle::toggledByUI()
|
||||
dynamic_cast<QtMainWindow*>(parent())->toggleView(m_view, false);
|
||||
}
|
||||
|
||||
|
||||
MouseReleaseFilter::MouseReleaseFilter(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_backButton = ApplicationSettings::getInstance()->getControlsMouseBackButton();
|
||||
m_forwardButton = ApplicationSettings::getInstance()->getControlsMouseForwardButton();
|
||||
|
||||
std::cout << m_backButton << std::endl;
|
||||
std::cout << m_forwardButton << std::endl;
|
||||
}
|
||||
|
||||
bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonRelease)
|
||||
{
|
||||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
||||
|
||||
if (mouseEvent->button() == m_backButton)
|
||||
{
|
||||
MessageUndo().dispatch();
|
||||
return true;
|
||||
}
|
||||
else if (mouseEvent->button() == m_forwardButton)
|
||||
{
|
||||
MessageRedo().dispatch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
|
||||
QtMainWindow::QtMainWindow()
|
||||
{
|
||||
setObjectName("QtMainWindow");
|
||||
@@ -56,6 +89,9 @@ QtMainWindow::QtMainWindow()
|
||||
|
||||
QApplication::setOverrideCursor(Qt::ArrowCursor);
|
||||
|
||||
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
|
||||
app->installEventFilter(new MouseReleaseFilter(this));
|
||||
|
||||
m_recentProjectAction = new QAction*[ApplicationSettings::MaximalAmountOfRecentProjects];
|
||||
|
||||
setupProjectMenu();
|
||||
@@ -179,6 +215,14 @@ bool QtMainWindow::event(QEvent* event)
|
||||
return QMainWindow::event(event);
|
||||
}
|
||||
|
||||
void QtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Backspace)
|
||||
{
|
||||
MessageUndo().dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::pushWindow(QWidget* window)
|
||||
{
|
||||
if (m_windowStack.size())
|
||||
@@ -480,8 +524,8 @@ void QtMainWindow::setupEditMenu()
|
||||
QMenu *menu = new QMenu(tr("&Edit"), this);
|
||||
menuBar()->addMenu(menu);
|
||||
|
||||
menu->addAction(tr("Undo"), this, SLOT(undo()), QKeySequence::Undo);
|
||||
menu->addAction(tr("Redo"), this, SLOT(redo()), QKeySequence::Redo);
|
||||
menu->addAction(tr("Back"), this, SLOT(undo()), QKeySequence::Undo);
|
||||
menu->addAction(tr("Forward"), this, SLOT(redo()), QKeySequence::Redo);
|
||||
|
||||
menu->addSeparator();
|
||||
if(!isTrial())
|
||||
|
||||
@@ -33,7 +33,26 @@ private:
|
||||
View* m_view;
|
||||
};
|
||||
|
||||
class QtMainWindow: public QMainWindow
|
||||
|
||||
class MouseReleaseFilter
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MouseReleaseFilter(QObject* parent);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
private:
|
||||
size_t m_backButton;
|
||||
size_t m_forwardButton;
|
||||
};
|
||||
|
||||
|
||||
class QtMainWindow
|
||||
: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -54,6 +73,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
public slots:
|
||||
void pushWindow(QWidget* window);
|
||||
@@ -88,6 +108,7 @@ public slots:
|
||||
void toggleView(View* view, bool fromMenu);
|
||||
|
||||
void handleEscapeShortcut();
|
||||
|
||||
void updateRecentProjectMenu();
|
||||
|
||||
static void setWindowSettingsPath(const std::string& windowSettingsPath);
|
||||
|
||||
Reference in New Issue
Block a user