Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
Fix Ctrl/Alt key handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
3vi1 committed Aug 12, 2017
1 parent 4a2255f commit 98c50a4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
3 changes: 3 additions & 0 deletions docs/RELEASES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
didn't show itself when using Qt with Unity, but it does with
KDE (and presumably Windows).

Change handling of ctrl/alt keys so that their up/down states
can no longer get out of sync when swapping between windows.

0.9.4.1 - Fixed bug where #defines were not working with newest qt/gcc.
(thanks Hibasnev!)

Expand Down
1 change: 0 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,6 @@ void MainWindow::findLocation(const QString& location)
QString fullName = regionMap->getSystemByAbbreviation(location.toUpper());
ui->mapView->findLocation(fullName);
positionTo(regionMap->getSystemByAbbreviation(location));
ui->mapView->resetCtrl();
}

void MainWindow::logDirChanged(const QString& dir)
Expand Down
27 changes: 5 additions & 22 deletions src/svgmapview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "svgmapview.h"
#include <QApplication> // for queryKeyboardModifiers
#include <QBuffer>
#include <QDebug>
#include <QFile>
Expand Down Expand Up @@ -147,29 +148,11 @@ void SvgMapView::setLoadText(const QString text)

void SvgMapView::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key::Key_Control)
{
controlKeyDown = true;
}
else if(event->key() == Qt::Key::Key_Alt)
{
altKeyDown = true;
}

QGraphicsView::keyPressEvent(event);
}

void SvgMapView::keyReleaseEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key::Key_Control)
{
controlKeyDown = false;
}
else if(event->key() == Qt::Key::Key_Alt)
{
altKeyDown = false;
}

QGraphicsView::keyReleaseEvent(event);
}

Expand All @@ -180,8 +163,6 @@ void SvgMapView::mouseMoveEvent(QMouseEvent *event)

void SvgMapView::mousePressEvent(QMouseEvent *event)
{


return QGraphicsView::mousePressEvent(event);
}

Expand All @@ -193,11 +174,13 @@ void SvgMapView::mouseReleaseEvent(QMouseEvent *event)

void SvgMapView::wheelEvent(QWheelEvent *event)
{
if(altKeyDown == true && controlKeyDown == true)
Qt::KeyboardModifiers mods = QApplication::queryKeyboardModifiers();

if(mods.testFlag(Qt::AltModifier) && mods.testFlag(Qt::ControlModifier))
{
emit sendOpacity(event->delta());
}
else if(controlKeyDown)
else if(mods.testFlag(Qt::ControlModifier))
{
setTransformationAnchor(AnchorViewCenter);
qreal angle = event->delta() * .025f;
Expand Down
4 changes: 0 additions & 4 deletions src/svgmapview.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ class SvgMapView : public QGraphicsView
void addLine(QGraphicsLineItem *line);
void updateLinesColor(QColor color);

void resetCtrl(){controlKeyDown = false;}

void openWormhole(const QString &systemName);
void closeWormhole(const QString &systemName);

Expand Down Expand Up @@ -144,8 +142,6 @@ public slots:
QString m_pilotGraphic;
QColor m_linesColor;

bool altKeyDown = false;
bool controlKeyDown = false;
bool drawBridges = false;
float zoom = 1;

Expand Down

0 comments on commit 98c50a4

Please sign in to comment.