presencevnc (0.4) unstable; urgency=low
* Add button to launch virtual keyboard
+ * Add history to connect dialog
+ * Fix tearing after scrolling
* Real fullscreen
-- Christian Pulvermacher <pulvermacher@gmx.de> Sat, 07 Aug 2010 11:52:56 +0200
setWindowTitle(tr("Connect to VNC Server"));
QSettings settings;
- int i = 0;
- for(;;) { //read history
- QString hostname = settings.value(QString("host%1").arg(i), "").toString();
- if(hostname.isEmpty())
- break;
-
- hosts.addItem(hostname);
- i++;
+ //read history
+ settings.beginGroup("hosts");
+ QStringList hostnames = settings.childGroups();
+ QStringList hostnames_sorted = hostnames;
+ foreach(QString hostname, hostnames) {
+ int position = settings.value(hostname + "/position").toInt();
+ if(position < 0)
+ position = 0;
+ else if(position >= hostnames.size())
+ position = hostnames.size()-1;
+
+ hostnames_sorted.replace(position, hostname);
}
+ settings.endGroup();
+
+ //set up combobox
+ hosts.addItems(hostnames_sorted);
hosts.setEditable(true);
hosts.lineEdit()->setInputMethodHints(Qt::ImhLowercaseOnly); //doesn't work, but I tried.
connect(&hosts, SIGNAL(editTextChanged(QString)),
- this, SLOT(convertToLowercase(QString)));
+ this, SLOT(cleanHostname(QString)));
layout.addWidget(&hosts);
QPushButton *done = new QPushButton(tr("Done"));
setLayout(&layout);
}
-void ConnectDialog::convertToLowercase(QString newtext)
+void ConnectDialog::cleanHostname(QString newtext)
{
+ newtext.remove(QChar('/'));
+ newtext.remove(QChar('\\'));
hosts.lineEdit()->setText(newtext.toLower());
}
//save url?
QSettings settings;
+ settings.beginGroup("hosts");
bool new_item = hosts.itemText(hosts.currentIndex()) != hosts.currentText();
bool used_old_host = !new_item and hosts.currentIndex() > 0;
- int rearrange_from_idx;
+ int rearrange_up_to_pos;
if(new_item) {
std::cout << "adding new item to history\n";
- int i = 0;
- for(;;) { //find first unused key
- QString hostname = settings.value(QString("host%1").arg(i), "").toString();
- if(hostname.isEmpty())
- break;
- i++;
- }
- rearrange_from_idx = i;
+ rearrange_up_to_pos = hosts.count(); //use free index
} else if(used_old_host) {
- rearrange_from_idx = hosts.currentIndex();
+ rearrange_up_to_pos = hosts.currentIndex();
}
if(new_item or used_old_host) {
- std::cout << "rearranging history, last index " << rearrange_from_idx << "\n";
+ std::cout << "rearranging history, last index " << rearrange_up_to_pos << "\n";
- for(int i = rearrange_from_idx-1; i >= 0; i--) { //increment index for each entry newer than the selected one
- QString hostname = settings.value(QString("host%1").arg(i), "").toString();
- settings.setValue(QString("host%1").arg(i+1), hostname);
+ QStringList hostnames = settings.childGroups();
+ foreach(QString hostname, hostnames) {
+ int position = settings.value(hostname + "/position").toInt();
+ if(position < rearrange_up_to_pos)
+ settings.setValue(hostname + "/position", position+1);
}
- settings.setValue(QString("host0"), hosts.currentText());
+ //position 0 is now free
+
+ //move selected host to front
+ settings.setValue(QString("%1/position").arg(hosts.currentText()), 0);
}
+ settings.endGroup();
emit connectToHost(QString("vnc://") + hosts.currentText());
deleteLater();
signals:
void connectToHost(QString url);
private slots:
- void convertToLowercase(QString newtext);
+ void cleanHostname(QString newtext);
private:
QHBoxLayout layout;
QComboBox hosts;
MainWindow::MainWindow(QString url, int quality):
QMainWindow(0),
vnc_view(0),
- scroll_area(new QScrollArea(0))
+ scroll_area(new ScrollArea(0))
{
setWindowTitle("Presence VNC");
setAttribute(Qt::WA_Maemo5StackedWindow);
//set up menu
QMenuBar *menu = new QMenuBar(this);
- QAction *connect_action = new QAction("Connect", this);
- disconnect_action = new QAction("Disconnect", this);
+ QAction *connect_action = new QAction(tr("Connect"), this);
+ disconnect_action = new QAction(tr("Disconnect"), this);
menu->addAction(connect_action);
menu->addAction(disconnect_action);
- scaling = new QAction("Fit to Screen", this);
+ scaling = new QAction(tr("Fit to Screen"), this);
scaling->setCheckable(true);
scaling->setChecked(settings.value("rescale", true).toBool());
menu->addAction(scaling);
- show_toolbar = new QAction("Show Toolbar", this);
+ show_toolbar = new QAction(tr("Show Toolbar"), this);
show_toolbar->setCheckable(true);
show_toolbar->setChecked(settings.value("show_toolbar", true).toBool());
menu->addAction(show_toolbar);
- QAction *pref_action = new QAction("Preferences", this);
+ QAction *pref_action = new QAction(tr("Preferences"), this);
menu->addAction(pref_action);
- QAction *about_action = new QAction("About", this);
+ QAction *about_action = new QAction(tr("About"), this);
menu->addAction(about_action);
connect(about_action, SIGNAL(triggered()),
break;
case RemoteView::Disconnecting:
if(old_status != RemoteView::Disconnected) { //Disconnecting also occurs while connecting, so check last state
- QMaemo5InformationBox::information(this, "Connection lost");
+ QMaemo5InformationBox::information(this, tr("Connection lost"));
//clean up
scroll_area->setWidget(0);
#include "remoteview.h"
#include "vncview.h"
+//fix tearing during scrolling
+class ScrollArea : public QScrollArea {
+public:
+ ScrollArea(QWidget *parent) : QScrollArea(parent) { }
+protected:
+ virtual void scrollContentsBy(int dx, int dy)
+ {
+ QScrollArea::scrollContentsBy(dx, dy);
+ if(widget())
+ widget()->update(); //update whole widget
+ }
+};
+
class MainWindow : public QMainWindow {
Q_OBJECT
public:
void grabZoomKeys(bool grab);
void reloadSettings();
VncView *vnc_view;
- QScrollArea *scroll_area;
+ ScrollArea *scroll_area;
QToolBar *toolbar;
QAction *scaling, *show_toolbar, *disconnect_action;
};
if(config_ver == 1) {
QString last_hostname = settings.value("last_hostname", "").toString();
settings.remove("last_hostname");
- if(!last_hostname.isEmpty())
- settings.setValue("host0", last_hostname);
+ if(!last_hostname.isEmpty()) {
+ //make sure hostname is sane
+ last_hostname.remove(QChar('/'));
+ last_hostname.remove(QChar('\\'));
+ last_hostname = last_hostname.toLower();
+
+ settings.setValue(QString("hosts/%1/position").arg(last_hostname), 0);
+ }
config_ver = 2;
}
Preferences::Preferences(QWidget *parent):
QDialog(parent)
{
- setWindowTitle("Preferences");
+ setWindowTitle(tr("Preferences"));
QHBoxLayout *layout1 = new QHBoxLayout();
QVBoxLayout *layout2 = new QVBoxLayout();