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
|
/*
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.
*/
/*
lets the user choose a nick from the list
begin: Sam Dez 7 2002
copyright: (C) 2002 by Dario Abatianni
email: eisfuchs@tigress.com
*/
#include "dccrecipientdialog.h"
#include <tqlayout.h>
#include <klineedit.h>
#include <klocale.h>
#include <kdebug.h>
TQString DccRecipientDialog::selectedNickname; // static
DccRecipientDialog::DccRecipientDialog(TQWidget* tqparent, const TQStringList &list,const TQSize &size) :
KDialogBase(tqparent,"dcc_recipient_dialog",true,i18n("Select Recipient"),
KDialogBase::Ok | KDialogBase::Cancel,KDialogBase::Ok,true)
{
// Create the top level widget
TQWidget* page=new TQWidget(this);
setMainWidget(page);
// Add the tqlayout to the widget
TQVBoxLayout* dialogLayout=new TQVBoxLayout(page);
dialogLayout->setSpacing(spacingHint());
// Add the nickname list widget
KListBox* nicknameList=new KListBox(page,"recipient_list");
nicknameList->insertStringList(list);
nicknameList->sort(true);
nicknameInput=new KLineEdit(page,"nickname_input");
dialogLayout->addWidget(nicknameList);
dialogLayout->addWidget(nicknameInput);
connect(nicknameList,TQT_SIGNAL (highlighted(TQListBoxItem*)),this,TQT_SLOT (newNicknameSelected(TQListBoxItem*)) );
connect(nicknameList,TQT_SIGNAL (doubleClicked(TQListBoxItem*)),this,TQT_SLOT (newNicknameSelectedQuit(TQListBoxItem*)) );
setButtonOK(KGuiItem(i18n("&OK"),"button_ok",i18n("Select nickname and close the window")));
setButtonCancel(KGuiItem(i18n("&Cancel"),"button_cancel",i18n("Close the window without changes")));
setInitialSize(size);
show();
}
DccRecipientDialog::~DccRecipientDialog()
{
}
TQString DccRecipientDialog::getSelectedNickname()
{
return selectedNickname;
}
void DccRecipientDialog::newNicknameSelected(TQListBoxItem* item)
{
nicknameInput->setText(item->text());
}
void DccRecipientDialog::newNicknameSelectedQuit(TQListBoxItem* item)
{
newNicknameSelected(item);
selectedNickname=nicknameInput->text();
delayedDestruct();
}
void DccRecipientDialog::slotCancel()
{
selectedNickname=TQString();
KDialogBase::slotCancel();
}
void DccRecipientDialog::slotOk()
{
selectedNickname=nicknameInput->text();
KDialogBase::slotOk();
}
TQString DccRecipientDialog::getNickname(TQWidget* tqparent, const TQStringList& list)
{
TQSize size; // TODO: get it from Preferences
DccRecipientDialog dlg(tqparent,list,size);
dlg.exec();
return dlg.getSelectedNickname();
}
#include "dccrecipientdialog.moc"
|