aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-06-02 15:15:52 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-06-02 15:15:52 +0000
commitf09539c4df05a270d6c24cec515c5f217166a0b0 (patch)
tree059bc8f74496d6a5ed014d6a8cbd81600360064d /src/plugins
parentf83a2576bd49a16e528e8cda2d76205d5db29acb (diff)
downloadqmmp-f09539c4df05a270d6c24cec515c5f217166a0b0.tar.gz
qmmp-f09539c4df05a270d6c24cec515c5f217166a0b0.tar.bz2
qmmp-f09539c4df05a270d6c24cec515c5f217166a0b0.zip
skinned: fixed scroller background color
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5074 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Ui/skinned/textscroller.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/Ui/skinned/textscroller.cpp b/src/plugins/Ui/skinned/textscroller.cpp
index 8fee5c739..dc7020aa9 100644
--- a/src/plugins/Ui/skinned/textscroller.cpp
+++ b/src/plugins/Ui/skinned/textscroller.cpp
@@ -265,7 +265,7 @@ void TextScroller::preparePixmap(const QString &text, bool scrollable)
if(m_transparencyAction->isChecked())
m_pixmap.fill(Qt::transparent);
else
- m_pixmap.fill(QString(Skin::instance()->getPLValue("normalbg")));
+ m_pixmap.fill(QString(Skin::instance()->getPLValue("mbbg")));
QPainter painter(&m_pixmap);
painter.setPen(m_color);
painter.setFont(m_font);
@@ -282,7 +282,7 @@ void TextScroller::preparePixmap(const QString &text, bool scrollable)
if(m_transparencyAction->isChecked())
m_pixmap.fill(Qt::transparent);
else
- m_pixmap.fill(QString(Skin::instance()->getPLValue("normalbg")));
+ m_pixmap.fill(QString(Skin::instance()->getPLValue("mbbg")));
QPainter painter(&m_pixmap);
painter.setPen(m_color);
painter.setFont(m_font);
:55 +0000 imported 0.2 fixes' href='/qmmp/commit/src/ui/eqwidget.cpp?id=b5833f9423ecdc673f653dbb3f4bca6dacc918c1'>b5833f942
2d622fd9b
ef5b02756
11b7655bb
ecc137abe
b5833f942
26da2f9c1
b5833f942
2702b572b
b5833f942
2d622fd9b
b5833f942
d67103d42
2d622fd9b
1b1902f39

2d622fd9b


2d622fd9b
2d622fd9b
26da2f9c1
2d622fd9b
1b1902f39
2d622fd9b
b5833f942
2d622fd9b
b5833f942
1b1902f39
2d622fd9b


97c98d9d5

f56054da3







2d622fd9b









97c98d9d5











b5833f942
2d622fd9b






b5833f942
2d622fd9b

8a3af3bd1

2d622fd9b



11b7655bb
b5833f942
26da2f9c1
97c98d9d5













2d622fd9b



49ba6c2fa
fa1e4194b
1b1902f39
2d622fd9b
deb8cb930



013ee07b5
2d622fd9b


deb8cb930
2d622fd9b




deb8cb930
2d622fd9b
fbf6df0e2
2d622fd9b






b5833f942
013ee07b5
2d622fd9b
deb8cb930
2d622fd9b
deb8cb930
2d622fd9b




deb8cb930
2d622fd9b
fbf6df0e2
2d622fd9b









ae75e5707
fa1e4194b
2d622fd9b
b5833f942
2d622fd9b


deb8cb930
2d622fd9b


deb8cb930
2d622fd9b




deb8cb930
2d622fd9b







deb8cb930
2d622fd9b





1b1902f39
2d622fd9b

1b1902f39
83a38f8e5

38c7065ba
83a38f8e5

1b1902f39
2d622fd9b

1b1902f39

2d622fd9b
38c7065ba
2d622fd9b

1b1902f39
2d622fd9b
1b1902f39









2d622fd9b





ef0abefb6





2d622fd9b
ef0abefb6
2d622fd9b











1b1902f39
2d622fd9b























2d622fd9b
98d4bdde3






2d622fd9b






053884732


2d622fd9b
053884732


2d622fd9b
053884732


2d622fd9b



053884732
2d622fd9b






1b1902f39
2d622fd9b












































e85b77286
899a15f90
e85b77286
6f1f9ca43
2d622fd9b

b5833f942
2d622fd9b

b5833f942
2d622fd9b












2d622fd9b



06bdda525






97c98d9d5
872336337


f775730cd
4be19e3fd
f775730cd
4be19e3fd

872336337



97c98d9d5







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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
                                                                            
                                                                            














                                                                            
                                                                            




                                                                             
                      
                
                              
                                   
                           









                         
                         

                     

                                    
 
                                    
                     
                              
                                                  
                                                       
                                       
                           
                                                                        
 
                                   
                                                                      
 

                                                                                                          


                                                                                     
                              
                                    
                                                                                                         
                                                                        
                                                                                
 
                              
     
                                         
                                                                                   


                    

                      







                                                              









                                         











                                                   
                                           






                                                  
                                          

                    

                                



                           
                                  
                                                  
                                                       













                                     



                             
                                                                  
                                                                                     
             
                       



                                                               
                              


                                                                      
                                                                                                        




                                              
                                                                                           
             
                                                                      






                                     
                                                                                        
                              
     
                                                                 
         
                                                                                                      




                                              
                                                                                         
             
                                                                    









                                         
                                                                  
                                                                 
                       
                                                                                     


                                              
                                                                                          


                                                      
                                                                                  




                                                               
                                                                                        







                                                                 
                                                                                    





                                                                 
                       

                   
                                                                

                                
                                

               
                                            

                            

                                                      
     
                                             

 
                        
 









                                                       





                                                                          





                                                                                             
                                  
                                                                                                











                                                                   
              























                                                                                                    
                                                          






                                                                      






                                 


                                                                                          
                                        


                                                                
                       


                                                  



                                                      
                                 






                                                   
              












































                                                   
                                                                         
                                    
                                                 
 

                                   
                           

                                                                           
                                     












                                                        



                 






                                                                                             
 


                                    
                                                                             
     
                                           

                                                               



                                 







                                                                                       
/***************************************************************************
 *   Copyright (C) 2006-2013 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.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/
#include <QSettings>
#include <QEvent>
#include <QMenu>
#include <QInputDialog>
#include <QCloseEvent>
#include <QFile>
#include <qmmpui/filedialog.h>
#include <qmmpui/playlistmanager.h>
#include <qmmp/soundcore.h>
#include "skin.h"
#include "eqslider.h"
#include "eqtitlebar.h"
#include "togglebutton.h"
#include "eqgraph.h"
#include "button.h"
#include "eqpreset.h"
#include "preseteditor.h"
#include "mainwindow.h"
#include "playlist.h"
#include "windowsystem.h"
#include "eqwidget.h"

EqWidget::EqWidget (QWidget *parent)
        : PixmapWidget (parent)
{
    setWindowTitle(tr("Equalizer"));
    m_shaded = false;
    m_skin = Skin::instance();
    setPixmap (m_skin->getEqPart (Skin::EQ_MAIN));
    setCursor (m_skin->getCursor (Skin::CUR_EQNORMAL));
    m_titleBar = new EqTitleBar (this);
    m_titleBar->move (0,0);
    connect (m_skin, SIGNAL (skinChanged()), this, SLOT (updateSkin()));

    m_preamp = new EqSlider (this);
    connect (m_preamp,SIGNAL (sliderMoved (double)),SLOT (writeEq()));

    m_on = new ToggleButton (this,Skin::EQ_BT_ON_N,Skin::EQ_BT_ON_P, Skin::EQ_BT_OFF_N,Skin::EQ_BT_OFF_P);
    connect (m_on, SIGNAL (clicked(bool)), SLOT(writeEq()));

    m_autoButton = new ToggleButton(this, Skin::EQ_BT_AUTO_1_N, Skin::EQ_BT_AUTO_1_P,
                                    Skin::EQ_BT_AUTO_0_N, Skin::EQ_BT_AUTO_0_P);
    m_eqg = new EQGraph(this);
    m_presetsMenu = new QMenu(this);
    m_presetButton = new Button (this, Skin::EQ_BT_PRESETS_N, Skin::EQ_BT_PRESETS_P, Skin::CUR_EQNORMAL);
    connect(m_presetButton, SIGNAL(clicked()), SLOT(showPresetsMenu()));
    connect(SoundCore::instance(), SIGNAL(eqSettingsChanged()), SLOT(readEq()));

    for (int i = 0; i<10; ++i)
    {
        m_sliders << new EqSlider (this);
        connect (m_sliders.at (i), SIGNAL (sliderMoved (double)),SLOT (writeEq()));
    }
    readSettings();
    createActions();
    updatePositions();
    updateMask();
#ifdef Q_WS_X11
    QString wm_name = WindowSystem::netWindowManagerName();
    if(wm_name.contains("metacity", Qt::CaseInsensitive) ||
       wm_name.contains("openbox", Qt::CaseInsensitive))
        setWindowFlags (Qt::Tool | Qt::FramelessWindowHint);
    else
#endif
        setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint);
}

EqWidget::~EqWidget()
{
    while (!m_presets.isEmpty())
        delete m_presets.takeFirst();
    while (!m_autoPresets.isEmpty())
        delete m_autoPresets.takeFirst();
}

void EqWidget::updatePositions()
{
    int r = m_skin->ratio();
    m_preamp->move (21*r,38*r);
    m_on->move (14*r,18*r);
    m_autoButton->move(39*r,18*r);
    m_eqg->move(87*r,17*r);
    m_presetButton->move(217*r,18*r);
     for (int i = 0; i < 10; ++i)
         m_sliders.at (i)->move ((78+i*18)*r,38*r);
}

void EqWidget::changeEvent (QEvent * event)
{
    if (event->type() == QEvent::ActivationChange)
    {
        m_titleBar->setActive(isActiveWindow());
    }
}

void EqWidget::closeEvent (QCloseEvent* e)
{
    writeSettings();
    if (e->spontaneous ())
        parentWidget()->close();
}

void EqWidget::updateSkin()
{
    m_titleBar->setActive (false);
    setPixmap (m_skin->getEqPart (Skin::EQ_MAIN));
    setCursor (m_skin->getCursor (Skin::CUR_EQNORMAL));
    setMimimalMode(m_shaded);
    updatePositions();
}

void EqWidget::setMimimalMode(bool b)
{
    m_shaded = b;
    int r = m_skin->ratio();

    if(m_shaded)
         resize(r*275,r*14);
    else
         resize(r*275,r*116);
    updateMask();
}

void EqWidget::readSettings()
{
    QSettings settings (Qmmp::configFile(), QSettings::IniFormat);
    move (settings.value ("Skinned/eq_pos", QPoint (100, 216)).toPoint()); //geometry
    readEq();
    //equalizer presets
    QString preset_path = QDir::homePath() +"/.qmmp/eq.preset";
    if(!QFile::exists(preset_path))
        preset_path = ":/skinned/eq.preset";
    QSettings eq_preset (preset_path, QSettings::IniFormat);
    for (int i = 1; true; ++i)
    {
        if (eq_preset.contains("Presets/Preset"+QString("%1").arg(i)))
        {
            QString name = eq_preset.value(QString("Presets/Preset%1").arg(i), tr("preset")).toString();
            EQPreset *preset = new EQPreset();
            preset->setText(name);
            eq_preset.beginGroup(name);
            for (int j = 0; j < 10; ++j)
            {
                preset->setGain(j,eq_preset.value(QString("Band%1").arg(j), 0).toDouble());
            }
            preset->setPreamp(eq_preset.value("Preamp",0).toDouble());
            m_presets.append(preset);
            eq_preset.endGroup();
        }
        else
            break;
    }
    //equalizer auto-load presets
    QSettings eq_auto (QDir::homePath() +"/.qmmp/eq.auto_preset", QSettings::IniFormat);
    for (int i = 1; true; ++i)
    {
        if (eq_auto.contains(QString("Presets/Preset%1").arg(i)))
        {
            QString name = eq_auto.value(QString("Presets/Preset%1").arg(i), tr("preset")).toString();
            EQPreset *preset = new EQPreset();
            preset->setText(name);
            eq_auto.beginGroup(name);
            for (int j = 0; j < 10; ++j)
            {
                preset->setGain(j,eq_auto.value(QString("Band%1").arg(j), 0).toDouble());
            }
            preset->setPreamp(eq_auto.value("Preamp",0).toDouble());
            m_autoPresets.append(preset);
            eq_auto.endGroup();
        }
        else
            break;
    }
}

void EqWidget::writeSettings()
{
    QSettings settings (Qmmp::configFile(), QSettings::IniFormat);
    settings.setValue ("Skinned/eq_pos", this->pos()); //geometry
    //equalizer presets
    QSettings eq_preset (QDir::homePath() +"/.qmmp/eq.preset", QSettings::IniFormat);
    eq_preset.clear ();
    for (int i = 0; i < m_presets.size(); ++i)
    {
        eq_preset.setValue(QString("Presets/Preset%1").arg(i+1), m_presets.at(i)->text());
        eq_preset.beginGroup(m_presets.at(i)->text());
        for (int j = 0; j < 10; ++j)
        {
            eq_preset.setValue(QString("Band%1").arg(j),m_presets.at(i)->gain(j));
        }
        eq_preset.setValue("Preamp",m_presets.at(i)->preamp());
        eq_preset.endGroup();
    }
    //equalizer auto-load presets
    QSettings eq_auto (QDir::homePath() +"/.qmmp/eq.auto_preset", QSettings::IniFormat);
    eq_auto.clear();
    for (int i = 0; i < m_autoPresets.size(); ++i)
    {
        eq_auto.setValue("Presets/Preset"+QString("%1").arg(i+1),
                         m_autoPresets.at(i)->text());
        eq_auto.beginGroup(m_autoPresets.at(i)->text());
        for (int j = 0; j < 10; ++j)
        {
            eq_auto.setValue(QString("Band%1").arg(j),m_autoPresets.at(i)->gain(j));
        }
        eq_auto.setValue("Preamp",m_autoPresets.at(i)->preamp());
        eq_auto.endGroup();
    }
}

void EqWidget::readEq()
{
    m_eqg->clear();
    EqSettings eqSettings = SoundCore::instance()->eqSettings();
    if(eqSettings.bands() != 10)
    {
        m_on->setChecked(false);
        return;
    }
    m_preamp->setValue(eqSettings.preamp());
    for (int i=0; i<10; ++i)
    {
        m_sliders.at(i)->setValue(eqSettings.gain(i));
        m_eqg->addValue(m_sliders.at(i)->value());
    }
    m_on->setChecked(eqSettings.isEnabled());
}

void EqWidget::writeEq()
{
    m_eqg->clear();
    EqSettings eqSettings;
    eqSettings.setPreamp(m_preamp->value());
    for (int i=0; i<10; ++i)
    {
        eqSettings.setGain(i,m_sliders.at(i)->value());
        m_eqg->addValue(m_sliders.at(i)->value());
    }
    eqSettings.setEnabled(m_on->isChecked());
    SoundCore::instance()->setEqSettings(eqSettings);
}

void EqWidget::createActions()
{
    m_presetsMenu->addAction(tr("&Load/Delete"),this, SLOT(showEditor()));
    m_presetsMenu->addSeparator();
    m_presetsMenu->addAction(QIcon::fromTheme("document-save"), tr("&Save Preset"),
                             this, SLOT(savePreset()));
    m_presetsMenu->addAction(QIcon::fromTheme("document-save"), tr("&Save Auto-load Preset"),
                             this, SLOT(saveAutoPreset()));
    m_presetsMenu->addAction(QIcon::fromTheme("document-open"), tr("&Import"),
                             this, SLOT(importWinampEQF()));
    m_presetsMenu->addSeparator();
    m_presetsMenu->addAction(QIcon::fromTheme("edit-clear"), tr("&Clear"), this, SLOT(reset()));
}

void EqWidget::showPresetsMenu()
{
    m_presetsMenu->exec(m_presetButton->mapToGlobal(QPoint(0, 0)));
}

void EqWidget::reset()
{
    for (int i = 0; i < m_sliders.size(); ++i)
        m_sliders.at(i)->setValue(0);
    m_preamp->setValue(0);
    writeEq();
}

void EqWidget::showEditor()
{
    PresetEditor *editor = new PresetEditor(this);
    editor->addPresets(m_presets);
    editor->addAutoPresets(m_autoPresets);
    connect (editor, SIGNAL(presetLoaded(EQPreset*)), SLOT(setPreset(EQPreset*)));
    connect (editor, SIGNAL(presetDeleted(EQPreset*)), SLOT(deletePreset(EQPreset*)));
    editor->show();
}

void EqWidget::savePreset()
{
    bool ok;
    QString text = QInputDialog::getText(this, tr("Saving Preset"),
                                         tr("Preset name:"), QLineEdit::Normal,
                                         tr("preset #")+QString("%1").arg(m_presets.size()+1), &ok);
    if (ok)
    {
        EQPreset* preset = new EQPreset;
        preset->setText(text);
        preset->setPreamp(m_preamp->value());
        for (int i = 0; i<10; ++i)
            preset->setGain(i, m_sliders.at (i)->value());
        foreach(EQPreset *p, m_presets) //remove preset with same name
        {
            if (p->text() == text)
            {
                m_presets.removeAll(p);
                delete p;
            }
        }
        m_presets.append(preset);
    }
}

void EqWidget::saveAutoPreset()
{
    PlayListTrack *track = PlayListManager::instance()->currentPlayList()->currentTrack();
    if (!track)
        return;
    //delete preset if it already exists
    EQPreset* preset = findPreset(track->url().section("/",-1));
    if (preset)
        deletePreset(preset);
    //create new preset
    preset = new EQPreset();
    preset->setText(track->url().section("/",-1));
    preset->setPreamp(m_preamp->value());
    for (int i = 0; i<10; ++i)
    {
        preset->setGain(i, m_sliders.at (i)->value());
    }
    m_autoPresets.append(preset);
}

void EqWidget::setPreset(EQPreset* preset)
{
    for (int i = 0; i<10; ++i)
        m_sliders.at(i)->setValue(preset->gain(i));
    m_preamp->setValue(preset->preamp());
    writeEq();
}

void EqWidget::deletePreset(EQPreset* preset)
{
    int p = m_presets.indexOf(preset);
    if (p != -1)
    {
        delete m_presets.takeAt(p);
        return;
    }
    p = m_autoPresets.indexOf(preset);
    if (p != -1)
    {
        delete m_autoPresets.takeAt(p);
        return;
    }
}

void EqWidget::loadPreset(const QString &name)
{
    if (m_autoButton->isChecked())
    {
        EQPreset *preset = findPreset(name);
        if (preset)
            setPreset(preset);
        else
            reset();
    }
}

EQPreset *EqWidget::findPreset(const QString &name)
{
    foreach(EQPreset *preset, m_autoPresets)
    {
        if (preset->text() == name)
            return preset;
    }
    return 0;
}

void EqWidget::importWinampEQF()
{
    char header[31];
    char name[257];
    char bands[11];
    QString path = FileDialog::getOpenFileName(this, tr("Import Preset"),
                   QDir::homePath(),
                   QString("Winamp EQF (*.q1)"));

    QFile file(path);