aboutsummaryrefslogtreecommitdiff
path: root/src/ui/playlisttitlebar.h
blob: 745aab44685c5c9f84ee03478a6802c2d66b577d (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
75
76
77
78
79
/***************************************************************************
 *   Copyright (C) 2007-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.             *
 ***************************************************************************/
#ifndef PLAYLISTTITLEBAR_H
#define PLAYLISTTITLEBAR_H

#include "playlist.h"
#include "pixmapwidget.h"
#include "mainwindow.h"

/**
	@author Ilya Kotov <forkotov02@hotmail.ru>
*/
class Skin;
class MainWindow;
class Button;
class PlayListModel;

class PlayListTitleBar : public PixmapWidget
{
Q_OBJECT
public:
    PlayListTitleBar(QWidget *parent = 0);
    ~PlayListTitleBar();
    void setActive(bool);
    void readSettings();

public slots:
    void showCurrent();
    void setModel(PlayListModel *selected, PlayListModel *previous = 0);

private slots:
    void updateSkin();
    void shade();

private:
    void updatePositions();
    void updatePixmap();
    Skin *m_skin;
    QPoint pos;
    bool m_active;
    PlayList* m_pl;
    MainWindow* m_mw;
    Button* m_close;
    Button* m_shade;
    Button* m_shade2;
    bool m_shaded;
    bool m_align, m_resize;
    int m_ratio;
    int m_height;
    PlayListModel* m_model;
    QString m_text;
    QString m_truncatedText;
    QFont m_font;

protected:
    void resizeEvent(QResizeEvent*);
    void mousePressEvent(QMouseEvent*);
    void mouseReleaseEvent(QMouseEvent*);
    void mouseMoveEvent(QMouseEvent*);
};

#endif
27865f9a5e38> 2015-06-11 06:32:21 +0000 refactoring' href='/qmmp/commit/src/plugins/General/fileops/settingsdialog.cpp?h=main&id=302e62bd7d92da84c7f3085b407916e6a7e8a1bb'>302e62bd7
845322411
520d57d70
2e2a47aa3




302e62bd7
2e2a47aa3





08d61df01
2e2a47aa3


520d57d70
013ee07b5
2e2a47aa3



520d57d70

2e2a47aa3



302e62bd7


7c6e2dd39

302e62bd7

2e2a47aa3

520d57d70
08de867fc

08de867fc
2e2a47aa3








08de867fc


302e62bd7
08de867fc







302e62bd7

08de867fc
302e62bd7
08de867fc

302e62bd7
08de867fc

302e62bd7
08de867fc


302e62bd7
08de867fc
2e2a47aa3



520d57d70
2e2a47aa3
302e62bd7

2e2a47aa3

013ee07b5
2e2a47aa3



08d61df01
2e2a47aa3


3acb1696b
845322411
dc13c73d6
2e2a47aa3
520d57d70

302e62bd7


7c6e2dd39
302e62bd7

2e2a47aa3

520d57d70
2e2a47aa3
302e62bd7

2e2a47aa3
08de867fc


302e62bd7
08de867fc
302e62bd7


520d57d70
























08de867fc


520d57d70



08de867fc


520d57d70
08de867fc
302e62bd7
08de867fc
302e62bd7
08de867fc



520d57d70
08de867fc
302e62bd7
08de867fc
302e62bd7
08de867fc





12fefde04
302e62bd7

12fefde04
08de867fc

12fefde04
08de867fc
12fefde04
08de867fc

520d57d70
08de867fc

302e62bd7
08de867fc
302e62bd7
08de867fc
7c6e2dd39



302e62bd7
7c6e2dd39
16cb4ed99
7c6e2dd39
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
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            
                                                                             
                    
                      
                       

                    
                         
                      
                              
                                         
                    
                         




                                               
                       
                                                                                            
                                               
                                                                                              
 




                                                                 
                                        





                                                          
                                                      


                                                          
 
                                                                                          



                                                                                                         

                                                                           



                                                                                                          


                                                         

                                                                               

                                                                                          

                        
                                                                           

                                      
                  








                                                                 


                                                   
                                                                  







                                                           

                                                             
     
                                                                                             

                                                                                
                                                                                             

                                                                                                       
                                                                      


                                                                                  
                                                                                             
     



                        
                                           
 

                                            

                                           
                               



                                                      
                                                  


                                                      
                                                        
                                                                                          
                                
 

                                                                       


                                                       
                                                     

                                                                                        

 
                                              
 

                                                                      
 


                                      
                                             
     


                                                                                                     
























                                                                                    


        



                                                


     
                                                                 
 
                                             
     
                                                                                                     



                                   
                                                                
 
                                             
     
                                                                                                     





                                  
                                                                                                     

                                                                
                                                                                   

 
                                                       
 
                                  

 
                                            

                                                                                  
                                                                      
                      
                                           
 



                                                                              
                                                                                    
                                     
                          
 
/***************************************************************************
 *   Copyright (C) 2009-2017 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 <QSettings>
#include <QHeaderView>
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
#include <QStandardPaths>
#include <qmmp/qmmp.h>
#include <qmmpui/filedialog.h>
#include <qmmpui/metadataformattermenu.h>
#include "fileops.h"
#include "hotkeydialog.h"
#include "settingsdialog.h"

SettingsDialog::SettingsDialog(QWidget *parent)
        : QDialog(parent)
{
    m_ui.setupUi(this);
    m_ui.tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    m_ui.tableWidget->verticalHeader()->hide();
    m_ui.tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);

    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("FileOps");
    int count = settings.value("count", 0).toInt();
    for (int i = 0; i < count; ++i)
    {
        m_ui.tableWidget->insertRow (i);
        QCheckBox *checkBox = new QCheckBox;
        checkBox->setFocusPolicy (Qt::NoFocus);

        QComboBox *comboBox = new QComboBox;
        comboBox->addItem (tr("Copy"), FileOps::COPY);
        comboBox->addItem (tr("Rename"), FileOps::RENAME);
        comboBox->addItem (tr("Move"), FileOps::MOVE);
        comboBox->addItem (tr("Remove"), FileOps::REMOVE);
        comboBox->setFocusPolicy (Qt::NoFocus);


        checkBox->setChecked(settings.value(QString("enabled_%1").arg(i), true).toBool());
        int ci = comboBox->findData (settings.value(QString("action_%1").arg(i), FileOps::COPY).toInt());
        if (ci >= 0)
            comboBox->setCurrentIndex(ci);

        connect(comboBox, SIGNAL(activated(int)), SLOT(updateLineEdits()));

        ActionItem *item = new ActionItem(settings.value(QString("name_%1").arg(i), "Action").toString());
        item->setPattern(settings.value(QString("pattern_%1").arg(i)).toString());
        item->setDestination(settings.value(QString("destination_%1").arg(i)).toString());

        m_ui.tableWidget->setCellWidget (i, 0, checkBox);
        m_ui.tableWidget->setCellWidget (i, 1, comboBox);
        m_ui.tableWidget->setItem (i, 2, item);
        QTableWidgetItem *item2 = new QTableWidgetItem();
        item2->setText(settings.value(QString("hotkey_%1").arg(i)).toString());
        m_ui.tableWidget->setItem (i, 3, item2);
        m_ui.tableWidget->item (i, 3)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    }
    settings.endGroup();
    connect (m_ui.tableWidget, SIGNAL(currentCellChanged(int,int,int,int)),
             SLOT(updateLineEdits()));
    updateLineEdits();
    createMenus();
}


SettingsDialog::~SettingsDialog()
{}

void SettingsDialog::accept()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("FileOps");
    //remove unused keys
    int count = settings.value("count", 0).toInt();
    for (int i = m_ui.tableWidget->rowCount() - 1; i < count; ++i)
    {
        settings.remove (QString("enabled_%1").arg(i));
        settings.remove (QString("action_%1").arg(i));
        settings.remove (QString("name_%1").arg(i));
        settings.remove (QString("pattern_%1").arg(i));
        settings.remove (QString("destination_%1").arg(i));
    }
    //save actions
    settings.setValue("count", m_ui.tableWidget->rowCount());
    for (int i = 0; i < m_ui.tableWidget->rowCount(); ++i)
    {
        QCheckBox *checkBox = qobject_cast<QCheckBox *>(m_ui.tableWidget->cellWidget (i, 0));
        settings.setValue (QString("enabled_%1").arg(i), checkBox->isChecked());

        QComboBox *comboBox = qobject_cast<QComboBox *>(m_ui.tableWidget->cellWidget (i, 1));
        settings.setValue (QString("action_%1").arg(i), comboBox->itemData (comboBox->currentIndex()));

        ActionItem *item = (ActionItem *) m_ui.tableWidget->item(i,2);
        settings.setValue (QString("name_%1").arg(i), item->text());
        settings.setValue (QString("pattern_%1").arg(i), item->pattern());
        settings.setValue (QString("destination_%1").arg(i), item->destination());
        settings.setValue (QString("hotkey_%1").arg(i), m_ui.tableWidget->item(i,3)->text());
    }
    settings.endGroup();
    QDialog::accept();
}

void SettingsDialog::on_newButton_clicked()
{
    int row = m_ui.tableWidget->rowCount ();
    m_ui.tableWidget->insertRow (row);
    QCheckBox *checkBox = new QCheckBox;
    checkBox->setFocusPolicy (Qt::NoFocus);
    checkBox->setChecked(true);

    QComboBox *comboBox = new QComboBox;
    comboBox->addItem (tr("Copy"), FileOps::COPY);
    comboBox->addItem (tr("Rename"), FileOps::RENAME);
    comboBox->addItem (tr("Move"), FileOps::MOVE);
    comboBox->addItem (tr("Remove"), FileOps::REMOVE);
    comboBox->setFocusPolicy (Qt::NoFocus);