summaryrefslogtreecommitdiffstats
path: root/libksirtet/lib/miscui.cpp
blob: 97a7bfa4f01fc7643ce91be4fe83d2725bdd69b6 (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
#include "miscui.h"
#include "miscui.moc"

#include <tqlayout.h>

#include <tdelocale.h>


//-----------------------------------------------------------------------------
MeetingCheckBox::MeetingCheckBox(Type type, bool owner, bool server,
                                 TQWidget *parent)
    : TQWidget(parent, "meeting_check_box")
{
    TQVBoxLayout *vbox = new TQVBoxLayout(this);

    _ready = new TQCheckBox(i18n("Ready"), this);
    vbox->addWidget(_ready);
    _ready->setEnabled(owner);
    connect(_ready, TQT_SIGNAL(clicked()), TQT_SLOT(changedSlot()));

    _excluded = new TQCheckBox(i18n("Excluded"), this);
    vbox->addWidget(_excluded);
    _excluded->setEnabled(server);
    connect(_excluded, TQT_SIGNAL(clicked()), TQT_SLOT(changedSlot()));

    setType(type);
}

void MeetingCheckBox::setType(Type type)
{
    _ready->setChecked( type==Ready );
    _excluded->setChecked( type==Excluded );
}

MeetingCheckBox::Type MeetingCheckBox::type() const
{
    if ( _excluded->isChecked() ) return Excluded;
    if ( _ready->isChecked() ) return Ready;
    return NotReady;
}

void MeetingCheckBox::changedSlot()
{
    emit changed(type());
}

//-----------------------------------------------------------------------------
PlayerComboBox::PlayerComboBox(Type type, bool canBeEmpty, bool acceptAI,
                               TQWidget *parent)
    : TQComboBox(parent, "player_combo_box")
{
    insertItem(i18n("Human"));
    if (acceptAI) insertItem(i18n("AI"));
    if (canBeEmpty) insertItem(i18n("None"));
    setCurrentItem(type);

    connect(this, TQT_SIGNAL(activated(int)), TQT_SIGNAL(changed(int)));
}