aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/hal/settingsdialog.cpp
Commit message (Collapse)AuthorAgeFilesLines
* changed contact informationtrialuser022017-10-071-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7514 90c681e8-e032-0410-971d-27865f9a5e38
* fixed FSF headerstrialuser022012-07-311-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2845 90c681e8-e032-0410-971d-27865f9a5e38
* fixed FSF address (trunk)trialuser022012-07-311-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2844 90c681e8-e032-0410-971d-27865f9a5e38
* reapplied previous patchtrialuser022010-03-111-4/+4
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1620 90c681e8-e032-0410-971d-27865f9a5e38
* removed obsolete memberstrialuser022010-03-111-2/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1619 90c681e8-e032-0410-971d-27865f9a5e38
* some hal plugin improvements, updated Russian translationtrialuser022009-01-291-0/+58
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@764 90c681e8-e032-0410-971d-27865f9a5e38
title='author trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> 2008-03-18 11:17:32 +0000 committer trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> 2008-03-18 11:17:32 +0000 dbus plugin: more properties and signals' href='/qmmp/commit/src/plugins/General/dbuscontrol/dbusadaptor.cpp?id=625b2712c1c9fa46ba43684a24a477aa60d88089'>625b2712c
95e35ef7c

4c257a6d6
2d622fd9b

06d187781
11707f82f




















06d187781
11707f82f


70ada13d8



11707f82f








06d187781
2d622fd9b
625b2712c


































4c257a6d6




625b2712c














95e35ef7c




06d187781

11707f82f
06d187781
2d622fd9b
06d187781
2d622fd9b
11707f82f
2d622fd9b

06d187781
2d622fd9b
11707f82f
2d622fd9b

06d187781
2d622fd9b
11707f82f
2d622fd9b

06d187781
2d622fd9b
11707f82f
2d622fd9b
06d187781
625b2712c




06d187781

11707f82f
06d187781

95e35ef7c






625b2712c










95e35ef7c








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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
                                                                            
                                                                            
















                                                                             


                           
                        
                        
 

                                                        
 
                     
                              
                                                                   

                                                                     
                                                                  

 
                           




















                                                                                           
 


                                                                                 



                                                  








                                                                                           
 
 


































                                                                    




                                                                 














                                                                               




                                                                

                        
                                                 
 
 
                        
 
                                                 

 
                        
 
                                                 

 
                            
 
                                                     

 
                         
 
                                                  
 
 




                                                             

                        
                                                 

 






                                                                   










                                                                








                                            
/***************************************************************************
 *   Copyright (C) 2008 by Ilya Kotov                                      *
 *   forkotov02@hotmail.ru                                                 *
 *                                                                         *
 *   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 2 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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <qmmpui/control.h>

#include "dbuscontrol.h"
#include "dbusadaptor.h"

DBUSAdaptor::DBUSAdaptor(Control *ctrl, QObject *parent)
        : QDBusAbstractAdaptor(parent)
{
    m_control = ctrl;
    setAutoRelaySignals(TRUE);
    connect(parent, SIGNAL(stateChanged()), SLOT (processState()));
    connect(parent, SIGNAL(volumeChanged()), SLOT (processVolume()));
    connect(parent, SIGNAL(timeChanged()), SLOT (processTime()));
    connect(parent, SIGNAL(songChanged()), SIGNAL(songChanged()));
}

DBUSAdaptor::~DBUSAdaptor()
{}

int DBUSAdaptor::volume()
{
    int left, right;
    QMetaObject::invokeMethod(parent(), "leftVolume", Q_RETURN_ARG(int, left));
    QMetaObject::invokeMethod(parent(), "rightVolume", Q_RETURN_ARG(int, right));
    return qMax(left, right);
}

void DBUSAdaptor::setVolume(int volume)
{
    volume = qMin(volume, 100);
    volume = qMax(volume, 0);
    int bal = balance();
    int left = volume-qMax(bal,0)*volume/100;
    int right = volume+qMin(bal,0)*volume/100;
    QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right));
}

int DBUSAdaptor::balance()
{
    int left, right;
    QMetaObject::invokeMethod(parent(), "leftVolume", Q_RETURN_ARG(int, left));
    QMetaObject::invokeMethod(parent(), "rightVolume", Q_RETURN_ARG(int, right));
    if(left || right)
        return (right-left)*100/qMax(left, right);
    else
        return 0;
}

void DBUSAdaptor::setBalance(int bal)
{
    bal = qMin(bal,100);
    bal = qMax(bal,-100);
    int left = volume()-qMax(bal,0)*volume()/100;
    int right = volume()+qMin(bal,0)*volume()/100;
    QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right));
}

int DBUSAdaptor::length()
{
    return qobject_cast<DBUSControl *>(parent())->info()->length();
}

int DBUSAdaptor::year()
{
    return qobject_cast<DBUSControl *>(parent())->info()->year();
}

QString DBUSAdaptor::title()
{
    return qobject_cast<DBUSControl *>(parent())->info()->title();
}

QString DBUSAdaptor::artist()
{
    return qobject_cast<DBUSControl *>(parent())->info()->artist();
}

QString DBUSAdaptor::album()
{
    return qobject_cast<DBUSControl *>(parent())->info()->album();
}

QString DBUSAdaptor::comment()
{
    return qobject_cast<DBUSControl *>(parent())->info()->comment();
}

QString DBUSAdaptor::genre()
{
    return qobject_cast<DBUSControl *>(parent())->info()->genre();
}

QString DBUSAdaptor::path()
{
    return qobject_cast<DBUSControl *>(parent())->info()->path();
}

bool DBUSAdaptor::isPlaying()
{
    return qobject_cast<DBUSControl *>(parent())->state() == General::Playing;
}

bool DBUSAdaptor::isPaused()
{
     return qobject_cast<DBUSControl *>(parent())->state() == General::Paused;
}

bool DBUSAdaptor::isStopped()
{
     return qobject_cast<DBUSControl *>(parent())->state() == General::Stopped;
}

int DBUSAdaptor::elapsedTime()
{
    return qobject_cast<DBUSControl *>(parent())->elapsedTime();
}

void DBUSAdaptor::play()
{
    QMetaObject::invokeMethod(m_control, "play");
}

void DBUSAdaptor::stop()
{
    QMetaObject::invokeMethod(m_control, "stop");
}

void DBUSAdaptor::next()
{
    QMetaObject::invokeMethod(m_control, "next");
}

void DBUSAdaptor::previous()
{
    QMetaObject::invokeMethod(m_control, "previous");
}

void DBUSAdaptor::pause()
{
    QMetaObject::invokeMethod(m_control, "pause");
}

void DBUSAdaptor::toggleVisibility()
{
    QMetaObject::invokeMethod(m_control, "toggleVisibility");
}

void DBUSAdaptor::exit()
{
    QMetaObject::invokeMethod(m_control, "exit");
}

void DBUSAdaptor::seek(int time)
{
    if ((time < 0) || (time > length()))
        return;
    QMetaObject::invokeMethod(m_control, "seek", Q_ARG(int, time));
}

void DBUSAdaptor::processState()
{
    uint state = qobject_cast<DBUSControl *>(parent())->state();
    if(state == General::Playing)
        emit started();
    else if(state == General::Stopped)
        emit stopped();
    else if(state == General::Paused)
        emit paused();
}

void DBUSAdaptor::processVolume()
{
    emit volumeChanged(volume(), balance());
}

void DBUSAdaptor::processTime()
{
    emit timeChanged(elapsedTime());
}