aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/FileDialogs/QmmpFileDialog/CMakeLists.txt
Commit message (Expand)AuthorAgeFilesLines
* imported 0.2 fixestrialuser022008-09-021-2/+3
* fixed buildtrialuser022008-07-241-1/+1
* updated Russian translationtrialuser022008-07-091-4/+3
* enabled qmmp file dialogtrialuser022008-06-191-0/+61
c681e8-e032-0410-971d-27865f9a5e38> 2009-11-23 20:39:29 +0000 added popup information' href='/qmmp/commit/src/ui/popupwidget.cpp?id=7b17a2848b62d30f25771529566a61f4dd40131e'>7b17a2848
cb8811646
7b17a2848












bc6a11535
7b17a2848
f85fc6216
bc6a11535
11b7655bb
7b17a2848

7b17a2848






fa1e4194b
7b17a2848


bc6a11535
013ee07b5
7b17a2848


bc6a11535
013ee07b5
d2b37ec8f
bc6a11535



013ee07b5
7b17a2848






bc6a11535





7b17a2848

245d0ac0c
7b17a2848
bc6a11535

b353daaa7
bc6a11535

7b17a2848
bc6a11535
7b17a2848

cb8811646
7b17a2848
7b17a2848
abaab158b
7b17a2848
7b17a2848
bc6a11535
d2b37ec8f
7b17a2848
7b17a2848
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
134
135
136
                                                                            
                                                                            














                                                                            
                                                                            




                                                                             
                         












                                         
                         
 
                                                                                          
                                                 
                                            

                                                          






                                                                 
                                   


                                                                              
                                                            
                                                                       


                               
                                
                                  
                                                       



                                                                
                           






                                                 





                                                

 
                                                          
 

                         
                        

             
     
                        

               
 
                               
                               
                          
                             
                          
                      
                       
                          
                     



                                                                  
 



                              
                  


           
                                      
 
                 



                             
                       
               
                                                               
                    
                                                   
                                                      
                                                                                                               



                          
 
/***************************************************************************
 *   Copyright (C) 2008-2014 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 <QVBoxLayout>
#include <QLabel>
#include <QApplication>
#include <QDesktopWidget>
#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::X11BypassWindowManagerHint | Qt::Dialog | Qt::FramelessWindowHint);
    //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();
    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);

    m_url = item->url();
    hide();
    if(!item)
    {
        m_timer->stop();
        return;
    }

    QString title = m_template;
    MetaDataFormatter f(title);
    title = f.parse(item);
    m_label1->setText(title);
    qApp->processEvents();
    updateGeometry ();
    resize(sizeHint());
    qApp->processEvents();
    m_timer->start();
    QRect rect = QApplication::desktop()->availableGeometry(this);
    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();
}