1 #include <kapplication.h>
10 #include "NewWindowDialog.h"
12 NewWindowDialog::NewWindowDialog(const KSircChannel
&channelInfo
, QWidget
* parent
, const char * name
)
14 m_channelInfo(channelInfo
)
16 setCaption(i18n("New Window For"));
17 setButtons(Ok
|Cancel
);
20 enableButtonSeparator(true);
21 KHBox
* w
= new KHBox(this);
24 QLabel
* l
= new QLabel(i18n("C&hannel/Nick:"), w
);
26 m_combo
= new KHistoryCombo(w
);
29 // we don't need duplicated channel into the list
30 m_combo
->setDuplicatesEnabled( false );
34 QLabel
* l2
= new QLabel(i18n("&Key:"), w
);
35 m_le
= new KLineEdit(w
);
36 m_le
->setEnabled(false);
40 m_combo
, SIGNAL(activated(const QString
&)),
41 m_combo
, SLOT(addToHistory(const QString
&)));
42 connect( m_combo
->lineEdit(), SIGNAL(textChanged ( const QString
& )),
43 this, SLOT( slotTextChanged( const QString
&)));
45 KConfig
*kConfig
= KGlobal::config();
46 KConfigGroup
group(kConfig
, "Recent");
47 m_combo
->setHistoryItems(group
.readEntry("Channels",QStringList()));
48 slotTextChanged( m_combo
->lineEdit()->text());
51 NewWindowDialog::~NewWindowDialog()
53 KConfig
*kConfig
= KGlobal::config();
54 KConfigGroup
group(kConfig
, "Recent");
55 group
.writeEntry("Channels", m_combo
->historyItems());
58 void NewWindowDialog::slotTextChanged( const QString
&text
)
60 enableButtonOk( !text
.isEmpty() );
62 if(text
[0] == QLatin1Char('#') || text
[0] == QLatin1Char('&'))
63 m_le
->setEnabled(true);
65 m_le
->setEnabled(false);
70 NewWindowDialog::slotOk()
72 m_channelInfo
.setChannel(m_combo
->lineEdit()->text().lower());
74 m_channelInfo
.setKey(m_le
->text());
75 emit(openTopLevel(m_channelInfo
));
79 #include "NewWindowDialog.moc"