Fade between podcast info screens a bit more nicely
This commit is contained in:
parent
56cc4a9140
commit
3a88d8fcda
|
@ -22,6 +22,7 @@
|
|||
#include "ui_addpodcastdialog.h"
|
||||
#include "core/application.h"
|
||||
#include "ui/iconloader.h"
|
||||
#include "widgets/widgetfadehelper.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
|
@ -33,7 +34,10 @@ AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
|
|||
ui_->details->SetApplication(app);
|
||||
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()));
|
||||
|
||||
// Create an Add Podcast button
|
||||
add_button_ = new QPushButton(IconLoader::Load("list-add"), tr("Add Podcast"), this);
|
||||
|
@ -85,11 +89,16 @@ void AddPodcastDialog::ChangePodcast(const QModelIndex& current) {
|
|||
if (!current.isValid() ||
|
||||
current.data(PodcastDiscoveryModel::Role_Type).toInt() !=
|
||||
PodcastDiscoveryModel::Type_Podcast) {
|
||||
ui_->details->hide();
|
||||
ui_->details_scroll_area->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
ui_->details->show();
|
||||
if (ui_->details_scroll_area->isVisible()) {
|
||||
fader_->StartBlur();
|
||||
} else {
|
||||
ui_->details_scroll_area->show();
|
||||
}
|
||||
|
||||
ui_->details->SetPodcast(current.data(PodcastDiscoveryModel::Role_Podcast).value<Podcast>());
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
class AddPodcastPage;
|
||||
class Application;
|
||||
class WidgetFadeHelper;
|
||||
class Ui_AddPodcastDialog;
|
||||
|
||||
class QModelIndex;
|
||||
|
@ -49,6 +50,8 @@ private:
|
|||
|
||||
QList<AddPodcastPage*> pages_;
|
||||
QList<bool> page_is_busy_;
|
||||
|
||||
WidgetFadeHelper* fader_;
|
||||
};
|
||||
|
||||
#endif // ADDPODCASTDIALOG_H
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>887</width>
|
||||
<height>447</height>
|
||||
<width>941</width>
|
||||
<height>473</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
@ -56,7 +56,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="results_page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -110,13 +110,35 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PodcastInfoWidget" name="details">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<widget class="QScrollArea" name="details_scroll_area">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="PodcastInfoWidget" name="details">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>248</width>
|
||||
<height>418</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -142,7 +164,7 @@
|
|||
</customwidget>
|
||||
<customwidget>
|
||||
<class>PodcastInfoWidget</class>
|
||||
<extends>QFrame</extends>
|
||||
<extends>QWidget</extends>
|
||||
<header>podcasts/podcastinfowidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
|
|
|
@ -57,6 +57,7 @@ void GPodderTopTagsModel::fetchMore(const QModelIndex& parent) {
|
|||
}
|
||||
setData(parent, true, Role_HasLazyLoaded);
|
||||
|
||||
qLog(Debug) << "Fetching podcasts for" << parent.data().toString();
|
||||
mygpo::PodcastList* list =
|
||||
api_->podcastsOfTag(GPodderTopTagsPage::kMaxTagCount, parent.data().toString());
|
||||
|
||||
|
@ -68,6 +69,7 @@ void GPodderTopTagsModel::fetchMore(const QModelIndex& parent) {
|
|||
void GPodderTopTagsModel::PodcastsOfTagFinished(const QModelIndex& parent,
|
||||
mygpo::PodcastList* list) {
|
||||
list->deleteLater();
|
||||
qLog(Debug) << "Tag list finished";
|
||||
|
||||
QStandardItem* parent_item = itemFromIndex(parent);
|
||||
if (!parent_item)
|
||||
|
|
|
@ -21,17 +21,14 @@
|
|||
#include "covers/albumcoverloader.h"
|
||||
|
||||
PodcastInfoWidget::PodcastInfoWidget(QWidget* parent)
|
||||
: QFrame(parent),
|
||||
: QWidget(parent),
|
||||
ui_(new Ui_PodcastInfoWidget),
|
||||
app_(NULL),
|
||||
image_id_(0)
|
||||
{
|
||||
ui_->setupUi(this);
|
||||
|
||||
setFrameShape(QFrame::StyledPanel);
|
||||
|
||||
setMaximumWidth(220);
|
||||
cover_options_.desired_height_ = 200;
|
||||
cover_options_.desired_height_ = 180;
|
||||
ui_->image->setFixedSize(cover_options_.desired_height_,
|
||||
cover_options_.desired_height_);
|
||||
|
||||
|
@ -57,9 +54,26 @@ void PodcastInfoWidget::SetApplication(Application* app) {
|
|||
SLOT(ImageLoaded(quint64,QImage)));
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
void SetText(const QString& value, T* label, QLabel* buddy_label = NULL) {
|
||||
const bool visible = !value.isEmpty();
|
||||
|
||||
label->setVisible(visible);
|
||||
if (buddy_label) {
|
||||
buddy_label->setVisible(visible);
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
label->setText(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PodcastInfoWidget::SetPodcast(const Podcast& podcast) {
|
||||
if (image_id_ != 0) {
|
||||
if (image_id_) {
|
||||
app_->album_cover_loader()->CancelTask(image_id_);
|
||||
image_id_ = 0;
|
||||
}
|
||||
|
||||
podcast_ = podcast;
|
||||
|
@ -78,18 +92,9 @@ void PodcastInfoWidget::SetPodcast(const Podcast& podcast) {
|
|||
SetText(podcast.author(), ui_->author, ui_->author_label);
|
||||
SetText(podcast.owner_name(), ui_->owner, ui_->owner_label);
|
||||
SetText(podcast.link().toString(), ui_->website, ui_->website_label);
|
||||
}
|
||||
|
||||
void PodcastInfoWidget::SetText(const QString& value, QLabel* label, QLabel* buddy_label) {
|
||||
const bool visible = !value.isEmpty();
|
||||
|
||||
label->setVisible(visible);
|
||||
if (buddy_label) {
|
||||
buddy_label->setVisible(visible);
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
label->setText(value);
|
||||
if (!image_id_) {
|
||||
emit LoadingFinished();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,4 +108,6 @@ void PodcastInfoWidget::ImageLoaded(quint64 id, const QImage& image) {
|
|||
ui_->image->setPixmap(QPixmap::fromImage(image));
|
||||
ui_->image->show();
|
||||
}
|
||||
|
||||
emit LoadingFinished();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class Ui_PodcastInfoWidget;
|
|||
|
||||
class QLabel;
|
||||
|
||||
class PodcastInfoWidget : public QFrame {
|
||||
class PodcastInfoWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -39,12 +39,12 @@ public:
|
|||
|
||||
void SetPodcast(const Podcast& podcast);
|
||||
|
||||
signals:
|
||||
void LoadingFinished();
|
||||
|
||||
private slots:
|
||||
void ImageLoaded(quint64 id, const QImage& image);
|
||||
|
||||
private:
|
||||
void SetText(const QString& value, QLabel* label, QLabel* buddy_label = NULL);
|
||||
|
||||
private:
|
||||
Ui_PodcastInfoWidget* ui_;
|
||||
|
||||
|
|
|
@ -20,18 +20,58 @@
|
|||
|
||||
#description {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
QLineEdit {
|
||||
background: transparent;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="image">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="image">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="title">
|
||||
|
@ -55,6 +95,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="copyright_label">
|
||||
<property name="text">
|
||||
|
@ -75,19 +118,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="copyright">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="author_label">
|
||||
<property name="text">
|
||||
|
@ -98,32 +128,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="author">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="owner">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="website_label">
|
||||
<property name="text">
|
||||
|
@ -134,10 +138,43 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="copyright">
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="author">
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="owner">
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="website">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
<widget class="QLineEdit" name="website">
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "songinfofetcher.h"
|
||||
|
||||
class PrettyImageView;
|
||||
class WidgetFadeHelper;
|
||||
|
||||
class QScrollArea;
|
||||
class QTimeLine;
|
||||
|
|
|
@ -143,6 +143,7 @@ void WidgetFadeHelper::paintEvent(QPaintEvent* ) {
|
|||
|
||||
if (fade_timeline_->state() != QTimeLine::Running) {
|
||||
// We're fading in the blur
|
||||
p.drawPixmap(0, 0, original_pixmap_);
|
||||
p.setOpacity(blur_timeline_->currentValue());
|
||||
} else {
|
||||
// Fading out the blur into the new image
|
||||
|
|
Loading…
Reference in New Issue