summaryrefslogtreecommitdiffstats
path: root/src/fbgui/agui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fbgui/agui.cpp')
-rw-r--r--src/fbgui/agui.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/fbgui/agui.cpp b/src/fbgui/agui.cpp
new file mode 100644
index 0000000..3f2fd68
--- /dev/null
+++ b/src/fbgui/agui.cpp
@@ -0,0 +1,86 @@
+/*
+ * agui.cpp
+ *
+ * Created on: Jan 31, 2012
+ * Author: joe
+ */
+
+#include "agui.h"
+#include "console.h"
+
+#include <log4cxx/logger.h>
+#include "qlog4cxx.h"
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+LoggerPtr aguiCoreLogger(Logger::getLogger("agui.core"));
+
+QString logFilePath("");
+int debugMode = -1;
+
+agui::agui() {
+ setupLayout();
+ createActions();
+
+ setAttribute(Qt::WA_QuitOnClose, true);
+ setWindowFlags(Qt::FramelessWindowHint);
+}
+
+agui::~agui() {
+}
+
+/**
+ * @brief This method sets the used Layout.
+ *
+ * This method sets the used Layout. Possible layout are:
+ * - browser mode: only the browser is visible
+ * - debug mode: the screen is divided into the browser and a debug
+ * out console
+ */
+void agui::setupLayout() {
+ // setup layout of the gui: debug split or browser
+ _webView = new QWebView(this);
+ //_webView->setContextMenuPolicy(Qt::NoContextMenu); // if this does not work try Qt::CustomContextMenu
+ _webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
+ if (debugMode > -1) {
+ // split main window in browser & debug console
+ Console* debugConsole = new Console(this);
+ QSplitter* _splitter = new QSplitter(Qt::Vertical, this);
+ _splitter->addWidget(_webView);
+ _splitter->addWidget(debugConsole);
+ setCentralWidget(_splitter);
+ } else {
+ setCentralWidget(_webView);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------
+/**
+ * This method enables a shortcut for closing the program.
+ * The shortcut itself is not configurable: CTRL + X
+ */
+void agui::createActions() {
+ _quit = new QAction(tr("&quit"), this);
+ _quit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X));
+ this->addAction(_quit);
+ connect(_quit, SIGNAL(triggered()), this, SLOT(close()));
+}
+//-------------------------------------------------------------------------------------------
+void agui::magicKey(const char* key){
+ QFile file("/proc/sysrq-trigger");
+ if (file.open(QIODevice::WriteOnly)) {
+ file.write(key);
+ file.close();
+ } else {
+ LOG4CXX_DEBUG(aguiCoreLogger, "Could not open /proc/sysrq-trigger");
+ }
+}
+
+void agui::rebootSystem() {
+ magicKey("b");
+}
+
+void agui::shutdownSystem() {
+ magicKey("o");
+}