Parent: [3772cf] (diff)

Child: [11bdc8] (diff)

Download this file

mw_controls.cpp    168 lines (130 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// GUI_PlayerButtons.cpp
/* Copyright (C) 2012 Lucio Carreras
*
* This file is part of sayonara player
*
* This program 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.
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
using namespace std;
#include "mainw.h"
#include "trayicon.h"
/** Slots connected to player or trayicon signals **/
void GUI_Player::onPlayActivated()
{
// We don't know which control caused this, so make sure all ui are setup
m_trayIcon->setPlaying(true);
ui->player_w->playctl()->onPlaying();
emit play();
}
void GUI_Player::onPauseActivated()
{
// We don't know which control caused this, so make sure all ui are setup
m_trayIcon->setPlaying(false);
ui->player_w->playctl()->onPaused();
emit pause();
}
void GUI_Player::onStopActivated()
{
m_trayIcon->setPlaying(false);
m_trayIcon->stop();
ui->player_w->playctl()->onStopped();
idleDisplay();
emit stop();
}
void GUI_Player::onMuteActivated(bool mute)
{
m_trayIcon->setMute(mute);
ui->player_w->volume()->setMuteUi(mute);
emit sig_mute(mute);
}
void GUI_Player::idleDisplay()
{
MetaData md;
md.title = QString::fromUtf8("Upplay ") + m_settings->getVersion();
md.artist = m_renderer_friendly_name.isEmpty() ?
"No renderer connected" :
tr("Renderer: ") + m_renderer_friendly_name;
ui->player_w->mdata()->setData(md);
this->setWindowTitle("Upplay");
ui->player_w->progress()->setUi(0);
ui->player_w->albumCover->setIcon(QIcon(Helper::getIconPath("logo.png")));
}
void GUI_Player::onBackwardActivated()
{
// ui->albumCover->setFocus();
int cur_pos_sec =
(m_metadata.length_ms * ui->player_w->progress()->currentValuePc())
/ 100000;
if (cur_pos_sec > 3) {
emit sig_seek(0);
} else {
emit backward();
}
}
void GUI_Player::onForwardActivated()
{
//ui->albumCover->setFocus();
emit forward();
}
/** PROGRESS BAR **/
void GUI_Player::total_time_changed(qint64 total_time)
{
ui->player_w->progress()->setTotalTime(total_time/1000);
}
void GUI_Player::onJumpForwardActivated()
{
ui->player_w->progress()->step(1);
}
void GUI_Player::onJumpBackwardActivated()
{
ui->player_w->progress()->step(-1);
}
// This is called from the external world to update the position
void GUI_Player::setCurrentPosition(quint32 pos_sec)
{
ui->player_w->progress()->setUi(pos_sec);
}
/** PROGRESS BAR END **/
/** PLAYER BUTTONS END **/
/** VOLUME **/
// Called e.g. after reading saved volume from settings: adjust ui and
// set audio volume.
void GUI_Player::setVolume(int pc)
{
ui->player_w->volume()->set(pc);
}
// Called from audio when volume has been changed by another player.
void GUI_Player::setVolumeUi(int pc)
{
ui->player_w->volume()->setUi(pc);
}
void GUI_Player::setMuteUi(bool ismute)
{
ui->player_w->volume()->setMuteUi(ismute);
}
void GUI_Player::onVolumeStepActivated(int val)
{
int vol_step = m_trayIcon->get_vol_step();
ui->player_w->volume()->step(vol_step * val);
}
void GUI_Player::onVolumeHigherActivated()
{
//qDebug() << "GUI_PLayer::volumeHigher";
ui->player_w->volume()->volumeHigher();
}
void GUI_Player::onVolumeLowerActivated()
{
//qDebug() << "GUI_PLayer::volumeLower";
ui->player_w->volume()->volumeLower();
}
/** VOLUME END **/