aboutsummaryrefslogtreecommitdiff
path: root/src/app/main.cpp
blob: 53c9e72c265878702a161461e5102087b1da2115 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/***************************************************************************
 *   Copyright (C) 2006-2016 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 <QApplication>
#include <QLocale>
#include <QLibraryInfo>
#include <QIcon>
#include <QTranslator>
#include <stdio.h>
#include <stdlib.h>
#ifdef Q_OS_WIN
#include <QtGlobal>
#include <windows.h>
#include <winuser.h>
#endif
#include <qmmp/qmmp.h>
#include "qmmpstarter.h"

int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
    //allows to activate main window from other instances
    AllowSetForegroundWindow(ASFW_ANY);
#endif
    QApplication a (argc, argv );
    a.setApplicationName("qmmp");
    QIcon icon;
    icon.addFile(":/16x16/qmmp.png");
    icon.addFile(":/32x32/qmmp.png");
    icon.addFile(":/48x48/qmmp.png");
    icon.addFile(":/56x56/qmmp.png");
    icon.addFile(":/64x64/qmmp.png");
    icon.addFile(":/128x128/qmmp.png");
    icon.addFile(":/256x256/qmmp.png");
    icon.addFile(":/scalable/qmmp.svgz");
    a.setWindowIcon(icon);
#ifdef Q_OS_WIN
    if(Qmmp::isPortable())
        qputenv("HOMEPATH", Qmmp::configDir().toLatin1()); //librcc database path
#endif
    QTranslator translator;
    QString locale = Qmmp::systemLanguageID();
    translator.load(QString(":/qmmp_") + locale);
    a.installTranslator(&translator);

    QTranslator qt_translator;
    qt_translator.load(QLibraryInfo::location (QLibraryInfo::TranslationsPath) + "/qtbase_" + locale);
    a.installTranslator(&qt_translator);

    QMMPStarter starter;

    if(starter.isFinished())
        return starter.exitCode();

    a.setQuitOnLastWindowClosed(false);
    return a.exec();
}
gins/General/mpris/tracklistobject.cpp?id=24af8da3f8942c200ba0058341a66a888224aa3c'>24af8da3f
fedd13511
24af8da3f




8ab140dac

24af8da3f
fedd13511
887f15da1

24af8da3f
887f15da1
8ab140dac
24af8da3f

fedd13511



1fb94978d
fedd13511
8ab140dac


3a965fcd4
8ab140dac



887f15da1
8ab140dac




887f15da1


8ab140dac
887f15da1

8ab140dac
887f15da1










1fb94978d
887f15da1

1fb94978d








8ab140dac



ac7a7dffc

92f1159a1
ac7a7dffc



92f1159a1
ac7a7dffc

887f15da1
24af8da3f
887f15da1


24af8da3f

8ab140dac

887f15da1
8ab140dac
90d3aeb64








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
                                                                            
                                                                            














                                                                            
                                                                            


                                                                             
               
 
                                   

                                
                                  

                            
                                                                   

                                       
                                               

                                               
                                                                      

                                                                                         
                     

 



                                   
                                                           
 
                       
                                 




                                        

           
                                              
                         

                                                                                              
                                                                            
                                                                                 
     

                       



                                       
                              
 


                                      
                                   



                                
                                                            




                                                 


                                            
     

                               
            










                                         
                                                 

                                                             








                                                              



               

                                       
                                          



                                         
                                   

 
                                                     
 


                                                                                                  

 

                                        
                                                                           
 








                                                                             
/***************************************************************************
 *   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 <QFile>
#include <QUrl>

#include <qmmpui/playlistmanager.h>
#include <qmmpui/mediaplayer.h>
#include <qmmpui/playlistitem.h>
#include <qmmpui/qmmpuisettings.h>
#include "tracklistobject.h"

TrackListObject::TrackListObject(QObject *parent) : QObject(parent)
{
    m_player = MediaPlayer::instance();
    m_ui_settings = QmmpUiSettings::instance();
    m_pl_manager = m_player->playListManager();
    m_model = m_pl_manager->currentPlayList();
    connect (m_model, SIGNAL(listChanged()), SLOT(updateTrackList()));
    connect (m_pl_manager, SIGNAL(currentPlayListChanged(PlayListModel*,PlayListModel*)),
             SLOT(switchPlayList(PlayListModel*,PlayListModel*)));
    m_prev_count = 0;
}

TrackListObject::~TrackListObject()
{
}

int TrackListObject::AddTrack(const QString &in0, bool in1)
{
    QString path = in0;
    if(in0.startsWith("file://"))
    {
        path = QUrl(in0).toLocalFile ();
        if(!QFile::exists(path))
            return 1; //error
    }
    if(in1)
    {
        m_pl_manager->selectPlayList(m_model);
        m_player->stop();
        connect(m_model, SIGNAL(trackAdded(PlayListTrack*)), SLOT(playTrack(PlayListTrack*)));
        /*m_prev_count = m_model->count();
        connect(m_model, SIGNAL(listChanged()), this, SLOT(checkNewItem()));
        connect(m_model, SIGNAL(loaderFinished()), this, SLOT(disconnectPl()));*/
    }
    m_model->add(path);
    return 0;
}

void TrackListObject::DelTrack(int in0)
{
    m_model->removeTrack(in0);
}

int TrackListObject::GetCurrentTrack()
{
    return m_model->currentIndex();
}

int TrackListObject::GetLength()
{
    return m_model->numberOfTrack(m_model->count() - 1) + 1;
}

QVariantMap TrackListObject::GetMetadata(int in0)
{
    QVariantMap map;
    PlayListTrack *track = 0;
    int track_counter = 0;
    for(int i = 0; i <m_model->count(); i++)
    {
        if(m_model->isTrack(i))
            track_counter++;
        else
            continue;
        if(track_counter - 1 == in0)
        {
            track = m_model->track(i);
            break;
        }
    }

    if (track)
    {
        if (track->url().contains("://"))
            map.insert("location", track->url());
        else
            map.insert("location", "file://" + track->url());
        map.insert("title", track->value(Qmmp::TITLE));
        map.insert("artist", track->value(Qmmp::ARTIST));
        map.insert("album", track->value(Qmmp::ALBUM));
        map.insert("tracknumber", track->value(Qmmp::TRACK));
        map.insert("time", (quint32)track->length());
        map.insert("mtime", (quint32)track->length() * 1000);
        map.insert("genre", track->value(Qmmp::GENRE));
        map.insert("comment", track->value(Qmmp::COMMENT));
        map.insert("year", track->value(Qmmp::YEAR).toUInt());
    }
    return map;
}

void TrackListObject::SetLoop(bool in0)
{