source: smplayer/trunk/src/skingui/qpropertysetter.cpp@ 142

Last change on this file since 142 was 142, checked in by Silvan Scherrer, 12 years ago

SMPlayer: update trunk to 0.8.5

File size: 6.7 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
3 umplayer, Copyright (C) 2010 Ori Rejwan
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20#include "qpropertysetter.h"
21#include "myicon.h"
22#include "images.h"
23#include "actiontools.h"
24
25
26#define ICON_ADD(icon, png) { icon.addPixmap(Images::icon(png, 16), QIcon::Normal, QIcon::Off); \
27 icon.addPixmap(Images::icon(png, 16), QIcon::Active, QIcon::Off); \
28 icon.addPixmap(Images::icon(png, 16), QIcon::Selected, QIcon::Off); \
29 icon.addPixmap(Images::icon(png, 16), QIcon::Disabled, QIcon::Off);}
30
31
32IconSetter* IconSetter::m_instance = 0;
33
34IconSetter::IconSetter(QWidget *parent) :
35 QWidget(parent)
36{
37 logoBgPix = Images::icon("ump-splash-bg");
38 logoSplashPix = Images::icon("ump-splash-highlight");
39 logoPix = Images::icon("ump-splash-logo");
40}
41
42IconSetter* IconSetter::instance()
43{
44 if(m_instance == 0)
45 {
46 m_instance = new IconSetter();
47 }
48 return m_instance;
49}
50
51void IconSetter::removeInstance()
52{
53 if(m_instance)
54 delete m_instance;
55 m_instance = 0;
56}
57
58void IconSetter::setActionIcon(QPixmap pixmap )
59{
60#if 0
61//#define SAVE_ICONS 1
62#define SAVE(name) { QPixmap p = pixmap.copy(n*24, 0, 24, 24); \
63 QString s = "/tmp/" name ".png"; \
64 p.save(s); }
65
66 for(int n = 0; n < 10; ++n )
67 {
68 QIcon icon;
69 icon.addPixmap(pixmap.copy(n*24, 0, 24, 24), QIcon::Normal, QIcon::Off);
70 icon.addPixmap(pixmap.copy(n*24, 24, 24, 24), QIcon::Active, QIcon::Off);
71 icon.addPixmap(pixmap.copy(n*24, 48, 24, 24), QIcon::Selected, QIcon::Off);
72 icon.addPixmap(pixmap.copy(n*24, 72, 24, 24), QIcon::Disabled, QIcon::Off);
73 QAction * action = 0;
74 //ActionTools::findAction("aaa", toolbar_actions);
75 switch(n)
76 {
77 case 0: action = ActionTools::findAction("open_file", toolbar_actions);
78 if (action) ICON_ADD(icon, "file")
79 #if SAVE_ICONS
80 SAVE("open")
81 #endif
82 break;
83 case 1: action = ActionTools::findAction("open_directory", toolbar_actions);
84 if (action) ICON_ADD(icon, "file")
85 #if SAVE_ICONS
86 SAVE("open_folder")
87 #endif
88 break;
89 case 2: action = ActionTools::findAction("open_dvd", toolbar_actions);
90 if (action) ICON_ADD(icon, "file")
91 #if SAVE_ICONS
92 SAVE("dvd")
93 #endif
94 break;
95 case 3: action = ActionTools::findAction("open_url", toolbar_actions);
96 if (action) ICON_ADD(icon, "file")
97 #if SAVE_ICONS
98 SAVE("url")
99 #endif
100 break;
101 case 4: action = ActionTools::findAction("screenshot", toolbar_actions);
102 if (action) ICON_ADD(icon, "file")
103 #if SAVE_ICONS
104 SAVE("screenshot")
105 #endif
106 break;
107 case 5: action = ActionTools::findAction("show_file_properties", toolbar_actions);
108 if (action) ICON_ADD(icon, "file")
109 #if SAVE_ICONS
110 SAVE("info")
111 #endif
112 break;
113 case 6: action = ActionTools::findAction("show_find_sub_dialog", toolbar_actions);
114 if (action) ICON_ADD(icon, "file")
115 #if SAVE_ICONS
116 SAVE("download_subs")
117 #endif
118 break;
119 case 7: action = ActionTools::findAction("show_preferences", toolbar_actions);
120 if (action) ICON_ADD(icon, "file")
121 #if SAVE_ICONS
122 SAVE("prefs")
123 #endif
124 break;
125 }
126 if (action) action->setIcon(icon);
127 }
128#endif
129}
130
131void IconSetter::buttonIcon(int buttonNo, QPixmap pix )
132{
133 MyIcon icon;
134 int w = pix.width();
135 int h = pix.height();
136 icon.setPixmap(pix.copy(0, 0, w, h/4 ), MyIcon::Normal, MyIcon::Off);
137 icon.setPixmap(pix.copy(0, h/4, w, h/4 ), MyIcon::MouseOver, MyIcon::Off);
138 icon.setPixmap(pix.copy(0, h/2, w, h/4 ), MyIcon::MouseDown, MyIcon::Off);
139 icon.setPixmap(pix.copy(0, 3*h/4, w, h/4 ), MyIcon::Disabled, MyIcon::Off);
140 MyIcon icon2;
141 switch(buttonNo)
142 {
143 case 1:
144 playControl->setBackwardIcon(icon);
145 break;
146 case 2:
147 playControl->setPreviousIcon(icon);break;
148 case 3:
149 icon2.setPixmap(pix.copy(0, 0, w/2, h/4 ), MyIcon::Normal, MyIcon::Off);
150 icon2.setPixmap(pix.copy(0, h/4, w/2, h/4 ), MyIcon::MouseOver, MyIcon::Off);
151 icon2.setPixmap(pix.copy(0, h/2, w/2, h/4 ), MyIcon::MouseDown, MyIcon::Off);
152 icon2.setPixmap(pix.copy(0, 3*h/4, w/2, h/4 ), MyIcon::Disabled, MyIcon::Off);
153
154 icon2.setPixmap(pix.copy(w/2, 0, w/2, h/4 ), MyIcon::Normal, MyIcon::On);
155 icon2.setPixmap(pix.copy(w/2, h/4, w/2, h/4 ), MyIcon::MouseOver, MyIcon::On);
156 icon2.setPixmap(pix.copy(w/2, h/2, w/2, h/4 ), MyIcon::MouseDown, MyIcon::On);
157 icon2.setPixmap(pix.copy(w/2, 3*h/4, w/2, h/4 ), MyIcon::Disabled, MyIcon::On);
158
159 playControl->setPlayPauseIcon(icon2);
160 break;
161 case 4:
162 playControl->setStopIcon(icon);break;
163 case 5:
164 playControl->setRecordIcon(icon);break;
165 case 6:
166 playControl->setNextIcon(icon);break;
167 case 7:
168 playControl->setForwardIcon(icon);break;
169
170 }
171}
172
173
174void IconSetter::mediaPanelButtonIcon( int n, QPixmap pix)
175{
176 if(pix.isNull()) return;
177 MyIcon icon;
178 int w = pix.width();
179 int h = pix.height();
180 icon.setPixmap(pix.copy(0, 0, w/2, h/4 ), MyIcon::Normal, MyIcon::Off);
181 icon.setPixmap(pix.copy(0, h/4, w/2, h/4 ), MyIcon::MouseOver, MyIcon::Off);
182 icon.setPixmap(pix.copy(0, h/2, w/2, h/4 ), MyIcon::MouseDown, MyIcon::Off);
183 icon.setPixmap(pix.copy(0, 3*h/4, w/2, h/4 ), MyIcon::Disabled, MyIcon::Off);
184
185 icon.setPixmap(pix.copy(w/2, 0, w/2, h/4 ), MyIcon::Normal, MyIcon::On);
186 icon.setPixmap(pix.copy(w/2, h/4, w/2, h/4 ), MyIcon::MouseOver, MyIcon::On);
187 icon.setPixmap(pix.copy(w/2, h/2, w/2, h/4 ), MyIcon::MouseDown, MyIcon::On);
188 icon.setPixmap(pix.copy(w/2, 3*h/4, w/2, h/4 ), MyIcon::Disabled, MyIcon::On);
189
190 switch(n)
191 {
192 case 1:
193 mediaPanel->setShuffleIcon(icon);break;
194 case 2:
195 mediaPanel->setRepeatIcon(icon);break;
196 }
197}
198
199#include "moc_qpropertysetter.cpp"
Note: See TracBrowser for help on using the repository browser.