13 class MainWindow : public QScrollArea {
21 MainWindow(QString url, int quality) : QScrollArea(0) {
22 swipe_start = QPoint(0,0);
23 setAttribute(Qt::WA_Maemo5StackedWindow);
25 vnc_view = new VncView(0, url, RemoteView::Quality(quality));
29 QMenuBar *menu = new QMenuBar(this);
30 QAction *scaling = new QAction("Rescale Remote Screen", this);
31 scaling->setCheckable(true);
32 scaling->setChecked(true);
33 menu->addAction(scaling);
34 QAction *about_action = new QAction("About", this);
35 menu->addAction(about_action);
37 //menu->setAttribute(Qt::WA_Maemo5StackedWindow);
40 connect(scaling, SIGNAL(toggled(bool)),
41 vnc_view, SLOT(enableScaling(bool)));
42 connect(about_action, SIGNAL(triggered()),
46 setAttribute(Qt::WA_Maemo5AutoOrientation, true);
47 //setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
52 void grabZoomKeys(bool grab)
54 unsigned long val = (grab)?1:0;
55 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
57 qWarning("Couldn't get zoom key atom");
60 XChangeProperty(QX11Info::display(), winId(), atom, XA_INTEGER,
61 32, PropModeReplace, reinterpret_cast<unsigned char *>(&val), 1);
63 void closeEvent(QCloseEvent*) {
66 vnc_view->startQuitting();
70 QMessageBox::about(this, tr("About Presence VNC"),
71 tr("<center><h1>Presence VNC 0.1 alpha</h1>\
72 A touch screen friendly VNC client\
73 <small><p>©2010 Christian Pulvermacher <pulvermacher@gmx.de></p>\
74 <p>Based on KRDC, © 2007-2008 Urs Wolfer</small></center>\
75 <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>"));
79 /* swipe not used, and doesn't work without scaling anyway :/
80 virtual bool event(QEvent *event) {
81 if(event->type() == QEvent::MouseMove) {
82 QMouseEvent *ev = dynamic_cast<QMouseEvent* >(event);
83 if(!swipe_start.isNull()) {
84 QPoint diff = swipe_start - ev->pos();
85 const int swipe_dist = 60;
86 if(diff.x() > swipe_dist and diff.y() < swipe_dist and diff.y() > -swipe_dist) { //
88 swipe_start = QPoint(0,0);
90 } else if((width() - ev->x()) < 10) {
91 swipe_start = ev->pos();
93 std::cout << "mousex: " << width() - ev->x() << "\n";
94 //TODO: make scrolling over border result in wheel events? i get weird (out of range) mouse events when that happens
96 } else if(event->type() == QEvent::MouseButtonRelease) {
97 swipe_start = QPoint(0,0);
100 // std::cout << "event " << event->type() << "\n";
101 return QScrollArea::event(event);