newtext.remove(QChar('\\'));
hosts.lineEdit()->setText(newtext.toLower());
+#ifdef Q_WS_MAEMO_5
//saved quality setting available?
QSettings settings;
int quality = settings.value(QString("hosts/%1/quality").arg(hosts.lineEdit()->text()), 2).toInt();
if(quality < 1 or quality > 3)
quality = 2;
quality_selector->setCurrentIndex(quality-1);
+#endif
}
void ConnectDialog::accept()
//move selected host to front
settings.setValue(QString("%1/position").arg(hosts.currentText()), 0);
}
+#ifdef Q_WS_MAEMO_5
int quality = quality_selector->currentIndex() + 1;
settings.setValue(QString("%1/quality").arg(hosts.currentText()), quality);
+#else
+ int quality = 2;
+#endif
settings.endGroup();
settings.sync();
#include "preferences.h"
#include "vncview.h"
+#include <QSlider>
+
#ifdef Q_WS_MAEMO_5
#include <QtMaemo5>
#include <QX11Info>
#endif
+
MainWindow::MainWindow(QString url, int quality):
QMainWindow(0),
vnc_view(0),
addToolBar(toolbar);
toolbar->setVisible(settings.value("show_toolbar", true).toBool());
+ //set up zoombar
+ zoombar = new QToolBar(0);
+ QSlider *zoom_slider = new QSlider(Qt::Horizontal, 0);
+ zoom_slider->setRange(0, 100);
+ connect(zoom_slider, SIGNAL(valueChanged(int)),
+ this, SLOT(setZoomLevel(int)));
+ zoombar->addWidget(zoom_slider);
+ addToolBar(zoombar);
+
//set up menu
QAction *connect_action = new QAction(tr("Connect"), this);
disconnect_action = new QAction(tr("Disconnect"), this);
QApplication::sendEvent(vnc_view, &event);
#endif
}
+
+void MainWindow::setZoomLevel(int level)
+{
+ if(vnc_view)
+ vnc_view->setZoomLevel(level);
+}
void sendPgUp() { vnc_view->sendKey(Qt::Key_PageUp); }
void sendPgDn() { vnc_view->sendKey(Qt::Key_PageDown); }
void sendReturn() { vnc_view->sendKey(Qt::Key_Return); }
+ void setZoomLevel(int level);
void showInputPanel();
void showKeyMenu();
void showPreferences();
void reloadSettings();
VncView *vnc_view;
ScrollArea *scroll_area;
- QToolBar *toolbar;
+ QToolBar *toolbar, *zoombar;
QAction *scaling, *show_toolbar, *disconnect_action;
KeyMenu *key_menu;
};
if (parentWidget())
scaleResize(parentWidget()->width(), parentWidget()->height());
else
- scaleResize(width(), height());
+ scaleResize(width(), height());
} else {
m_verticalFactor = 1.0;
m_horizontalFactor = 1.0;
}
}
+void VncView::setZoomLevel(int level)
+{
+ Q_ASSERT(parentWidget() != 0);
+ kDebug(5011) << "zooming to " << level;
+
+ //level should be in [0, 100]
+ if(level == 0) {
+ //double
+ m_verticalFactor = 2.0;
+ m_horizontalFactor = 2.0;
+
+ resize(m_frame.width()*2, m_frame.height()*2);
+ } else if(level < 10) {
+ //1:1
+ m_verticalFactor = 1.0;
+ m_horizontalFactor = 1.0;
+
+ resize(m_frame.width(), m_frame.height());
+ } else {
+ //map level to factor: level=10 => factor=nozoom_factor, level=100 => factor=1.0
+ double nozoom_factor = qMin(double(m_frame.width()/parentWidget()->width()), double(m_frame.height()/parentWidget()->height()));
+ double factor = double(level-10)/90*(1.0 - nozoom_factor) + nozoom_factor;
+ if(factor < 0) {
+ //remote display smaller than local?
+ kDebug(5011) << "remote display smaller than local?";
+ factor = 1.0;
+ }
+
+ scaleResize(parentWidget()->width()*factor, parentWidget()->height()*factor);
+ }
+}
+
void VncView::setCut(const QString &text)
{
m_dontSendClipboard = true;
void showDotCursor(DotCursorState state);
public slots:
- void enableScaling(bool scale);
+ void enableScaling(bool scale); //TODO: i may want to remove this
+ void setZoomLevel(int level); //'level' doesn't correspond to actual magnification, though mapping is done here
void scaleResize(int w, int h);
void sendKey(Qt::Key key);
void sendKeySequence(QKeySequence keys);