mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-29 02:29:56 +01:00
Don't crash when double clicking in the Add Podcast dialog
This commit is contained in:
parent
9873ed083a
commit
c204dd31fb
@ -41,12 +41,14 @@ AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
|
||||
ui_->setupUi(this);
|
||||
ui_->details->SetApplication(app);
|
||||
ui_->results->SetExpandOnReset(false);
|
||||
ui_->results->SetAddOnDoubleClick(false);
|
||||
ui_->results_stack->setCurrentWidget(ui_->results_page);
|
||||
|
||||
fader_ = new WidgetFadeHelper(ui_->details_scroll_area);
|
||||
|
||||
connect(ui_->provider_list, SIGNAL(currentRowChanged(int)), SLOT(ChangePage(int)));
|
||||
connect(ui_->details, SIGNAL(LoadingFinished()), fader_, SLOT(StartFade()));
|
||||
connect(ui_->results, SIGNAL(doubleClicked(QModelIndex)), SLOT(PodcastDoubleClicked(QModelIndex)));
|
||||
|
||||
// Create Add and Remove Podcast buttons
|
||||
add_button_ = new QPushButton(IconLoader::Load("list-add"), tr("Add Podcast"), this);
|
||||
@ -178,6 +180,16 @@ void AddPodcastDialog::AddPodcast() {
|
||||
remove_button_->setEnabled(true);
|
||||
}
|
||||
|
||||
void AddPodcastDialog::PodcastDoubleClicked(const QModelIndex& index) {
|
||||
QVariant podcast_variant = index.data(PodcastDiscoveryModel::Role_Podcast);
|
||||
if (podcast_variant.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Podcast podcast = podcast_variant.value<Podcast>();
|
||||
app_->podcast_backend()->Subscribe(&podcast);
|
||||
}
|
||||
|
||||
void AddPodcastDialog::RemovePodcast() {
|
||||
app_->podcast_backend()->Unsubscribe(current_podcast_);
|
||||
current_podcast_.set_database_id(-1);
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
private slots:
|
||||
void OpenSettingsPage();
|
||||
void AddPodcast();
|
||||
void PodcastDoubleClicked(const QModelIndex& index);
|
||||
void RemovePodcast();
|
||||
void ChangePage(int index);
|
||||
void ChangePodcast(const QModelIndex& current);
|
||||
|
@ -27,6 +27,7 @@ AutoExpandingTreeView::AutoExpandingTreeView(QWidget *parent)
|
||||
: QTreeView(parent),
|
||||
auto_open_(true),
|
||||
expand_on_reset_(true),
|
||||
add_on_double_click_(true),
|
||||
ignore_next_click_(false)
|
||||
{
|
||||
setExpandsOnDoubleClick(false);
|
||||
@ -89,11 +90,13 @@ void AutoExpandingTreeView::ItemClicked(const QModelIndex& index) {
|
||||
void AutoExpandingTreeView::ItemDoubleClicked(const QModelIndex& index) {
|
||||
ignore_next_click_ = true;
|
||||
|
||||
QMimeData* data = model()->mimeData(QModelIndexList() << index);
|
||||
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
||||
mime_data->from_doubleclick_ = true;
|
||||
if (add_on_double_click_) {
|
||||
QMimeData* data = model()->mimeData(QModelIndexList() << index);
|
||||
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
||||
mime_data->from_doubleclick_ = true;
|
||||
}
|
||||
emit AddToPlaylistSignal(data);
|
||||
}
|
||||
emit AddToPlaylistSignal(data);
|
||||
}
|
||||
|
||||
void AutoExpandingTreeView::mousePressEvent(QMouseEvent* event) {
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
|
||||
void SetAutoOpen(bool v) { auto_open_ = v; }
|
||||
void SetExpandOnReset(bool v) { expand_on_reset_ = v; }
|
||||
void SetAddOnDoubleClick(bool v) { add_on_double_click_ = v; }
|
||||
|
||||
public slots:
|
||||
void RecursivelyExpand(const QModelIndex &index);
|
||||
@ -61,6 +62,7 @@ private:
|
||||
private:
|
||||
bool auto_open_;
|
||||
bool expand_on_reset_;
|
||||
bool add_on_double_click_;
|
||||
|
||||
bool ignore_next_click_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user