diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-27 13:49:57 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-27 16:43:02 +0200 |
commit | e4fa5befb61e8e611da2a8dbac2dd0153230f910 (patch) | |
tree | 23dc524c034c26fb1322aa481925baabfba4bc55 /gui | |
parent | f0230b9718f928717c977c7a7407dcc893056673 (diff) |
gui/main-window: annoy when running as root
Diffstat (limited to 'gui')
-rw-r--r-- | gui/main-window.cpp | 32 | ||||
-rw-r--r-- | gui/main-window.hpp | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/gui/main-window.cpp b/gui/main-window.cpp index 0382edf2..c62e0ae3 100644 --- a/gui/main-window.cpp +++ b/gui/main-window.cpp @@ -31,6 +31,34 @@ extern "C" const char* opentrack_version; +#if !defined _WIN32 && !defined __APPLE__ +# include <unistd.h> +void MainWindow::annoy_if_root() +{ + if (geteuid() == 0) + { + for (unsigned k = 0; k < 2; k++) + { + portable::sleep(1 * 1000); + QMessageBox::critical(this, + tr("Running as root is bad"), + tr("Do not run as root. Set correct device node permissions."), + QMessageBox::Ok); + portable::sleep(1 * 1000); + QMessageBox::critical(this, + tr("Running as root is bad, seriously"), + tr("Do not run as root. I'll keep whining at every startup."), + QMessageBox::Ok); + portable::sleep(3 * 1000); + QMessageBox::critical(this, + tr("Running as root is really seriously bad"), + tr("Do not run as root. Be annoyed, comprehensively."), + QMessageBox::Ok); + } + } +} +#endif + MainWindow::MainWindow() : State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH), pose_update_timer(this), @@ -46,6 +74,10 @@ MainWindow::MainWindow() : { ui.setupUi(this); +#if !defined _WIN32 && !defined __APPLE__ + annoy_if_root(); +#endif + { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | windowFlags()); diff --git a/gui/main-window.hpp b/gui/main-window.hpp index f992b218..8b0144b8 100644 --- a/gui/main-window.hpp +++ b/gui/main-window.hpp @@ -97,6 +97,9 @@ class MainWindow : public QMainWindow, private State void closeEvent(QCloseEvent*) override; bool event(QEvent *event) override; bool maybe_hide_to_tray(QEvent* e); +#if !defined _WIN32 && !defined __APPLE__ + void annoy_if_root(); +#endif // only use in impl file since no definition in header! template<typename t> |