smartplaylists: Move classes to own files

This commit is contained in:
Jonas Kvinge 2024-08-25 05:49:41 +02:00
parent 20ef621a20
commit bd39e7cb0d
17 changed files with 551 additions and 212 deletions

View File

@ -148,15 +148,20 @@ set(SOURCES
smartplaylists/playlistgeneratormimedata.cpp
smartplaylists/playlistquerygenerator.cpp
smartplaylists/smartplaylistquerywizardplugin.cpp
smartplaylists/smartplaylistquerywizardpluginsortpage.cpp
smartplaylists/smartplaylistquerywizardpluginsearchpage.cpp
smartplaylists/smartplaylistsearch.cpp
smartplaylists/smartplaylistsearchpreview.cpp
smartplaylists/smartplaylistsearchterm.cpp
smartplaylists/smartplaylistsearchtermwidget.cpp
smartplaylists/smartplaylistsearchtermwidgetoverlay.cpp
smartplaylists/smartplaylistsmodel.cpp
smartplaylists/smartplaylistsviewcontainer.cpp
smartplaylists/smartplaylistsview.cpp
smartplaylists/smartplaylistwizard.cpp
smartplaylists/smartplaylistwizardplugin.cpp
smartplaylists/smartplaylistwizardtypepage.cpp
smartplaylists/smartplaylistwizardfinishpage.cpp
covermanager/albumcovermanager.cpp
covermanager/albumcovermanagerlist.cpp
@ -409,13 +414,18 @@ set(HEADERS
smartplaylists/playlistquerygenerator.h
smartplaylists/playlistgeneratormimedata.h
smartplaylists/smartplaylistquerywizardplugin.h
smartplaylists/smartplaylistquerywizardpluginsortpage.h
smartplaylists/smartplaylistquerywizardpluginsearchpage.h
smartplaylists/smartplaylistsearchpreview.h
smartplaylists/smartplaylistsearchtermwidget.h
smartplaylists/smartplaylistsearchtermwidgetoverlay.h
smartplaylists/smartplaylistsmodel.h
smartplaylists/smartplaylistsviewcontainer.h
smartplaylists/smartplaylistsview.h
smartplaylists/smartplaylistwizard.h
smartplaylists/smartplaylistwizardplugin.h
smartplaylists/smartplaylistwizardtypepage.h
smartplaylists/smartplaylistwizardfinishpage.h
covermanager/albumcovermanager.h
covermanager/albumcovermanagerlist.h

View File

@ -34,6 +34,8 @@
#include "core/shared_ptr.h"
#include "playlistquerygenerator.h"
#include "smartplaylistquerywizardplugin.h"
#include "smartplaylistquerywizardpluginsearchpage.h"
#include "smartplaylistquerywizardpluginsortpage.h"
#include "smartplaylistsearchtermwidget.h"
#include "ui_smartplaylistquerysearchpage.h"
#include "ui_smartplaylistquerysortpage.h"
@ -41,51 +43,6 @@
using std::make_unique;
using std::make_shared;
class SmartPlaylistQueryWizardPlugin::SearchPage : public QWizardPage { // clazy:exclude=missing-qobject-macro
friend class SmartPlaylistQueryWizardPlugin;
public:
explicit SearchPage(QWidget *parent = nullptr)
: QWizardPage(parent),
layout_(nullptr),
new_term_(nullptr),
preview_(nullptr),
ui_(new Ui_SmartPlaylistQuerySearchPage) {
ui_->setupUi(this);
}
bool isComplete() const override {
if (ui_->type->currentIndex() == 2) { // All songs
return true;
}
return !std::any_of(terms_.begin(), terms_.end(), [](SmartPlaylistSearchTermWidget *widget) { return !widget->Term().is_valid(); });
}
QVBoxLayout *layout_;
QList<SmartPlaylistSearchTermWidget*> terms_;
SmartPlaylistSearchTermWidget *new_term_;
SmartPlaylistSearchPreview *preview_;
ScopedPtr<Ui_SmartPlaylistQuerySearchPage> ui_;
};
class SmartPlaylistQueryWizardPlugin::SortPage : public QWizardPage { // clazy:exclude=missing-qobject-macro
public:
SortPage(SmartPlaylistQueryWizardPlugin *plugin, QWidget *parent, int next_id)
: QWizardPage(parent), next_id_(next_id), plugin_(plugin) {}
void showEvent(QShowEvent*) override { plugin_->UpdateSortPreview(); }
int nextId() const override { return next_id_; }
int next_id_;
SmartPlaylistQueryWizardPlugin *plugin_;
};
SmartPlaylistQueryWizardPlugin::SmartPlaylistQueryWizardPlugin(Application *app, SharedPtr<CollectionBackend> collection_backend, QObject *parent)
: SmartPlaylistWizardPlugin(app, collection_backend, parent),
search_page_(nullptr),
@ -102,9 +59,9 @@ QString SmartPlaylistQueryWizardPlugin::description() const {
int SmartPlaylistQueryWizardPlugin::CreatePages(QWizard *wizard, int finish_page_id) {
// Create the UI
search_page_ = new SearchPage(wizard);
search_page_ = new SmartPlaylistQueryWizardPluginSearchPage(wizard);
QWizardPage *sort_page = new SortPage(this, wizard, finish_page_id);
QWizardPage *sort_page = new SmartPlaylistQueryWizardPluginSortPage(this, wizard, finish_page_id);
sort_ui_ = make_unique<Ui_SmartPlaylistQuerySortPage>();
sort_ui_->setupUi(sort_page);

View File

@ -23,7 +23,6 @@
#include "config.h"
#include <QObject>
#include <QString>
#include "core/scoped_ptr.h"
@ -35,6 +34,7 @@ class QWizard;
class CollectionBackend;
class SmartPlaylistSearch;
class SmartPlaylistQueryWizardPluginSearchPage;
class Ui_SmartPlaylistQuerySortPage;
class SmartPlaylistQueryWizardPlugin : public SmartPlaylistWizardPlugin {
@ -53,6 +53,9 @@ class SmartPlaylistQueryWizardPlugin : public SmartPlaylistWizardPlugin {
void SetGenerator(PlaylistGeneratorPtr) override;
PlaylistGeneratorPtr CreateGenerator() const override;
public Q_SLOTS:
void UpdateSortPreview();
private Q_SLOTS:
void AddSearchTerm();
void RemoveSearchTerm();
@ -60,19 +63,15 @@ class SmartPlaylistQueryWizardPlugin : public SmartPlaylistWizardPlugin {
void SearchTypeChanged();
void UpdateTermPreview();
void UpdateSortPreview();
void UpdateSortOrder();
void MoveTermListToBottom(const int min, const int max);
private:
class SearchPage;
class SortPage;
SmartPlaylistSearch MakeSearch() const;
ScopedPtr<Ui_SmartPlaylistQuerySortPage> sort_ui_;
SearchPage *search_page_;
SmartPlaylistQueryWizardPluginSearchPage *search_page_;
int previous_scrollarea_max_;
};

View File

@ -0,0 +1,45 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <algorithm>
#include "smartplaylistquerywizardpluginsearchpage.h"
#include "smartplaylistsearchtermwidget.h"
#include "ui_smartplaylistquerysearchpage.h"
SmartPlaylistQueryWizardPluginSearchPage::SmartPlaylistQueryWizardPluginSearchPage(QWidget *parent)
: QWizardPage(parent),
layout_(nullptr),
new_term_(nullptr),
preview_(nullptr),
ui_(new Ui_SmartPlaylistQuerySearchPage) {
ui_->setupUi(this);
}
bool SmartPlaylistQueryWizardPluginSearchPage::isComplete() const {
if (ui_->type->currentIndex() == 2) { // All songs
return true;
}
return !std::any_of(terms_.begin(), terms_.end(), [](SmartPlaylistSearchTermWidget *widget) { return !widget->Term().is_valid(); });
}

View File

@ -0,0 +1,55 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SMARTPLAYLISTQUERYWIZARDPLUGINSEARCHPAGE_H
#define SMARTPLAYLISTQUERYWIZARDPLUGINSEARCHPAGE_H
#include <QWizardPage>
#include "core/scoped_ptr.h"
#include "ui_smartplaylistquerysearchpage.h"
class QVBoxLayout;
class SmartPlaylistSearchTermWidget;
class SmartPlaylistSearchPreview;
class SmartPlaylistQueryWizardPluginSearchPage : public QWizardPage {
Q_OBJECT
friend class SmartPlaylistQueryWizardPlugin;
public:
explicit SmartPlaylistQueryWizardPluginSearchPage(QWidget *parent = nullptr);
bool isComplete() const override;
private:
QVBoxLayout *layout_;
QList<SmartPlaylistSearchTermWidget*> terms_;
SmartPlaylistSearchTermWidget *new_term_;
SmartPlaylistSearchPreview *preview_;
ScopedPtr<Ui_SmartPlaylistQuerySearchPage> ui_;
};
#endif // SMARTPLAYLISTQUERYWIZARDPLUGINSEARCHPAGE_H

View File

@ -0,0 +1,35 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "smartplaylistquerywizardplugin.h"
#include "smartplaylistquerywizardpluginsortpage.h"
SmartPlaylistQueryWizardPluginSortPage::SmartPlaylistQueryWizardPluginSortPage(SmartPlaylistQueryWizardPlugin *plugin, QWidget *parent, const int next_id)
: QWizardPage(parent), next_id_(next_id), plugin_(plugin) {}
void SmartPlaylistQueryWizardPluginSortPage::showEvent(QShowEvent *e) {
Q_UNUSED(e)
plugin_->UpdateSortPreview();
}
int SmartPlaylistQueryWizardPluginSortPage::nextId() const { return next_id_; }

View File

@ -0,0 +1,45 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SMARTPLAYLISTQUERYWIZARDPLUGINSORTPAGE_H
#define SMARTPLAYLISTQUERYWIZARDPLUGINSORTPAGE_H
#include <QWizardPage>
class QShowEvent;
class SmartPlaylistQueryWizardPlugin;
class SmartPlaylistQueryWizardPluginSortPage : public QWizardPage {
Q_OBJECT
public:
explicit SmartPlaylistQueryWizardPluginSortPage(SmartPlaylistQueryWizardPlugin *plugin, QWidget *parent, const int next_id);
void showEvent(QShowEvent *e) override;
int nextId() const override;
private:
int next_id_;
SmartPlaylistQueryWizardPlugin *plugin_;
};
#endif // SMARTPLAYLISTQUERYWIZARDPLUGINSORTPAGE_H

View File

@ -20,19 +20,16 @@
#include "config.h"
#include <QWidget>
#include <QIODevice>
#include <QFile>
#include <QMessageBox>
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include <QPalette>
#include <QDateTime>
#include <QMetaObject>
#include <QPropertyAnimation>
#include <QKeyEvent>
#include <QEvent>
#include <QEnterEvent>
#include <QShowEvent>
#include <QResizeEvent>
#include "core/shared_ptr.h"
#include "core/iconloader.h"
@ -41,39 +38,9 @@
#include "playlist/playlistdelegates.h"
#include "smartplaylistsearchterm.h"
#include "smartplaylistsearchtermwidget.h"
#include "smartplaylistsearchtermwidgetoverlay.h"
#include "ui_smartplaylistsearchtermwidget.h"
// Exported by QtGui
void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
class SmartPlaylistSearchTermWidget::Overlay : public QWidget { // clazy:exclude=missing-qobject-macro
public:
explicit Overlay(SmartPlaylistSearchTermWidget *parent);
void Grab();
void SetOpacity(const float opacity);
float opacity() const { return opacity_; }
static const int kSpacing;
static const int kIconSize;
protected:
void paintEvent(QPaintEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void keyReleaseEvent(QKeyEvent *e) override;
private:
SmartPlaylistSearchTermWidget *parent_;
float opacity_;
QString text_;
QPixmap pixmap_;
QPixmap icon_;
};
const int SmartPlaylistSearchTermWidget::Overlay::kSpacing = 6;
const int SmartPlaylistSearchTermWidget::Overlay::kIconSize = 22;
SmartPlaylistSearchTermWidget::SmartPlaylistSearchTermWidget(SharedPtr<CollectionBackend> collection_backend, QWidget *parent)
: QWidget(parent),
ui_(new Ui_SmartPlaylistSearchTermWidget),
@ -259,17 +226,19 @@ void SmartPlaylistSearchTermWidget::SetActive(bool active) {
ui_->container->setEnabled(active);
if (!active) {
overlay_ = new Overlay(this);
overlay_ = new SmartPlaylistSearchTermWidgetOverlay(this);
}
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void SmartPlaylistSearchTermWidget::enterEvent(QEnterEvent*) {
void SmartPlaylistSearchTermWidget::enterEvent(QEnterEvent *e) {
#else
void SmartPlaylistSearchTermWidget::enterEvent(QEvent*) {
void SmartPlaylistSearchTermWidget::enterEvent(QEvent *e) {
#endif
Q_UNUSED(e)
if (!overlay_ || !isEnabled()) return;
animation_->stop();
@ -279,7 +248,9 @@ void SmartPlaylistSearchTermWidget::enterEvent(QEvent*) {
}
void SmartPlaylistSearchTermWidget::leaveEvent(QEvent*) {
void SmartPlaylistSearchTermWidget::leaveEvent(QEvent *e) {
Q_UNUSED(e);
if (!overlay_) return;
@ -293,6 +264,7 @@ void SmartPlaylistSearchTermWidget::leaveEvent(QEvent*) {
void SmartPlaylistSearchTermWidget::resizeEvent(QResizeEvent *e) {
QWidget::resizeEvent(e);
if (overlay_ && overlay_->isVisible()) {
QMetaObject::invokeMethod(this, &SmartPlaylistSearchTermWidget::Grab);
}
@ -425,86 +397,3 @@ void SmartPlaylistSearchTermWidget::RelativeValueChanged() {
Q_EMIT Changed();
}
SmartPlaylistSearchTermWidget::Overlay::Overlay(SmartPlaylistSearchTermWidget *parent)
: QWidget(parent),
parent_(parent),
opacity_(0.0),
text_(tr("Add search term")),
icon_(IconLoader::Load(QStringLiteral("list-add")).pixmap(kIconSize)) {
raise();
setFocusPolicy(Qt::TabFocus);
}
void SmartPlaylistSearchTermWidget::Overlay::SetOpacity(const float opacity) {
opacity_ = opacity;
update();
}
void SmartPlaylistSearchTermWidget::Overlay::Grab() {
hide();
// Take a "screenshot" of the window
QPixmap pixmap = parent_->grab();
QImage image = pixmap.toImage();
// Blur it
QImage blurred(image.size(), QImage::Format_ARGB32_Premultiplied);
blurred.fill(Qt::transparent);
QPainter blur_painter(&blurred);
qt_blurImage(&blur_painter, image, 10.0, true, false);
blur_painter.end();
pixmap_ = QPixmap::fromImage(blurred);
resize(parent_->size());
show();
update();
}
void SmartPlaylistSearchTermWidget::Overlay::paintEvent(QPaintEvent*) {
QPainter p(this);
// Background
p.fillRect(rect(), palette().window());
// Blurred parent widget
p.setOpacity(0.25 + opacity_ * 0.25);
p.drawPixmap(0, 0, pixmap_);
// Draw a frame
p.setOpacity(1.0);
p.setPen(palette().color(QPalette::Mid));
p.setRenderHint(QPainter::Antialiasing);
p.drawRoundedRect(rect(), 5, 5);
// Geometry
const QSize contents_size(kIconSize + kSpacing + fontMetrics().horizontalAdvance(text_), qMax(kIconSize, fontMetrics().height()));
const QRect contents(QPoint((width() - contents_size.width()) / 2, (height() - contents_size.height()) / 2), contents_size);
const QRect icon(contents.topLeft(), QSize(kIconSize, kIconSize));
const QRect text(icon.right() + kSpacing, icon.top(), contents.width() - kSpacing - kIconSize, contents.height());
// Icon and text
p.setPen(palette().color(QPalette::Text));
p.drawPixmap(icon, icon_);
p.drawText(text, Qt::TextDontClip | Qt::AlignVCenter, text_); // NOLINT(bugprone-suspicious-enum-usage)
}
void SmartPlaylistSearchTermWidget::Overlay::mouseReleaseEvent(QMouseEvent*) {
Q_EMIT parent_->Clicked();
}
void SmartPlaylistSearchTermWidget::Overlay::keyReleaseEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Space) Q_EMIT parent_->Clicked();
}

View File

@ -37,6 +37,7 @@ class QResizeEvent;
class CollectionBackend;
class Ui_SmartPlaylistSearchTermWidget;
class SmartPlaylistSearchTermWidgetOverlay;
class SmartPlaylistSearchTermWidget : public QWidget {
Q_OBJECT
@ -78,13 +79,10 @@ class SmartPlaylistSearchTermWidget : public QWidget {
void Grab();
private:
class Overlay;
friend class Overlay;
Ui_SmartPlaylistSearchTermWidget *ui_;
SharedPtr<CollectionBackend> collection_backend_;
Overlay *overlay_;
SmartPlaylistSearchTermWidgetOverlay *overlay_;
QPropertyAnimation *animation_;
bool active_;
bool initialized_;

View File

@ -0,0 +1,130 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <QString>
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include <QPalette>
#include <QKeyEvent>
#include <QMouseEvent>
#include "core/iconloader.h"
#include "smartplaylistsearchterm.h"
#include "smartplaylistsearchtermwidget.h"
#include "smartplaylistsearchtermwidgetoverlay.h"
const int SmartPlaylistSearchTermWidgetOverlay::kSpacing = 6;
const int SmartPlaylistSearchTermWidgetOverlay::kIconSize = 22;
// Exported by QtGui
void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
SmartPlaylistSearchTermWidgetOverlay::SmartPlaylistSearchTermWidgetOverlay(SmartPlaylistSearchTermWidget *parent)
: QWidget(parent),
parent_(parent),
opacity_(0.0),
text_(tr("Add search term")),
icon_(IconLoader::Load(QStringLiteral("list-add")).pixmap(kIconSize)) {
raise();
setFocusPolicy(Qt::TabFocus);
}
void SmartPlaylistSearchTermWidgetOverlay::Grab() {
hide();
// Take a "screenshot" of the window
QPixmap pixmap = parent_->grab();
QImage image = pixmap.toImage();
// Blur it
QImage blurred(image.size(), QImage::Format_ARGB32_Premultiplied);
blurred.fill(Qt::transparent);
QPainter blur_painter(&blurred);
qt_blurImage(&blur_painter, image, 10.0, true, false);
blur_painter.end();
pixmap_ = QPixmap::fromImage(blurred);
resize(parent_->size());
show();
update();
}
void SmartPlaylistSearchTermWidgetOverlay::SetOpacity(const float opacity) {
opacity_ = opacity;
update();
}
void SmartPlaylistSearchTermWidgetOverlay::paintEvent(QPaintEvent*) {
QPainter p(this);
// Background
p.fillRect(rect(), palette().window());
// Blurred parent widget
p.setOpacity(0.25 + opacity_ * 0.25);
p.drawPixmap(0, 0, pixmap_);
// Draw a frame
p.setOpacity(1.0);
p.setPen(palette().color(QPalette::Mid));
p.setRenderHint(QPainter::Antialiasing);
p.drawRoundedRect(rect(), 5, 5);
// Geometry
const QSize contents_size(kIconSize + kSpacing + fontMetrics().horizontalAdvance(text_), qMax(kIconSize, fontMetrics().height()));
const QRect contents(QPoint((width() - contents_size.width()) / 2, (height() - contents_size.height()) / 2), contents_size);
const QRect icon(contents.topLeft(), QSize(kIconSize, kIconSize));
const QRect text(icon.right() + kSpacing, icon.top(), contents.width() - kSpacing - kIconSize, contents.height());
// Icon and text
p.setPen(palette().color(QPalette::Text));
p.drawPixmap(icon, icon_);
p.drawText(text, Qt::TextDontClip | Qt::AlignVCenter, text_); // NOLINT(bugprone-suspicious-enum-usage)
}
void SmartPlaylistSearchTermWidgetOverlay::mouseReleaseEvent(QMouseEvent *e) {
Q_UNUSED(e)
Q_EMIT parent_->Clicked();
}
void SmartPlaylistSearchTermWidgetOverlay::keyReleaseEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Space) {
Q_EMIT parent_->Clicked();
}
}
float SmartPlaylistSearchTermWidgetOverlay::opacity() const { return opacity_; }

View File

@ -0,0 +1,61 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SMARTPLAYLISTSEARCHTERMWIDGETOVERLAY_H
#define SMARTPLAYLISTSEARCHTERMWIDGETOVERLAY_H
#include <QWidget>
#include <QString>
#include <QPixmap>
class QPaintEvent;
class QMouseEvent;
class QKeyEvent;
class SmartPlaylistSearchTermWidget;
class SmartPlaylistSearchTermWidgetOverlay : public QWidget {
Q_OBJECT
public:
explicit SmartPlaylistSearchTermWidgetOverlay(SmartPlaylistSearchTermWidget *parent);
static const int kSpacing;
static const int kIconSize;
void Grab();
void SetOpacity(const float opacity);
float opacity() const;
protected:
void paintEvent(QPaintEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void keyReleaseEvent(QKeyEvent *e) override;
private:
SmartPlaylistSearchTermWidget *parent_;
float opacity_;
QString text_;
QPixmap pixmap_;
QPixmap icon_;
};
#endif // SMARTPLAYLISTSEARCHTERMWIDGETOVERLAY_H

View File

@ -34,38 +34,16 @@
#include "smartplaylistquerywizardplugin.h"
#include "smartplaylistwizard.h"
#include "smartplaylistwizardplugin.h"
#include "smartplaylistwizardtypepage.h"
#include "smartplaylistwizardfinishpage.h"
#include "ui_smartplaylistwizardfinishpage.h"
class SmartPlaylistWizard::TypePage : public QWizardPage { // clazy:exclude=missing-qobject-macro
public:
explicit TypePage(QWidget *parent) : QWizardPage(parent), next_id_(-1) {}
int nextId() const override { return next_id_; }
int next_id_;
};
class SmartPlaylistWizard::FinishPage : public QWizardPage { // clazy:exclude=missing-qobject-macro
public:
explicit FinishPage(QWidget *parent) : QWizardPage(parent), ui_(new Ui_SmartPlaylistWizardFinishPage) {
ui_->setupUi(this);
QObject::connect(ui_->name, &QLineEdit::textChanged, this, &SmartPlaylistWizard::FinishPage::completeChanged);
}
~FinishPage() override { delete ui_; }
int nextId() const override { return -1; }
bool isComplete() const override { return !ui_->name->text().isEmpty(); }
Ui_SmartPlaylistWizardFinishPage *ui_;
};
SmartPlaylistWizard::SmartPlaylistWizard(Application *app, SharedPtr<CollectionBackend> collection_backend, QWidget *parent)
: QWizard(parent),
app_(app),
collection_backend_(collection_backend),
type_page_(new TypePage(this)),
finish_page_(new FinishPage(this)),
type_page_(new SmartPlaylistWizardTypePage(this)),
finish_page_(new SmartPlaylistWizardFinishPage(this)),
type_index_(-1) {
setWindowIcon(IconLoader::Load(QStringLiteral("strawberry")));

View File

@ -32,6 +32,8 @@
class Application;
class CollectionBackend;
class SmartPlaylistWizardPlugin;
class SmartPlaylistWizardTypePage;
class SmartPlaylistWizardFinishPage;
class SmartPlaylistWizard : public QWizard {
Q_OBJECT
@ -47,9 +49,6 @@ class SmartPlaylistWizard : public QWizard {
void initializePage(const int id) override;
private:
class TypePage;
class FinishPage;
void AddPlugin(SmartPlaylistWizardPlugin *plugin);
private Q_SLOTS:
@ -58,8 +57,8 @@ class SmartPlaylistWizard : public QWizard {
private:
Application *app_;
SharedPtr<CollectionBackend> collection_backend_;
TypePage *type_page_;
FinishPage *finish_page_;
SmartPlaylistWizardTypePage *type_page_;
SmartPlaylistWizardFinishPage *finish_page_;
int finish_id_;
int type_index_;

View File

@ -0,0 +1,34 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "smartplaylistwizardfinishpage.h"
#include "ui_smartplaylistwizardfinishpage.h"
SmartPlaylistWizardFinishPage::SmartPlaylistWizardFinishPage(QWidget *parent) : QWizardPage(parent), ui_(new Ui_SmartPlaylistWizardFinishPage) {
ui_->setupUi(this);
QObject::connect(ui_->name, &QLineEdit::textChanged, this, &SmartPlaylistWizardFinishPage::completeChanged);
}
SmartPlaylistWizardFinishPage::~SmartPlaylistWizardFinishPage() { delete ui_; }
int SmartPlaylistWizardFinishPage::nextId() const { return -1; }
bool SmartPlaylistWizardFinishPage::isComplete() const { return !ui_->name->text().isEmpty(); }

View File

@ -0,0 +1,42 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SMARTPLAYLISTWIZARDFINISHPAGE_H
#define SMARTPLAYLISTWIZARDFINISHPAGE_H
#include <QWizardPage>
class Ui_SmartPlaylistWizardFinishPage;
class SmartPlaylistWizardFinishPage : public QWizardPage {
Q_OBJECT
public:
explicit SmartPlaylistWizardFinishPage(QWidget *parent);
~SmartPlaylistWizardFinishPage() override;
int nextId() const override;
bool isComplete() const override;
Ui_SmartPlaylistWizardFinishPage *ui_;
};
#endif // SMARTPLAYLISTWIZARDFINISHPAGE_H

View File

@ -0,0 +1,25 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "smartplaylistwizardtypepage.h"
SmartPlaylistWizardTypePage::SmartPlaylistWizardTypePage(QWidget *parent) : QWizardPage(parent), next_id_(-1) {}
int SmartPlaylistWizardTypePage::nextId() const { return next_id_; }

View File

@ -0,0 +1,37 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SMARTPLAYLISTWIZARDTYPEPAGE_H
#define SMARTPLAYLISTWIZARDTYPEPAGE_H
#include <QWizardPage>
class SmartPlaylistWizardTypePage : public QWizardPage {
Q_OBJECT
public:
explicit SmartPlaylistWizardTypePage(QWidget *parent);
int nextId() const override;
int next_id_;
};
#endif // SMARTPLAYLISTWIZARDTYPEPAGE_H