diff options
author | sr | 2013-02-04 19:50:31 +0100 |
---|---|---|
committer | sr | 2013-02-04 19:50:31 +0100 |
commit | 1a5709501f94014d41987b956338bb6424b9f90c (patch) | |
tree | d3b93fe8dc406bca56aff147ef5cc4cbf9ed6be0 /src/client/util | |
parent | Test (diff) | |
download | pvs2-1a5709501f94014d41987b956338bb6424b9f90c.tar.gz pvs2-1a5709501f94014d41987b956338bb6424b9f90c.tar.xz pvs2-1a5709501f94014d41987b956338bb6424b9f90c.zip |
Initial commit
Diffstat (limited to 'src/client/util')
-rwxr-xr-x | src/client/util/platform/blankscreen.h | 25 | ||||
-rwxr-xr-x | src/client/util/platform/blankscreen_Win32.cpp | 41 | ||||
-rwxr-xr-x | src/client/util/platform/blankscreen_X11.cpp | 75 | ||||
-rw-r--r-- | src/client/util/util.cpp | 25 | ||||
-rw-r--r-- | src/client/util/util.h | 23 |
5 files changed, 189 insertions, 0 deletions
diff --git a/src/client/util/platform/blankscreen.h b/src/client/util/platform/blankscreen.h new file mode 100755 index 0000000..8ed4c04 --- /dev/null +++ b/src/client/util/platform/blankscreen.h @@ -0,0 +1,25 @@ +#ifndef _BLANKSCREEN_H_ +#define _BLANKSCREEN_H_ + +#include <QString> +#include <QDialog> + +class BlankScreen_Sysdep; + +class BlankScreen : public QDialog +{ + Q_OBJECT +public: + BlankScreen(); + virtual ~BlankScreen(); + void draw(bool force = false); + bool lock(const QString& message); + bool unlock(); + +private: + bool _locked; + QString _message; + BlankScreen_Sysdep* _sysdep; +}; + +#endif diff --git a/src/client/util/platform/blankscreen_Win32.cpp b/src/client/util/platform/blankscreen_Win32.cpp new file mode 100755 index 0000000..2bba1cf --- /dev/null +++ b/src/client/util/platform/blankscreen_Win32.cpp @@ -0,0 +1,41 @@ +
+#include "blankscreen.h"
+#include <qwidget.h>
+
+struct BlankScreen_Sysdep {
+
+ bool locked;
+ QWidget* blankwin;
+
+ QString lockMsg;
+ int blackColor, whiteColor;
+ int offX, offY;
+};
+
+BlankScreen::BlankScreen()
+{
+ _sysdep = new BlankScreen_Sysdep;
+ _sysdep->blankwin = new QWidget(0, Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
+ _sysdep->blankwin->setWindowState(Qt::WindowFullScreen);
+ _sysdep->blankwin->show();
+}
+
+BlankScreen::~BlankScreen()
+{
+ delete _sysdep;
+}
+
+void BlankScreen::draw(bool force)
+{
+
+}
+
+bool BlankScreen::lock(const QString& message)
+{
+ return true;
+}
+
+bool BlankScreen::unlock()
+{
+ return true;
+}
diff --git a/src/client/util/platform/blankscreen_X11.cpp b/src/client/util/platform/blankscreen_X11.cpp new file mode 100755 index 0000000..69b6d8c --- /dev/null +++ b/src/client/util/platform/blankscreen_X11.cpp @@ -0,0 +1,75 @@ +#include "blankscreen.h" + +#include <QApplication> +#include <QDesktopWidget> + +#include <X11/Xlib.h> +#include <X11/cursorfont.h> + +#include <cassert> +#include <cstring> + +struct BlankScreen_Sysdep +{ + Display *dpy; +}; + +BlankScreen::BlankScreen() : QDialog(NULL) +{ + _sysdep = new BlankScreen_Sysdep; + _sysdep->dpy = XOpenDisplay(NULL); + if (_sysdep->dpy == NULL) + return; + assert(_sysdep->dpy); + + setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint); + setStyleSheet("background-color:#000"); + + _locked = false; +} + +BlankScreen::~BlankScreen() +{ + unlock(); + delete _sysdep; +} + +bool BlankScreen::lock(const QString& message) +{ + if (_locked) + return true; + if (_sysdep->dpy == NULL) + return false; + + _message = message; + + this->setGeometry(QApplication::desktop()->geometry()); + this->showFullScreen(); + this->activateWindow(); + this->raise(); + + // grabbing of keyboard and mouse + XGrabKeyboard(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy) , false, GrabModeAsync, GrabModeAsync, CurrentTime); + XGrabPointer(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy) , false, 0, GrabModeAsync, GrabModeAsync, None, 0, CurrentTime); + + _locked = true; + return true; +} + +bool BlankScreen::unlock() +{ + this->hide(); + if (!_locked) + return true; + if (_sysdep->dpy == NULL) + return false; + + // ungrabbing of keyboard and mouse + XUngrabPointer(_sysdep->dpy, CurrentTime); + XUngrabKeyboard(_sysdep->dpy, CurrentTime); + + XFlush(_sysdep->dpy); + + _locked = false; + return true; +} diff --git a/src/client/util/util.cpp b/src/client/util/util.cpp new file mode 100644 index 0000000..9dcbebb --- /dev/null +++ b/src/client/util/util.cpp @@ -0,0 +1,25 @@ +/* + * Util.cpp + * + * Created on: 18.01.2013 + * Author: sr + */ + +#include "util.h" +#include <QSettings> + +namespace Util +{ +//# +//# +QDir settingsDir() +{ + USER_SETTINGS(settings); + QFileInfo fi(settings.fileName()); + QDir path(fi.path()); + return path; +} +//# +//# +} + diff --git a/src/client/util/util.h b/src/client/util/util.h new file mode 100644 index 0000000..82248c0 --- /dev/null +++ b/src/client/util/util.h @@ -0,0 +1,23 @@ +#ifndef UTIL_H_ +#define UTIL_H_ + +// Helper for getting a settings object in various places, so if you ever change the organization, location, +// file format or anything, you won't have to edit in 100 places. +// Use like this: +// USER_SETTINGS(settings) +// settings.value("somekey") +#define USER_SETTINGS(name) QSettings name (QSettings::IniFormat, QSettings::UserScope, "openslx", "pvs2client") +#define SYSTEM_SETTINGS(name) QSettings name (QSettings::IniFormat, QSettings::SystemScope, "openslx", "pvs2client") + +#include <QDir> + +namespace Util +{ +//# +//# +QDir settingsDir(); +//# +//# +} + +#endif /* UTIL_H_ */ |