aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Effect/bs2b/settingsdialog.cpp
blob: 68f3ecd3f6bf5d2acb555e5713d594194fb31b1d (plain) (blame)
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
/***************************************************************************
 *   Copyright (C) 2009 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 <QSettings>
#include <bs2b/bs2b.h>
#include <qmmp/qmmp.h>

#include "settingsdialog.h"

SettingsDialog::SettingsDialog(QWidget *parent)
        : QDialog(parent)
{
    ui.setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose, TRUE);
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    ui.levelComboBox->addItem (tr("low"), BS2B_LOW_CLEVEL);
    ui.levelComboBox->addItem (tr("middle"), BS2B_MIDDLE_CLEVEL);
    ui.levelComboBox->addItem (tr("high"), BS2B_HIGH_CLEVEL);
    ui.levelComboBox->addItem (tr("low (easy version)"), BS2B_LOW_ECLEVEL);
    ui.levelComboBox->addItem (tr("middle (easy version)"), BS2B_MIDDLE_ECLEVEL);
    ui.levelComboBox->addItem (tr("high (easy version) [default]"), BS2B_HIGH_ECLEVEL);
    int index = ui.levelComboBox->findData(settings.value("bs2b/level", BS2B_DEFAULT_CLEVEL).toInt());
    if (index >= 0)
        ui.levelComboBox->setCurrentIndex(index);
}

SettingsDialog::~SettingsDialog()
{
}

void SettingsDialog::accept()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.setValue("bs2b/level", ui.levelComboBox->itemData(ui.levelComboBox->currentIndex()).toInt());
    QDialog::accept();
}
iv>
bc6a11535



013ee07b5
7b17a2848






bc6a11535





7b17a2848

245d0ac0c
7b17a2848
bc6a11535
bc6a11535

7b17a2848
bc6a11535
3c37f7453
7b17a2848

aa167f22d
96cfa27dc
7b17a2848
bc6a11535
d2b37ec8f
7b17a2848
7b17a2848
69c45fb3c
cb8811646


7b17a2848
bc6a11535



b353daaa7
bc6a11535


b353daaa7
bc6a11535
b353daaa7
bc6a11535



b353daaa7
bc6a11535
b353daaa7
bc6a11535
109e40669
bc6a11535
ce25692d5
d2b37ec8f



bc6a11535
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
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            




                                                                             
                  












                                         
                         
 
                                                                
                                                 
                                            

                                                          






                                                                 
                                   


                                                                              
                                       
                                                            
                                                                       


                               
                                
                                  
                                                       



                                                                
                           






                                                 





                                                

 
                                                          
 
                         

             
     
                        
                      

               
                         
                                                
                          
                      
                       
                          
                     
                                                                       


                                                   
 



                              
                  


           
                                      
 
                 



                             
                       
               
                                                               
                    
                                                   
                                                      
                                                                                                               



                          
 
/***************************************************************************
 *   Copyright (C) 2008-2018 by Ilya Kotov                                 *
 *   forkotov02@ya.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 <QVBoxLayout>
#include <QLabel>
#include <QApplication>
#include <QScreen>
#include <QTimer>
#include <QSettings>
#include <QApplication>
#include <qmmp/soundcore.h>
#include <qmmp/metadatamanager.h>
#include <qmmpui/metadataformatter.h>
#include <qmmpui/playlistitem.h>

#include "popupwidget.h"

using namespace PlayListPopup;

PopupWidget::PopupWidget(QWidget *parent)
        : QWidget(parent)
{
    setWindowFlags(Qt::ToolTip | Qt::BypassGraphicsProxyWidget);
    //setFrameStyle(QFrame::Box | QFrame::Plain);
    setAttribute(Qt::WA_QuitOnClose, false);
    QHBoxLayout *hlayout = new QHBoxLayout(this); //layout
    m_pixlabel = new QLabel(this);
    hlayout->addWidget(m_pixlabel);

    m_label1 = new QLabel(this);
    hlayout->addWidget (m_label1);

    //settings
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Skinned");
    setWindowOpacity(settings.value("popup_opacity", 1.0).toDouble());
    m_coverSize = settings.value("popup_cover_size", 48).toInt();
    m_template = settings.value("popup_template",DEFAULT_TEMPLATE).toString();
    m_formatter.setPattern(m_template);
    int delay = settings.value("popup_delay", 2500).toInt();
    bool show_cover = settings.value("popup_show_cover",true).toBool();
    settings.endGroup();
    //timer
    m_timer = new QTimer(this);
    m_timer->setInterval(delay);
    m_timer->setSingleShot (true);
    connect(m_timer, SIGNAL(timeout ()), SLOT(show()));
    if(show_cover)
        connect(m_timer, SIGNAL(timeout ()), SLOT(loadCover()));
    else
        m_pixlabel->hide();
    setMouseTracking(true);
}

PopupWidget::~PopupWidget()
{}

void PopupWidget::mousePressEvent (QMouseEvent *)
{
    hide();
}

void PopupWidget::mouseMoveEvent (QMouseEvent *)
{
    hide();
}

void PopupWidget::prepare(PlayListTrack *item, QPoint pos)
{
    pos += QPoint(15,10);
    hide();
    if(!item)
    {
        m_timer->stop();
        m_url.clear();
        return;
    }
    m_url = item->path();
    m_label1->setText(m_formatter.format(item));
    qApp->processEvents();
    updateGeometry ();
    resize(sizeHint());
    qApp->processEvents();
    m_timer->start();
    QRect rect = QGuiApplication::primaryScreen()->availableGeometry();
    if(pos.x() + width() > rect.x() + rect.width())
        pos.rx() -= width();
    move(pos);
}

void PopupWidget::deactivate()
{
    m_timer->stop();
    m_url.clear();
    hide();
}

const QString PopupWidget::url() const
{
    return m_url;
}

void PopupWidget::loadCover()
{
    if(m_url.isEmpty())
        return;
    QPixmap pix = MetaDataManager::instance()->getCover(m_url);
    if(pix.isNull())
        pix = QPixmap(":/skinned/ui_no_cover.png");
    m_pixlabel->setFixedSize(m_coverSize,m_coverSize);
    m_pixlabel->setPixmap(pix.scaled(m_coverSize,m_coverSize,Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
    qApp->processEvents();
    updateGeometry ();
    resize(sizeHint());
    qApp->processEvents();
}