#include "preferences.h"
#include "vncview.h"
-#include <QSlider>
-
#ifdef Q_WS_MAEMO_5
#include <QtMaemo5>
#include <QX11Info>
toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/control_keyboard.png"), "", this, SLOT(showInputPanel()));
#endif
- //move fullscreen button to the right
+ //move remaining buttons to the right
QWidget *spacer = new QWidget();
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
toolbar->addWidget(spacer);
//set up zoombar
zoombar = new QToolBar(0);
- QSlider *zoom_slider = new QSlider(Qt::Horizontal, 0);
+ zoom_slider = new QSlider(Qt::Horizontal, 0);
zoom_slider->setRange(0, 100);
connect(zoom_slider, SIGNAL(valueChanged(int)),
this, SLOT(setZoomLevel(int)));
+ zoom_slider->setValue(settings.value("zoomlevel", 95).toInt());
zoombar->addWidget(zoom_slider);
addToolBar(zoombar);
//set up menu
QAction *connect_action = new QAction(tr("Connect"), this);
disconnect_action = new QAction(tr("Disconnect"), this);
- scaling = new QAction(tr("Fit to Screen"), this);
- scaling->setCheckable(true);
- scaling->setChecked(settings.value("rescale", true).toBool());
show_toolbar = new QAction(tr("Show Toolbar"), this);
show_toolbar->setCheckable(true);
show_toolbar->setChecked(settings.value("show_toolbar", true).toBool());
#ifdef Q_WS_MAEMO_5
menuBar()->addAction(connect_action);
menuBar()->addAction(disconnect_action);
- menuBar()->addAction(scaling);
menuBar()->addAction(show_toolbar);
menuBar()->addAction(pref_action);
menuBar()->addAction(about_action);
session_menu->addAction(tr("&Quit"), this, SLOT(close()));
QMenu* view_menu = menuBar()->addMenu(tr("&View"));
- view_menu->addAction(scaling);
view_menu->addAction(show_toolbar);
QMenu* help_menu = menuBar()->addMenu(tr("&Help"));
showConnectDialog();
} else {
vnc_view = new VncView(this, url, RemoteView::Quality(quality));
- connect(scaling, SIGNAL(toggled(bool)),
- vnc_view, SLOT(enableScaling(bool)));
connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
this, SLOT(statusChanged(RemoteView::RemoteStatus)));
scroll_area->setWidget(vnc_view);
vnc_view->start();
- vnc_view->enableScaling(scaling->isChecked());
key_menu = new KeyMenu(this);
}
}
QSettings settings;
settings.setValue("show_toolbar", show_toolbar->isChecked());
- settings.setValue("rescale", scaling->isChecked());
+ settings.setValue("zoomlevel", zoom_slider->value());
settings.sync();
hide();
vnc_view = new VncView(this, url, RemoteView::Quality(quality));
- connect(scaling, SIGNAL(toggled(bool)),
- vnc_view, SLOT(enableScaling(bool)));
connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
this, SLOT(statusChanged(RemoteView::RemoteStatus)));
scroll_area->setWidget(vnc_view);
vnc_view->start();
- vnc_view->enableScaling(scaling->isChecked());
disconnect_action->setEnabled(true);
toolbar->setEnabled(true);
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
#endif
+ /* TODO: still needed?
if(!scaling->isChecked()) {
//ugly hack to force a refresh (forceFullRepaint() doesn't repaint?? -> vnc_view hidden???)
vnc_view->resize(scroll_area->size());
vnc_view->enableScaling(false);
}
+ */
break;
case RemoteView::Disconnecting:
if(old_status != RemoteView::Disconnected) { //Disconnecting also occurs while connecting, so check last state
old_status = status;
}
-//when rescaling is enabled, this resizes the widget to use available screen space
+//resizes the widget to use available screen space
//necessary when rotating, showing fullscreen, etc.
void MainWindow::forceResize()
{
- if(vnc_view and scaling->isChecked()) {
+ if(vnc_view) {
vnc_view->resize(scroll_area->size());
}
}
//with scaled view, artefacts occur because of rounding errors
//we'll try to only update chunks of screen space that correspond to integer pixel sizes in m_frame
+ //put this into paintEvent
/*
int frame_x = x/m_horizontalFactor;
int frame_w = w/m_horizontalFactor;
void VncView::enableScaling(bool scale)
{
RemoteView::enableScaling(scale);
-
- if (scale) {
- //setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
- //setMinimumSize(1, 1);
- if (parentWidget())
- scaleResize(parentWidget()->width(), parentWidget()->height());
- else
- scaleResize(width(), height());
- } else {
- m_verticalFactor = 1.0;
- m_horizontalFactor = 1.0;
-
- //setMaximumSize(m_frame.width(), m_frame.height()); //This is a hack to force Qt to center the view in the scroll area
- //setMinimumSize(m_frame.width(), m_frame.height());
- resize(m_frame.width(), m_frame.height());
- }
}
//level should be in [0, 100]
bool always_show_local_cursor = settings.value("always_show_local_cursor", false).toBool();
if(always_show_local_cursor)
showDotCursor(CursorOn);
+
+ enableScaling(true);
}
//convert commitString into keyevents