summaryrefslogtreecommitdiffstats
path: root/konversation/src/channeldialog.cpp
blob: d50a694c24286b74e684f43dd45f943144dda98b (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
/*
  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.

  copyright: (C) 2004 by Peter Simonsson
  email:     psn@linux.se
*/

#include "channeldialog.h"
#include "servergroupsettings.h"

#include <tqlayout.h>
#include <tqframe.h>
#include <tqlabel.h>
#include <tqlineedit.h>

#include <tdelocale.h>
#include <tdemessagebox.h>


namespace Konversation
{

    ChannelDialog::ChannelDialog(const TQString& title, TQWidget *parent, const char *name)
        : KDialogBase(Plain, title, Ok|Cancel, Ok, parent, name)
    {
        TQFrame* mainWidget = plainPage();
        TQGridLayout* mainLayout = new TQGridLayout(mainWidget, 1, 2, 0, spacingHint());

        TQLabel* channelLbl = new TQLabel(i18n("C&hannel:"), mainWidget);
        m_channelEdit = new TQLineEdit(mainWidget);
        m_channelEdit->setMaxLength(50);
        channelLbl->setBuddy(m_channelEdit);

        TQLabel* passwordLbl = new TQLabel(i18n("Pass&word:"), mainWidget);
        m_passwordEdit = new TQLineEdit(mainWidget);
        m_passwordEdit->setEchoMode(TQLineEdit::Password);
        passwordLbl->setBuddy(m_passwordEdit);

        mainLayout->addWidget(channelLbl, 0, 0);
        mainLayout->addWidget(m_channelEdit, 0, 1);
        mainLayout->addWidget(passwordLbl, 1, 0);
        mainLayout->addWidget(m_passwordEdit, 1, 1);

        m_channelEdit->setFocus();
    }

    ChannelDialog::~ChannelDialog()
    {
    }

    void ChannelDialog::setChannelSettings(const ChannelSettings& channel)
    {
        m_channelEdit->setText(channel.name());
        m_passwordEdit->setText(channel.password());
    }

    ChannelSettings ChannelDialog::channelSettings()
    {
        ChannelSettings channel;
        channel.setName(m_channelEdit->text());
        channel.setPassword(m_passwordEdit->text());

        return channel;
    }

    void ChannelDialog::slotOk()
    {
        if (m_channelEdit->text().isEmpty())
        {
            KMessageBox::error(this, i18n("The channel name is required."));
        }
        else
        {
            accept();
        }
    }
}

#include "channeldialog.moc"