26 #include "addfeeddialog.h"
28 #include <tqcheckbox.h>
30 #include <tdeapplication.h>
32 #include <tdelocale.h>
33 #include <klineedit.h>
34 #include <kiconloader.h>
35 #include <kicontheme.h>
37 #include <ksqueezedtextlabel.h>
38 #include <tdemessagebox.h>
42 AddFeedWidget::AddFeedWidget(TQWidget *parent,
const char *name)
43 : AddFeedWidgetBase(parent, name)
45 pixmapLabel1->setPixmap(kapp->iconLoader()->loadIcon(
"applications-internet",TDEIcon::Desktop,TDEIcon::SizeHuge, TDEIcon::DefaultState, 0,
true));
46 statusLabel->setText(TQString());
49 AddFeedWidget::~AddFeedWidget()
52 AddFeedDialog::AddFeedDialog(TQWidget *parent,
const char *name)
53 : KDialogBase(KDialogBase::Swallow, TQt::WStyle_DialogBorder, parent, name, true, i18n(
"Add Feed"), KDialogBase::Ok|KDialogBase::Cancel)
55 widget =
new AddFeedWidget(
this);
56 connect(widget->urlEdit, TQ_SIGNAL(textChanged(
const TQString&)),
this, TQ_SLOT(textChanged(
const TQString&)));
57 enableButtonOK(
false);
58 setMainWidget(widget);
61 AddFeedDialog::~AddFeedDialog()
64 void AddFeedDialog::setURL(
const TQString& t)
66 widget->urlEdit->setText(t);
69 void AddFeedDialog::slotOk( )
71 enableButtonOK(
false);
72 feedURL = widget->urlEdit->text().stripWhiteSpace();
79 if (feedURL.startsWith(
"feed:"))
80 feedURL = feedURL.right( feedURL.length() - 5 );
82 if (feedURL.find(
":/") == -1)
83 feedURL.prepend(
"http://");
84 f->setXmlUrl(feedURL);
86 widget->statusLabel->setText( i18n(
"Downloading %1").arg(feedURL) );
88 connect( feed, TQ_SIGNAL(fetched(Feed* )),
89 this, TQ_SLOT(fetchCompleted(Feed *)) );
90 connect( feed, TQ_SIGNAL(fetchError(Feed* )),
91 this, TQ_SLOT(fetchError(Feed *)) );
92 connect( feed, TQ_SIGNAL(fetchDiscovery(Feed* )),
93 this, TQ_SLOT(fetchDiscovery(Feed *)) );
98 void AddFeedDialog::fetchCompleted(Feed *)
100 KDialogBase::slotOk();
103 void AddFeedDialog::fetchError(Feed *)
105 KMessageBox::error(
this, i18n(
"Feed not found from %1.").arg(feedURL));
106 KDialogBase::slotCancel();
109 void AddFeedDialog::fetchDiscovery(Feed *f)
111 widget->statusLabel->setText( i18n(
"Feed found, downloading...") );
115 void AddFeedDialog::textChanged(
const TQString& text)
117 enableButtonOK(!text.isEmpty());
122 #include "addfeeddialog.moc"