Skip to content

Commit b5019c8

Browse files
authored
Fixed shortcut window not closing when main is closed.
1 parent fed9332 commit b5019c8

7 files changed

Lines changed: 21 additions & 11 deletions

File tree

global.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#include "global.h"
2+
#include <math.h>
23
#include "gpmanager.h"
34

45
QSettings settings("TuxSH", "InputRedirectionClient-Qt");
56

67
Worker worker;
78
Settings btnSettings;
89
double tsRatio;
10+
911
std::vector<ShortCut> listShortcuts;
1012

1113
QGamepadManager::GamepadButtons buttons = 0;

global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class Worker : public QObject {
102102
void setLeftAxis(double x, double y);
103103
void setRightAxis(double x, double y);
104104
void setPreviousLAxis(double x, double y);
105+
void closeThread() { emit finished(); }
105106

106107
explicit Worker(QObject *parent = 0) : QObject(parent)
107108
{

main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ int main(int argc, char *argv[])
2626
QObject::connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater()));
2727
QObject::connect(&timer, SIGNAL(timeout()), &worker, SLOT(sendFrame()));
2828
thread->start();
29-
30-
return a.exec();
29+
a.exec();
30+
worker.closeThread();
31+
return 0;
3132
}

mainwidget.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ private slots:
5454
setContextMenuPolicy(Qt::CustomContextMenu);
5555

5656
// Disable/hide the configurator button if running windows since it's not supported
57-
if (QSysInfo::productType() == "windows")
57+
if (QSysInfo::productType() == "windows" ||
58+
QSysInfo::productType() == "osx")
5859
{
5960
configGamepadButton->setEnabled(false);
6061
configGamepadButton->setVisible(false);
@@ -177,15 +178,13 @@ private slots:
177178
touchScreen->update();
178179
});
179180

180-
181181
touchScreen = new TouchScreen(nullptr);
182182
settingsConfig = new ConfigWindow(nullptr, touchScreen);
183183
this->setWindowTitle(tr("InputRedirectionClient-Qt"));
184184

185185
addrLineEdit->setText(settings.value("ipAddress", "").toString());
186186
}
187187

188-
189188
void show(void)
190189
{
191190
QWidget::show();
@@ -212,6 +211,9 @@ private slots:
212211
}
213212
touchScreen->close();
214213
settingsConfig->close();
214+
215+
touchScreen->setTouchScreenPressed(false);
216+
delete touchScreen;
215217
ev->accept();
216218
}
217219

@@ -224,7 +226,7 @@ private slots:
224226
//When main window is opened, load shortcut settings
225227
void showEvent(QShowEvent* event)
226228
{
227-
int id = qRegisterMetaType<ShortCut>("ShortCut");
229+
qRegisterMetaType<ShortCut>("ShortCut");
228230
qRegisterMetaTypeStreamOperators<ShortCut>("ShortCut");
229231

230232
QString valName = "tsShortcut0";
@@ -244,7 +246,7 @@ private slots:
244246
}
245247
else
246248
{
247-
settings.remove("tsShortcut"+i);
249+
settings.remove(tr("tsShortcut%1").arg(i));
248250
}
249251

250252
}
@@ -257,8 +259,7 @@ private slots:
257259

258260
buttons = 0;
259261
interfaceButtons = 0;
260-
touchScreen->setTouchScreenPressed(false);
261-
delete touchScreen;
262+
262263
delete settingsConfig;
263264
}
264265
};

touchscreen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,4 @@ void TouchScreen::clearImage(void)
220220
settings.setValue("tsBackgroundImage", "");
221221
updatePixmap();
222222
}
223+

touchscreen.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public slots:
3535
void updatePixmap(void);
3636
void clearImage(void);
3737
void paintEvent(QPaintEvent* e);
38+
39+
~TouchScreen(void)
40+
{
41+
qDebug() << "DECON";
42+
tsShortcutGui.close();
43+
}
3844
};
3945

4046
#endif // TOUCHSCREEN_H

tsshortcut.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ class TsShortcut : public QWidget
1212
{
1313
private:
1414
QString wTitle;
15-
QPushButton *acceptButton;
1615
QVBoxLayout *layout;
1716
QFormLayout *formLayout;
1817
QListWidget *lstWidget;
19-
QGamepadManager::GamepadButton btnToMap;
2018
QLabel *lblDirections;
2119
QPushButton *btnColorDialog, *btnCreateShort,
2220
*btnDelShort, *btnHelp, *btnPressNow;

0 commit comments

Comments
 (0)