summaryrefslogtreecommitdiff
path: root/noncore/comm/keypebble/kvncconndlg.cpp
blob: 420c816edabb7fda0acc08898d2dfa56d696d5f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qspinbox.h>
#include <qlineedit.h>

#include "kvncconndlg.h"

KVNCConnDlg::KVNCConnDlg( KRFBServer *options,
				QWidget *parent, char *name, bool modal )
: KVNCConnDlgBase( parent, name, modal, WStyle_ContextHelp )
{
    this->options=options;
    tmpOptions=*options;

    serverHostname->setText(options->hostname);
    serverDisplay->setValue(options->display);
    serverPassword->setText(options->password);
    serverBookmark->setText(options->name);

		hex->setChecked( options->hexTile );
		corre->setChecked( options->corre );
		rre->setChecked( options->rre );
		copyRect->setChecked( options->copyrect );

		for (int i=0; i < scaleFactor->count(); ++i) {
				if (scaleFactor->text(i).toInt()==tmpOptions.scaleFactor) {
						scaleFactor->setCurrentItem(i);
				}
		}

		// TODO
		hex->setEnabled( false );
		corre->setEnabled( false );
		rre->setEnabled( false );
		// /TODO

		deIconify->setChecked( options->deIconify );
		bit->setChecked( options->colors256 );
		shared->setChecked( options->shared );
		timeBox->setValue( options->updateRate );
		    
		serverPassword->setEchoMode(QLineEdit::Password);

		connect(togglePassword, SIGNAL( stateChanged(int) ), this, SLOT( showPassword(int) ) );


}
KVNCConnDlg::~KVNCConnDlg()
{
}

void KVNCConnDlg::accept()
{
		save();
		QDialog::accept();
}

void KVNCConnDlg::save()
{
		tmpOptions.hexTile = hex->isChecked();
		tmpOptions.corre = corre->isChecked();
		tmpOptions.rre = rre->isChecked();
		tmpOptions.copyrect = copyRect->isChecked();
		tmpOptions.deIconify = deIconify->isChecked();
		tmpOptions.colors256 = bit->isChecked();
		tmpOptions.shared = shared->isChecked();
		tmpOptions.hostname = serverHostname->text();
		tmpOptions.password = serverPassword->text();
		tmpOptions.display = serverDisplay->value();
		tmpOptions.name = serverBookmark->text();
		tmpOptions.scaleFactor = scaleFactor->currentText().toInt();

		if (!serverBookmark->text().isEmpty()) {
       if ( options) {
          *options=tmpOptions;
        }
    }
}

void KVNCConnDlg::showPassword(int show)
{
		if (show)
				serverPassword->setEchoMode(QLineEdit::Normal);
		else
			serverPassword->setEchoMode(QLineEdit::Password);
}