Implemented in lua better selection tags.
[tagua/yd.git] / src / qconnect.cpp
blobbada86729b155b5e96cb0cdc023bca3ea06f6eaa
1 /*
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.
9 */
11 #include <QLineEdit>
12 #include <QSpinBox>
13 #include <QCheckBox>
14 #include <QFileDialog>
16 #include <iostream>
17 #include "qconnect.h"
18 #include "global.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)
27 : QDialog(parent)
29 setObjectName(name);
31 setupUi(this);
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);
44 if (s_ics["host"])
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();
55 if(!t.isEmpty())
56 editTimeseal->setText(t);
59 void QConnect::accept() {
60 QDialog::accept();
62 Settings s_ics = settings.group("ics");
63 s_ics["username"] = editUsername->text();
64 if (chkStore->isChecked())
65 s_ics["password"] = editPassword->text();
66 else
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(),
80 editPassword->text(),
81 editHost->text(),
82 spinPort->value(),
83 groupTimeseal->isChecked() ? editTimeseal->text() : QString(),
84 chkTimesealCmd->isChecked() ? editTimesealCmd->text() :
85 QString("$(HOST_IP) $(PORT)")