1 /* GUI_ControlsNew.cpp */
2
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "GUI_ControlsNew.h"
22 #include "Gui/Player/ui_GUI_ControlsNew.h"
23
24 #include "Components/Tagging/UserTaggingOperations.h"
25
26 #include "Interfaces/PlayManager.h"
27
28 #include "Utils/MetaData/MetaDataList.h"
29
30 using Gui::RatingEditor;
31
32 struct GUI_ControlsNew::Private
33 {
34 PlayManager* playManager;
35
PrivateGUI_ControlsNew::Private36 explicit Private(PlayManager* playManager) :
37 playManager{playManager}
38 {}
39 };
40
GUI_ControlsNew(PlayManager * playManager,CoverDataProvider * coverProvider,QWidget * parent)41 GUI_ControlsNew::GUI_ControlsNew(PlayManager* playManager, CoverDataProvider* coverProvider, QWidget* parent) :
42 GUI_ControlsBase(playManager, coverProvider, parent)
43 {
44 m = Pimpl::make<Private>(playManager);
45
46 ui = new Ui::GUI_ControlsNew();
47 ui->setupUi(this);
48
49 ui->widgetRating->setMaximumHeight(static_cast<int>(this->fontMetrics().height() * 1.5));
50 ui->widgetRating->setMaximumWidth(ui->widgetRating->height() * 5);
51
52 ui->widgetRating->setMouseTrackable(false);
53 connect(ui->widgetRating, &RatingEditor::sigFinished, this, &GUI_ControlsNew::ratingChangedHere);
54 }
55
~GUI_ControlsNew()56 GUI_ControlsNew::~GUI_ControlsNew()
57 {
58 delete ui;
59 ui = nullptr;
60 }
61
labSayonara() const62 QLabel* GUI_ControlsNew::labSayonara() const { return ui->labSayonara; }
63
labTitle() const64 QLabel* GUI_ControlsNew::labTitle() const { return ui->labTitle; }
65
labVersion() const66 QLabel* GUI_ControlsNew::labVersion() const { return ui->labVersion; }
67
labAlbum() const68 QLabel* GUI_ControlsNew::labAlbum() const { return ui->labAlbum; }
69
labArtist() const70 QLabel* GUI_ControlsNew::labArtist() const { return ui->labArtist; }
71
labWrittenBy() const72 QLabel* GUI_ControlsNew::labWrittenBy() const { return ui->labWrittenBy; }
73
labBitrate() const74 QLabel* GUI_ControlsNew::labBitrate() const { return ui->labBitrate; }
75
labCopyright() const76 QLabel* GUI_ControlsNew::labCopyright() const { return ui->labCopyright; }
77
labFilesize() const78 QLabel* GUI_ControlsNew::labFilesize() const { return ui->labFilesize; }
79
labCurrentTime() const80 QLabel* GUI_ControlsNew::labCurrentTime() const { return ui->labCurrentTime; }
81
labMaxTime() const82 QLabel* GUI_ControlsNew::labMaxTime() const { return ui->labDuration; }
83
widgetDetails() const84 QWidget* GUI_ControlsNew::widgetDetails() const { return ui->widgetDetails; }
85
labRating() const86 Gui::RatingEditor* GUI_ControlsNew::labRating() const { return ui->widgetRating; }
87
sliProgress() const88 Gui::SearchSlider* GUI_ControlsNew::sliProgress() const { return ui->sliProgress; }
89
sliVolume() const90 Gui::SearchSlider* GUI_ControlsNew::sliVolume() const { return ui->sliVolume; }
91
btnMute() const92 QPushButton* GUI_ControlsNew::btnMute() const { return ui->btnMute; }
93
btnPlay() const94 QPushButton* GUI_ControlsNew::btnPlay() const { return ui->btnPlay; }
95
btnRecord() const96 QPushButton* GUI_ControlsNew::btnRecord() const { return ui->btnRec; }
97
btnPrevious() const98 QPushButton* GUI_ControlsNew::btnPrevious() const { return ui->btnPrev; }
99
btnNext() const100 QPushButton* GUI_ControlsNew::btnNext() const { return ui->btnNext; }
101
btnStop() const102 QPushButton* GUI_ControlsNew::btnStop() const { return ui->btnStop; }
103
btnCover() const104 Gui::CoverButton* GUI_ControlsNew::btnCover() const { return ui->btnCover; }
105
ratingChangedHere(bool save)106 void GUI_ControlsNew::ratingChangedHere(bool save)
107 {
108 const auto& track = m->playManager->currentTrack();
109
110 if(!save)
111 {
112 ui->widgetRating->setRating(track.rating());
113 return;
114 }
115
116 const auto rating = ui->widgetRating->rating();
117
118 auto* uto = new Tagging::UserOperations(track.libraryId(), this);
119 connect(uto, &Tagging::UserOperations::sigFinished, uto, &QObject::deleteLater);
120 uto->setTrackRating(track, rating);
121 }
122
isExternResizeAllowed() const123 bool GUI_ControlsNew::isExternResizeAllowed() const
124 {
125 return true;
126 }
127
languageChanged()128 void GUI_ControlsNew::languageChanged()
129 {
130 if(ui)
131 {
132 ui->retranslateUi(this);
133 }
134 }
135