1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-29 02:29:56 +01:00

If there's a URL on the clipboard, fill in the textbox on the add by URL page automatically. Set focus on the query textbox when going to a page, and select the first podcast automatically when results arrive.

This commit is contained in:
David Sansome 2012-03-09 19:12:45 +00:00
parent e6640f1d10
commit 3cafaf52ae
8 changed files with 45 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include "ui_addpodcastbyurl.h"
#include "core/closure.h"
#include <QClipboard>
#include <QNetworkReply>
#include <QMessageBox>
@ -72,3 +73,19 @@ void AddPodcastByUrl::RequestFinished(PodcastUrlLoaderReply* reply) {
break;
}
}
void AddPodcastByUrl::Show() {
ui_->url->setFocus();
if (!ui_->url->text().isEmpty()) {
return;
}
const QClipboard* clipboard = QApplication::clipboard();
foreach (const QString& contents, QStringList() << clipboard->text(QClipboard::Clipboard)
<< clipboard->text(QClipboard::Selection)) {
if (contents.contains("://")) {
ui_->url->setText(contents);
return;
}
}
}

View File

@ -32,6 +32,8 @@ public:
AddPodcastByUrl(Application* app, QWidget* parent = 0);
~AddPodcastByUrl();
void Show();
private slots:
void GoClicked();
void RequestFinished(PodcastUrlLoaderReply* reply);

View File

@ -29,6 +29,7 @@
#include "widgets/widgetfadehelper.h"
#include <QPushButton>
#include <QTimer>
const char* AddPodcastDialog::kBbcOpmlUrl = "http://www.bbc.co.uk/podcasts.opml";
@ -153,6 +154,17 @@ void AddPodcastDialog::PageBusyChanged(bool busy) {
void AddPodcastDialog::CurrentPageBusyChanged(bool busy) {
ui_->results_stack->setCurrentWidget(busy ? ui_->busy_page : ui_->results_page);
ui_->stack->setDisabled(busy);
QTimer::singleShot(0, this, SLOT(SelectFirstPodcast()));
}
void AddPodcastDialog::SelectFirstPodcast() {
// Select the first item if there was one.
const PodcastDiscoveryModel* model = pages_[ui_->provider_list->currentRow()]->model();
if (model->rowCount() > 0) {
ui_->results->selectionModel()->setCurrentIndex(
model->index(0, 0), QItemSelectionModel::ClearAndSelect);
}
}
void AddPodcastDialog::AddPodcast() {

View File

@ -47,6 +47,8 @@ private slots:
void PageBusyChanged(bool busy);
void CurrentPageBusyChanged(bool busy);
void SelectFirstPodcast();
private:
void AddPage(AddPodcastPage* page);

View File

@ -87,3 +87,7 @@ void GPodderSearchPage::SearchFailed(mygpo::PodcastList* list) {
// Try doing the search again.
SearchClicked();
}
void GPodderSearchPage::Show() {
ui_->query->setFocus();
}

View File

@ -36,6 +36,8 @@ public:
GPodderSearchPage(Application* app, QWidget* parent = 0);
~GPodderSearchPage();
void Show();
private slots:
void SearchClicked();
void SearchFinished(mygpo::PodcastList* list);

View File

@ -101,3 +101,7 @@ void ITunesSearchPage::SearchFinished(QNetworkReply* reply) {
model()->appendRow(model()->CreatePodcastItem(podcast));
}
}
void ITunesSearchPage::Show() {
ui_->query->setFocus();
}

View File

@ -32,6 +32,8 @@ public:
ITunesSearchPage(Application* app, QWidget* parent);
~ITunesSearchPage();
void Show();
static const char* kUrlBase;
private slots: