mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-24 22:48:31 +01:00
ContextView: Remove engine and device
This commit is contained in:
parent
cb8a0b6853
commit
a1dbbba1a1
@ -51,13 +51,9 @@
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/song.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "utilities/strutils.h"
|
||||
#include "utilities/timeutils.h"
|
||||
#include "widgets/resizabletextedit.h"
|
||||
#include "engine/enginebase.h"
|
||||
#include "engine/devicefinders.h"
|
||||
#include "engine/devicefinder.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "collection/collectionquery.h"
|
||||
#include "collection/collectionview.h"
|
||||
@ -79,7 +75,6 @@ ContextView::ContextView(QWidget *parent)
|
||||
menu_options_(new QMenu(this)),
|
||||
action_show_album_(nullptr),
|
||||
action_show_data_(nullptr),
|
||||
action_show_output_(nullptr),
|
||||
action_show_lyrics_(nullptr),
|
||||
action_search_lyrics_(nullptr),
|
||||
layout_container_(new QVBoxLayout()),
|
||||
@ -95,11 +90,8 @@ ContextView::ContextView(QWidget *parent)
|
||||
layout_play_(new QVBoxLayout()),
|
||||
label_stop_summary_(new QLabel(this)),
|
||||
widget_play_data_(new QWidget(this)),
|
||||
widget_play_output_(new QWidget(this)),
|
||||
layout_play_data_(new QGridLayout()),
|
||||
layout_play_output_(new QGridLayout()),
|
||||
textedit_play_lyrics_(new ResizableTextEdit(this)),
|
||||
spacer_play_output_(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed)),
|
||||
spacer_play_data_(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed)),
|
||||
label_filetype_title_(new QLabel(this)),
|
||||
label_length_title_(new QLabel(this)),
|
||||
@ -111,14 +103,6 @@ ContextView::ContextView(QWidget *parent)
|
||||
label_samplerate_(new QLabel(this)),
|
||||
label_bitdepth_(new QLabel(this)),
|
||||
label_bitrate_(new QLabel(this)),
|
||||
label_device_title_(new QLabel(this)),
|
||||
label_engine_title_(new QLabel(this)),
|
||||
label_device_space_(new QLabel(this)),
|
||||
label_engine_space_(new QLabel(this)),
|
||||
label_device_(new QLabel(this)),
|
||||
label_engine_(new QLabel(this)),
|
||||
label_device_icon_(new QLabel(this)),
|
||||
label_engine_icon_(new QLabel(this)),
|
||||
lyrics_tried_(false),
|
||||
lyrics_id_(-1) {
|
||||
|
||||
@ -171,36 +155,6 @@ ContextView::ContextView(QWidget *parent)
|
||||
|
||||
// Playing
|
||||
|
||||
label_engine_title_->setText(tr("Engine"));
|
||||
label_device_title_->setText(tr("Device"));
|
||||
label_engine_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
label_device_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
label_engine_space_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
label_device_space_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
label_engine_space_->setMinimumWidth(24);
|
||||
label_device_space_->setMinimumWidth(24);
|
||||
label_engine_icon_->setMinimumSize(32, 32);
|
||||
label_device_icon_->setMaximumSize(32, 32);
|
||||
label_engine_icon_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
label_device_icon_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
label_engine_->setWordWrap(true);
|
||||
label_device_->setWordWrap(true);
|
||||
|
||||
layout_play_output_->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
layout_play_output_->addWidget(label_engine_title_, 0, 0);
|
||||
layout_play_output_->addWidget(label_engine_space_, 0, 1);
|
||||
layout_play_output_->addWidget(label_engine_icon_, 0, 2);
|
||||
layout_play_output_->addWidget(label_engine_, 0, 3);
|
||||
|
||||
layout_play_output_->addWidget(label_device_title_, 1, 0);
|
||||
layout_play_output_->addWidget(label_device_space_, 1, 1);
|
||||
layout_play_output_->addWidget(label_device_icon_, 1, 2);
|
||||
layout_play_output_->addWidget(label_device_, 1, 3);
|
||||
|
||||
widget_play_output_->setLayout(layout_play_output_);
|
||||
|
||||
label_filetype_title_->setText(tr("Filetype"));
|
||||
label_length_title_->setText(tr("Length"));
|
||||
label_samplerate_title_->setText(tr("Samplerate"));
|
||||
@ -238,26 +192,18 @@ ContextView::ContextView(QWidget *parent)
|
||||
textedit_play_lyrics_->hide();
|
||||
|
||||
layout_play_->setContentsMargins(0, 0, 0, 0);
|
||||
layout_play_->addWidget(widget_play_output_);
|
||||
layout_play_->addSpacerItem(spacer_play_output_);
|
||||
layout_play_->addWidget(widget_play_data_);
|
||||
layout_play_->addSpacerItem(spacer_play_data_);
|
||||
layout_play_->addWidget(textedit_play_lyrics_);
|
||||
layout_play_->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||
|
||||
labels_play_ << label_engine_title_
|
||||
<< label_device_title_
|
||||
<< label_filetype_title_
|
||||
labels_play_ << label_filetype_title_
|
||||
<< label_length_title_
|
||||
<< label_samplerate_title_
|
||||
<< label_bitdepth_title_
|
||||
<< label_bitrate_title_;
|
||||
|
||||
labels_play_data_ << label_engine_icon_
|
||||
<< label_engine_
|
||||
<< label_device_
|
||||
<< label_device_icon_
|
||||
<< label_filetype_
|
||||
labels_play_data_ << label_filetype_
|
||||
<< label_length_
|
||||
<< label_samplerate_
|
||||
<< label_bitdepth_
|
||||
@ -299,10 +245,6 @@ void ContextView::AddActions() {
|
||||
action_show_data_->setCheckable(true);
|
||||
action_show_data_->setChecked(true);
|
||||
|
||||
action_show_output_ = new QAction(tr("Show engine and device"), this);
|
||||
action_show_output_->setCheckable(true);
|
||||
action_show_output_->setChecked(true);
|
||||
|
||||
action_show_lyrics_ = new QAction(tr("Show song lyrics"), this);
|
||||
action_show_lyrics_->setCheckable(true);
|
||||
action_show_lyrics_->setChecked(true);
|
||||
@ -313,7 +255,6 @@ void ContextView::AddActions() {
|
||||
|
||||
menu_options_->addAction(action_show_album_);
|
||||
menu_options_->addAction(action_show_data_);
|
||||
menu_options_->addAction(action_show_output_);
|
||||
menu_options_->addAction(action_show_lyrics_);
|
||||
menu_options_->addAction(action_search_lyrics_);
|
||||
menu_options_->addSeparator();
|
||||
@ -322,7 +263,6 @@ void ContextView::AddActions() {
|
||||
|
||||
QObject::connect(action_show_album_, &QAction::triggered, this, &ContextView::ActionShowAlbum);
|
||||
QObject::connect(action_show_data_, &QAction::triggered, this, &ContextView::ActionShowData);
|
||||
QObject::connect(action_show_output_, &QAction::triggered, this, &ContextView::ActionShowOutput);
|
||||
QObject::connect(action_show_lyrics_, &QAction::triggered, this, &ContextView::ActionShowLyrics);
|
||||
QObject::connect(action_search_lyrics_, &QAction::triggered, this, &ContextView::ActionSearchLyrics);
|
||||
|
||||
@ -348,7 +288,6 @@ void ContextView::ReloadSettings() {
|
||||
summary_fmt_ = s.value(ContextSettingsPage::kSettingsSummaryFmt, "%album%").toString();
|
||||
action_show_album_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ALBUM)], true).toBool());
|
||||
action_show_data_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::TECHNICAL_DATA)], false).toBool());
|
||||
action_show_output_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE)], false).toBool());
|
||||
action_show_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS)], true).toBool());
|
||||
action_search_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS)], true).toBool());
|
||||
font_headline_.setFamily(s.value("font_headline", default_font).toString());
|
||||
@ -550,49 +489,6 @@ void ContextView::SetSong() {
|
||||
spacer_play_data_->changeSize(0, 0, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
if (action_show_output_->isChecked()) {
|
||||
widget_play_output_->show();
|
||||
EngineBase::Type enginetype = EngineBase::Type::None;
|
||||
if (app_->player()->engine()) enginetype = app_->player()->engine()->type();
|
||||
QIcon icon_engine = IconLoader::Load(EngineBase::Name(enginetype), true, 32);
|
||||
|
||||
label_engine_icon_->setPixmap(icon_engine.pixmap(QSize(32, 32)));
|
||||
label_engine_->setText(EngineBase::Description(enginetype));
|
||||
spacer_play_output_->changeSize(20, 20, QSizePolicy::Fixed);
|
||||
|
||||
DeviceFinder::Device device;
|
||||
for (DeviceFinder *f : app_->device_finders()->ListFinders()) {
|
||||
for (const DeviceFinder::Device &d : f->ListDevices()) {
|
||||
if (d.value != app_->player()->engine()->device()) continue;
|
||||
device = d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (device.value.isValid()) {
|
||||
label_device_title_->show();
|
||||
label_device_icon_->show();
|
||||
label_device_->show();
|
||||
QIcon icon_device = IconLoader::Load(device.iconname, true, 32);
|
||||
label_device_icon_->setPixmap(icon_device.pixmap(QSize(32, 32)));
|
||||
label_device_->setText(device.description);
|
||||
}
|
||||
else {
|
||||
label_device_title_->hide();
|
||||
label_device_icon_->hide();
|
||||
label_device_->hide();
|
||||
label_device_icon_->clear();
|
||||
label_device_->clear();
|
||||
}
|
||||
}
|
||||
else {
|
||||
widget_play_output_->hide();
|
||||
label_engine_icon_->clear();
|
||||
label_engine_->clear();
|
||||
label_device_icon_->clear();
|
||||
label_device_->clear();
|
||||
spacer_play_output_->changeSize(0, 0, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) {
|
||||
textedit_play_lyrics_->SetText(lyrics_);
|
||||
textedit_play_lyrics_->show();
|
||||
@ -679,7 +575,6 @@ void ContextView::ResetSong() {
|
||||
l->clear();
|
||||
}
|
||||
|
||||
widget_play_output_->hide();
|
||||
widget_play_data_->hide();
|
||||
textedit_play_lyrics_->hide();
|
||||
|
||||
@ -763,16 +658,6 @@ void ContextView::ActionShowData() {
|
||||
|
||||
}
|
||||
|
||||
void ContextView::ActionShowOutput() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE)], action_show_output_->isChecked());
|
||||
s.endGroup();
|
||||
if (song_playing_.is_valid()) SetSong();
|
||||
|
||||
}
|
||||
|
||||
void ContextView::ActionShowLyrics() {
|
||||
|
||||
QSettings s;
|
||||
|
@ -86,7 +86,6 @@ class ContextView : public QWidget {
|
||||
private slots:
|
||||
void ActionShowAlbum();
|
||||
void ActionShowData();
|
||||
void ActionShowOutput();
|
||||
void ActionShowLyrics();
|
||||
void ActionSearchLyrics();
|
||||
void UpdateNoSong();
|
||||
@ -112,7 +111,6 @@ class ContextView : public QWidget {
|
||||
QMenu *menu_options_;
|
||||
QAction *action_show_album_;
|
||||
QAction *action_show_data_;
|
||||
QAction *action_show_output_;
|
||||
QAction *action_show_lyrics_;
|
||||
QAction *action_search_lyrics_;
|
||||
|
||||
@ -129,12 +127,9 @@ class ContextView : public QWidget {
|
||||
QVBoxLayout *layout_play_;
|
||||
QLabel *label_stop_summary_;
|
||||
QWidget *widget_play_data_;
|
||||
QWidget *widget_play_output_;
|
||||
QGridLayout *layout_play_data_;
|
||||
QGridLayout *layout_play_output_;
|
||||
ResizableTextEdit *textedit_play_lyrics_;
|
||||
|
||||
QSpacerItem *spacer_play_output_;
|
||||
QSpacerItem *spacer_play_data_;
|
||||
|
||||
QLabel *label_filetype_title_;
|
||||
@ -149,15 +144,6 @@ class ContextView : public QWidget {
|
||||
QLabel *label_bitdepth_;
|
||||
QLabel *label_bitrate_;
|
||||
|
||||
QLabel *label_device_title_;
|
||||
QLabel *label_engine_title_;
|
||||
QLabel *label_device_space_;
|
||||
QLabel *label_engine_space_;
|
||||
QLabel *label_device_;
|
||||
QLabel *label_engine_;
|
||||
QLabel *label_device_icon_;
|
||||
QLabel *label_engine_icon_;
|
||||
|
||||
Song song_playing_;
|
||||
Song song_prev_;
|
||||
QImage image_original_;
|
||||
|
Loading…
Reference in New Issue
Block a user