summaryrefslogtreecommitdiffstats
path: root/konversation/src/quickconnectdialog.cpp
blob: 20f98191ea6048ea140d17c237216d96f26afccb (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
*/

/*
  Dialog for quick connection to an IRC network without adding a server in the Server List.
  begin:     Sat June 05 2004
  copyright: (C) 2004 by Michael Goettsche
  email:     mail@tuxipuxi.de
*/

#include "quickconnectdialog.h"
#include "konversationapplication.h"

#include <tqlayout.h>
#include <tqwhatsthis.h>
#include <tqlabel.h>
#include <tqcheckbox.h>

#include <klineedit.h>
#include <klocale.h>


QuickConnectDialog::QuickConnectDialog(TQWidget *tqparent)
:KDialogBase(tqparent, "quickconnect", true, i18n("Quick Connect"),
KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, true)
{
    TQWidget* page = new TQWidget(this);
    setMainWidget(page);

    TQGridLayout* tqlayout = new TQGridLayout(page, 2, 4);
    tqlayout->setSpacing(spacingHint());
    tqlayout->setColStretch(1, 10);

    TQLabel* hostNameLabel = new TQLabel(i18n("&Server host:"), page);
    TQString hostNameWT = i18n("Enter the host of the network here.");
    TQWhatsThis::add(hostNameLabel, hostNameWT);
    hostNameInput = new KLineEdit(page);
    TQWhatsThis::add(hostNameInput, hostNameWT);
    hostNameLabel->setBuddy(hostNameInput);

    TQLabel* portLabel = new TQLabel(i18n("&Port:"), page);
    TQString portWT = i18n("The port that the IRC server is using.");
    TQWhatsThis::add(portLabel, portWT);
    portInput = new KLineEdit("6667", page );
    TQWhatsThis::add(portInput, portWT);
    portLabel->setBuddy(portInput);

    TQLabel* nickLabel = new TQLabel(i18n("&Nick:"), page);
    TQString nickWT = i18n("The nick you want to use.");
    TQWhatsThis::add(nickLabel, nickWT);
    nickInput = new KLineEdit(Preferences::nickname(0), page);
    TQWhatsThis::add(nickInput, nickWT);
    nickLabel->setBuddy(nickInput);

    TQLabel* passwordLabel = new TQLabel(i18n("P&assword:"), page);
    TQString passwordWT = i18n("If the IRC server requires a password, enter it here (most servers do not require a password.)");
    TQWhatsThis::add(passwordLabel, passwordWT);
    passwordInput = new KLineEdit(page);
    TQWhatsThis::add(passwordInput, passwordWT);
    passwordLabel->setBuddy(passwordInput);

    sslCheckBox = new TQCheckBox(page, "sslCheckBox");
    sslCheckBox->setText(i18n("&Use SSL"));

    tqlayout->addWidget(hostNameLabel, 0, 0);
    tqlayout->addWidget(hostNameInput, 0, 1);
    tqlayout->addWidget(portLabel, 0, 2);
    tqlayout->addWidget(portInput, 0, 3);

    tqlayout->addWidget(nickLabel, 1, 0);
    tqlayout->addWidget(nickInput, 1, 1);
    tqlayout->addWidget(passwordLabel, 1, 2);
    tqlayout->addWidget(passwordInput, 1, 3);

    tqlayout->addWidget(sslCheckBox, 2, 0);

    hostNameInput->setFocus();

    setButtonOK(KGuiItem(i18n("C&onnect"),"connect_creating",i18n("Connect to the server")));
}

QuickConnectDialog::~QuickConnectDialog()
{
}

void QuickConnectDialog::slotOk()
{
    if (!hostNameInput->text().isEmpty() &&
        !portInput->text().isEmpty() &&
        !nickInput->text().isEmpty())
    {

        emit connectClicked(Konversation::PromptToReuseConnection,
                            hostNameInput->text().stripWhiteSpace(),
                            portInput->text(),
                            passwordInput->text(),
                            nickInput->text(),
                            "",
                            sslCheckBox->isChecked());
        delayedDestruct();
    }
}

#include "quickconnectdialog.moc"