Add an "Open OPML file" button to the Add Podcast dialog
This commit is contained in:
parent
45a8b3af59
commit
3e410021a5
|
@ -28,6 +28,7 @@
|
|||
#include "ui/iconloader.h"
|
||||
#include "widgets/widgetfadehelper.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
|
||||
|
@ -36,7 +37,8 @@ const char* AddPodcastDialog::kBbcOpmlUrl = "http://www.bbc.co.uk/podcasts.opml"
|
|||
AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
|
||||
: QDialog(parent),
|
||||
app_(app),
|
||||
ui_(new Ui_AddPodcastDialog)
|
||||
ui_(new Ui_AddPodcastDialog),
|
||||
last_opml_path_(QDir::homePath())
|
||||
{
|
||||
ui_->setupUi(this);
|
||||
ui_->details->SetApplication(app);
|
||||
|
@ -66,6 +68,12 @@ AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
|
|||
connect(settings_button, SIGNAL(clicked()), SLOT(OpenSettingsPage()));
|
||||
ui_->button_box->addButton(settings_button, QDialogButtonBox::ResetRole);
|
||||
|
||||
// Create an Open OPML file button
|
||||
QPushButton* open_opml_button = new QPushButton(
|
||||
IconLoader::Load("document-open"), tr("Open OPML file..."), this);
|
||||
connect(open_opml_button, SIGNAL(clicked()), this, SLOT(OpenOPMLFile()));
|
||||
ui_->button_box->addButton(open_opml_button, QDialogButtonBox::ResetRole);
|
||||
|
||||
// Add providers
|
||||
by_url_page_ = new AddPodcastByUrl(app, this);
|
||||
AddPage(by_url_page_);
|
||||
|
@ -216,3 +224,17 @@ void AddPodcastDialog::RemovePodcast() {
|
|||
void AddPodcastDialog::OpenSettingsPage() {
|
||||
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Podcasts);
|
||||
}
|
||||
|
||||
void AddPodcastDialog::OpenOPMLFile() {
|
||||
const QString filename = QFileDialog::getOpenFileName(
|
||||
this, tr("Open OPML file"), last_opml_path_, "OPML files (*.opml)");
|
||||
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
last_opml_path_ = filename;
|
||||
|
||||
by_url_page_->SetUrlAndGo(QUrl::fromLocalFile(last_opml_path_));
|
||||
ChangePage(ui_->stack->indexOf(by_url_page_));
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@ private slots:
|
|||
|
||||
void SelectFirstPodcast();
|
||||
|
||||
void OpenOPMLFile();
|
||||
|
||||
private:
|
||||
void AddPage(AddPodcastPage* page);
|
||||
|
||||
|
@ -76,6 +78,8 @@ private:
|
|||
WidgetFadeHelper* fader_;
|
||||
|
||||
Podcast current_podcast_;
|
||||
|
||||
QString last_opml_path_;
|
||||
};
|
||||
|
||||
#endif // ADDPODCASTDIALOG_H
|
||||
|
|
|
@ -34,6 +34,11 @@ PodcastParser::PodcastParser() {
|
|||
}
|
||||
|
||||
bool PodcastParser::SupportsContentType(const QString& content_type) const {
|
||||
if (content_type.isEmpty()) {
|
||||
// Why not have a go.
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (const QString& mime_type, supported_mime_types()) {
|
||||
if (content_type.contains(mime_type)) {
|
||||
return true;
|
||||
|
|
|
@ -143,7 +143,9 @@ void PodcastUrlLoader::RequestFinished(RequestState* state, QNetworkReply* reply
|
|||
return;
|
||||
}
|
||||
|
||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
|
||||
const QVariant http_status =
|
||||
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
||||
if (http_status.isValid() && http_status.toInt() != 200) {
|
||||
SendErrorAndDelete(QString("HTTP %1: %2").arg(
|
||||
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString(),
|
||||
reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString()), state);
|
||||
|
|
Loading…
Reference in New Issue