fix includes
[presencevnc] / src / mainwindow.h
index 1b5cdbf..c5296a5 100644 (file)
+/*
+    Presence VNC
+    Copyright (C) 2010 Christian Pulvermacher
 
-#include <QtGui>
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
 
-#include <QX11Info>
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
 
-#include "vncview.h"
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
+#include "remoteview.h"
 
-#include <iostream>
+#include <QtGui>
 
-class MainWindow : public QScrollArea {
-       Q_OBJECT
-private:
-       VncView *vnc_view;
-       QWidget *menu;
-       QPoint swipe_start;
+class KeyMenu;
+class ScrollArea;
+class VncView;
 
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
 public:
-       MainWindow(QString url, int quality) : QScrollArea(0) {
-               swipe_start = QPoint(0,0);
-               setAttribute(Qt::WA_Maemo5StackedWindow);
-
-               vnc_view = new VncView(0, url, RemoteView::Quality(quality));
-               setWidget(vnc_view);
-
-               //set up menu
-               QMenuBar *menu = new QMenuBar(this);
-               QAction *scaling = new QAction("Rescale Remote Screen", this);
-               scaling->setCheckable(true);
-               scaling->setChecked(true);
-               menu->addAction(scaling);
-               QAction *about_action = new QAction("About", this);
-               menu->addAction(about_action);
-
-               //menu->setAttribute(Qt::WA_Maemo5StackedWindow);
-               //menu->hide();
-
-               connect(scaling, SIGNAL(toggled(bool)),
-                       vnc_view, SLOT(enableScaling(bool)));
-               connect(about_action, SIGNAL(triggered()),
-                       this, SLOT(about()));
-
-               grabZoomKeys(true);
-               setAttribute(Qt::WA_Maemo5AutoOrientation, true);
-               //setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
-
-               vnc_view->start();
-       }
-
-       void grabZoomKeys(bool grab)
-       {
-               unsigned long val = (grab)?1:0;
-               Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
-               if(!atom) {
-                       qWarning("Couldn't get zoom key atom");
-                       return;
-               }
-               XChangeProperty(QX11Info::display(), winId(), atom, XA_INTEGER,
-                       32, PropModeReplace, reinterpret_cast<unsigned char *>(&val), 1);
-       }
-       void closeEvent(QCloseEvent*) {
-               hide();
-               grabZoomKeys(false);
-               vnc_view->startQuitting();
-       }
+    MainWindow(QString url, int quality, int listen_port, bool view_only);
 public slots:
-       void about() {
-               QMessageBox::about(this, tr("About Presence VNC"),
-                       tr("<center><h1>Presence VNC 0.1 alpha</h1>\
-A touch screen friendly VNC client\
-<small><p>&copy;2010 Christian Pulvermacher &lt;pulvermacher@gmx.de&gt</p>\
-<p>Based on KRDC, &copy; 2007-2008 Urs Wolfer</small></center>\
-<p>This program is free software; License: <a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GNU GPL 2</a> or later.</p>"));
-       }
-
+    void about();
+    void showConnectDialog();
+    void connectToHost(QString url, int quality, int listen_port, bool view_only);
+    void disconnectFromHost();
+    void updateScreenSpace();
+    void updateScreenSpaceDelayed();
+    void sendTab();
+    void sendEsc();
+    void sendPgUp();
+    void sendPgDn();
+    void sendReturn();
+    void setZoomLevel(int level);
+    void showInputPanel();
+    void showKeyMenu();
+    void showPreferences();
+    void statusChanged(RemoteView::RemoteStatus status);
+    void toggleFullscreen();
+    void zoomSliderReleased();
+    void displayStateChanged(QString state);
 protected:
-/* swipe not used, and doesn't work without scaling anyway :/
-       virtual bool event(QEvent *event) {
-               if(event->type() == QEvent::MouseMove) {
-                       QMouseEvent *ev = dynamic_cast<QMouseEvent* >(event);
-                       if(!swipe_start.isNull()) {
-                               QPoint diff = swipe_start - ev->pos();
-                               const int swipe_dist = 60;
-                               if(diff.x() > swipe_dist and diff.y() < swipe_dist and diff.y() > -swipe_dist) { //
-                                       menu->show();
-                                       swipe_start = QPoint(0,0);
-                               }
-                       } else if((width() - ev->x()) < 10) {
-                               swipe_start = ev->pos();
-                       }
-                       std::cout << "mousex: " << width() - ev->x() << "\n";
-                       //TODO: make scrolling over border result in wheel events? i get weird (out of range) mouse events when that happens
-                       return true;
-               } else if(event->type() == QEvent::MouseButtonRelease) {
-                       swipe_start = QPoint(0,0);
-                       return true;
-               } else {
-//                     std::cout << "event " << event->type() << "\n";
-                       return QScrollArea::event(event);
-               }
-       }
-       */
+    void closeEvent(QCloseEvent*);
+    void resizeEvent(QResizeEvent *event);
+private:
+    void grabZoomKeys(bool grab);
+    void reloadSettings();
+
+    VncView *vnc_view;
+    ScrollArea *scroll_area;
+
+    QToolBar *toolbar;
+    QSlider *zoom_slider;
+    QAction *scaling, *show_toolbar, *disconnect_action;
+    QActionGroup *input_toolbuttons;
+    KeyMenu *key_menu;
+    QAction *key_menu_button;
+    bool zoom_to_cursor;
 };
+#endif