Replaced all std::cout with kDebug.
[tagua/yd.git] / src / qconnect.cpp
blob7ee180b66ccf70c1c153d8d9f7c71308215512c5
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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>
15 #include <KFileDialog>
16 #include <KMessageBox>
18 #include <iostream>
19 #include "qconnect.h"
20 #include "mastersettings.h"
22 static const char* timeseal_cmd_tool_tip =
23 "Expandable variables ref:\n"
24 " $(HOST_IP) - The resolved ip address of the host\n"
25 " $(HOST_NAME) - The host name\n"
26 " $(PORT) - The TCP port to connect to";
28 QConnect::QConnect(QWidget *parent, const char *name)
29 : QDialog(parent)
31 setObjectName(name);
33 setupUi(this);
34 connect(buttonTimesealPath, SIGNAL(clicked()), this, SLOT(setTimesealPath()));
35 chkTimesealCmd->setToolTip(timeseal_cmd_tool_tip);
36 editTimesealCmd->setToolTip(timeseal_cmd_tool_tip);
37 //kDebug() << "initializing dialog";
39 Settings s_ics = settings().group("ics");
40 if (s_ics["username"])
41 editUsername->setText(s_ics["username"].value<QString>());
42 if (s_ics["password"]) {
43 editPassword->setText(s_ics["password"].value<QString>());
44 chkStore->setChecked(true);
46 if (s_ics["host"])
47 editHost->setText(s_ics["host"] | "");
48 spinPort->setValue((s_ics["port"] | 5000));
49 Settings s_timeseal = s_ics.group("timeseal");
50 groupTimeseal->setChecked(s_timeseal.flag("use", false));
51 editTimeseal->setText(s_timeseal["path"] |= QString());
52 chkTimesealCmd->setChecked(s_timeseal["command"].flag("use", false)); editTimesealCmd->setText(s_timeseal["command"] |= "$(HOST_IP) $(PORT)");
55 void QConnect::setTimesealPath() {
56 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*", this, i18n("Select timeseal binary"));
58 if (!url.isLocalFile()) {
59 KMessageBox::sorry(0, i18n("Only local executables supported"));
60 return;
63 if (!url.isEmpty())
64 editTimeseal->setText(url.path());
67 void QConnect::accept() {
68 QDialog::accept();
70 Settings s_ics = settings().group("ics");
71 s_ics["username"] = editUsername->text();
72 if (chkStore->isChecked())
73 s_ics["password"] = editPassword->text();
74 else
75 s_ics["password"].remove();
76 s_ics["host"] = editHost->text();
77 s_ics["port"] = spinPort->value();
80 Settings s_timeseal = s_ics.group("timeseal");
81 s_timeseal.setFlag("use", groupTimeseal->isChecked());
82 s_timeseal["path"] = editTimeseal->text();
83 s_timeseal.group("command").setFlag("use", chkTimesealCmd->isChecked());
84 s_timeseal["command"] = editTimesealCmd->text();
87 acceptConnection(editUsername->text(),
88 editPassword->text(),
89 editHost->text(),
90 spinPort->value(),
91 groupTimeseal->isChecked() ? editTimeseal->text() : QString(),
92 chkTimesealCmd->isChecked() ? editTimesealCmd->text() :
93 QString("$(HOST_IP) $(PORT)")