2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
14 #include <QFileDialog>
18 #include "mastersettings.h"
20 static const char* timeseal_cmd_tool_tip
=
21 "Expandable variables ref:\n"
22 " $(HOST_IP) - The resolved ip address of the host\n"
23 " $(HOST_NAME) - The host name\n"
24 " $(PORT) - The TCP port to connect to";
26 QConnect::QConnect(QWidget
*parent
, const char *name
)
32 connect(buttonTimesealPath
, SIGNAL(clicked()), this, SLOT(setTimesealPath()));
33 chkTimesealCmd
->setToolTip(timeseal_cmd_tool_tip
);
34 editTimesealCmd
->setToolTip(timeseal_cmd_tool_tip
);
35 //std::cout << "initializing dialog" << std::endl;
37 Settings s_ics
= settings
.group("ics");
38 if (s_ics
["username"])
39 editUsername
->setText(s_ics
["username"].value
<QString
>());
40 if (s_ics
["password"]) {
41 editPassword
->setText(s_ics
["password"].value
<QString
>());
42 chkStore
->setChecked(true);
45 editHost
->setText(s_ics
["host"] | "");
46 spinPort
->setValue((s_ics
["port"] | 5000));
47 Settings s_timeseal
= s_ics
.group("timeseal");
48 groupTimeseal
->setChecked(s_timeseal
.flag("use", false));
49 editTimeseal
->setText(s_timeseal
["path"] |= QString());
50 chkTimesealCmd
->setChecked(s_timeseal
["command"].flag("use", false)); editTimesealCmd
->setText(s_timeseal
["command"] |= "$(HOST_IP) $(PORT)");
53 void QConnect::setTimesealPath() {
54 QString t
= QFileDialog::getOpenFileName();
56 editTimeseal
->setText(t
);
59 void QConnect::accept() {
62 Settings s_ics
= settings
.group("ics");
63 s_ics
["username"] = editUsername
->text();
64 if (chkStore
->isChecked())
65 s_ics
["password"] = editPassword
->text();
67 s_ics
["password"].remove();
68 s_ics
["host"] = editHost
->text();
69 s_ics
["port"] = spinPort
->value();
72 Settings s_timeseal
= s_ics
.group("timeseal");
73 s_timeseal
.setFlag("use", groupTimeseal
->isChecked());
74 s_timeseal
["path"] = editTimeseal
->text();
75 s_timeseal
.group("command").setFlag("use", chkTimesealCmd
->isChecked());
76 s_timeseal
["command"] = editTimesealCmd
->text();
79 emit
acceptConnection(editUsername
->text(),
83 groupTimeseal
->isChecked() ? editTimeseal
->text() : QString(),
84 chkTimesealCmd
->isChecked() ? editTimesealCmd
->text() :
85 QString("$(HOST_IP) $(PORT)")