summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/main-window.cpp32
-rw-r--r--gui/main-window.hpp3
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>