1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2017 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 |
|
---|
32 | IconSetter* IconSetter::m_instance = 0;
|
---|
33 |
|
---|
34 | IconSetter::IconSetter(QWidget *parent) :
|
---|
35 | QWidget(parent)
|
---|
36 | {
|
---|
37 | }
|
---|
38 |
|
---|
39 | IconSetter* IconSetter::instance()
|
---|
40 | {
|
---|
41 | if(m_instance == 0)
|
---|
42 | {
|
---|
43 | m_instance = new IconSetter();
|
---|
44 | }
|
---|
45 | return m_instance;
|
---|
46 | }
|
---|
47 |
|
---|
48 | void IconSetter::removeInstance()
|
---|
49 | {
|
---|
50 | if(m_instance)
|
---|
51 | delete m_instance;
|
---|
52 | m_instance = 0;
|
---|
53 | }
|
---|
54 |
|
---|
55 | void IconSetter::setActionIcon(QPixmap pixmap )
|
---|
56 | {
|
---|
57 | #if 0
|
---|
58 | //#define SAVE_ICONS 1
|
---|
59 | #define SAVE(name) { QPixmap p = pixmap.copy(n*24, 0, 24, 24); \
|
---|
60 | QString s = "/tmp/" name ".png"; \
|
---|
61 | p.save(s); }
|
---|
62 |
|
---|
63 | for(int n = 0; n < 10; ++n )
|
---|
64 | {
|
---|
65 | QIcon icon;
|
---|
66 | icon.addPixmap(pixmap.copy(n*24, 0, 24, 24), QIcon::Normal, QIcon::Off);
|
---|
67 | icon.addPixmap(pixmap.copy(n*24, 24, 24, 24), QIcon::Active, QIcon::Off);
|
---|
68 | icon.addPixmap(pixmap.copy(n*24, 48, 24, 24), QIcon::Selected, QIcon::Off);
|
---|
69 | icon.addPixmap(pixmap.copy(n*24, 72, 24, 24), QIcon::Disabled, QIcon::Off);
|
---|
70 | QAction * action = 0;
|
---|
71 | //ActionTools::findAction("aaa", toolbar_actions);
|
---|
72 | switch(n)
|
---|
73 | {
|
---|
74 | case 0: action = ActionTools::findAction("open_file", toolbar_actions);
|
---|
75 | if (action) ICON_ADD(icon, "file")
|
---|
76 | #if SAVE_ICONS
|
---|
77 | SAVE("open")
|
---|
78 | #endif
|
---|
79 | break;
|
---|
80 | case 1: action = ActionTools::findAction("open_directory", toolbar_actions);
|
---|
81 | if (action) ICON_ADD(icon, "file")
|
---|
82 | #if SAVE_ICONS
|
---|
83 | SAVE("open_folder")
|
---|
84 | #endif
|
---|
85 | break;
|
---|
86 | case 2: action = ActionTools::findAction("open_dvd", toolbar_actions);
|
---|
87 | if (action) ICON_ADD(icon, "file")
|
---|
88 | #if SAVE_ICONS
|
---|
89 | SAVE("dvd")
|
---|
90 | #endif
|
---|
91 | break;
|
---|
92 | case 3: action = ActionTools::findAction("open_url", toolbar_actions);
|
---|
93 | if (action) ICON_ADD(icon, "file")
|
---|
94 | #if SAVE_ICONS
|
---|
95 | SAVE("url")
|
---|
96 | #endif
|
---|
97 | break;
|
---|
98 | case 4: action = ActionTools::findAction("screenshot", toolbar_actions);
|
---|
99 | if (action) ICON_ADD(icon, "file")
|
---|
100 | #if SAVE_ICONS
|
---|
101 | SAVE("screenshot")
|
---|
102 | #endif
|
---|
103 | break;
|
---|
104 | case 5: action = ActionTools::findAction("show_file_properties", toolbar_actions);
|
---|
105 | if (action) ICON_ADD(icon, "file")
|
---|
106 | #if SAVE_ICONS
|
---|
107 | SAVE("info")
|
---|
108 | #endif
|
---|
109 | break;
|
---|
110 | case 6: action = ActionTools::findAction("show_find_sub_dialog", toolbar_actions);
|
---|
111 | if (action) ICON_ADD(icon, "file")
|
---|
112 | #if SAVE_ICONS
|
---|
113 | SAVE("download_subs")
|
---|
114 | #endif
|
---|
115 | break;
|
---|
116 | case 7: action = ActionTools::findAction("show_preferences", toolbar_actions);
|
---|
117 | if (action) ICON_ADD(icon, "file")
|
---|
118 | #if SAVE_ICONS
|
---|
119 | SAVE("prefs")
|
---|
120 | #endif
|
---|
121 | break;
|
---|
122 | }
|
---|
123 | if (action) action->setIcon(icon);
|
---|
124 | }
|
---|
125 | #endif
|
---|
126 | }
|
---|
127 |
|
---|
128 | void IconSetter::buttonIcon(int buttonNo, QPixmap pix )
|
---|
129 | {
|
---|
130 | MyIcon icon;
|
---|
131 | int w = pix.width();
|
---|
132 | int h = pix.height();
|
---|
133 | icon.setPixmap(pix.copy(0, 0, w, h/4 ), MyIcon::Normal, MyIcon::Off);
|
---|
134 | icon.setPixmap(pix.copy(0, h/4, w, h/4 ), MyIcon::MouseOver, MyIcon::Off);
|
---|
135 | icon.setPixmap(pix.copy(0, h/2, w, h/4 ), MyIcon::MouseDown, MyIcon::Off);
|
---|
136 | icon.setPixmap(pix.copy(0, 3*h/4, w, h/4 ), MyIcon::Disabled, MyIcon::Off);
|
---|
137 | MyIcon icon2;
|
---|
138 | switch(buttonNo)
|
---|
139 | {
|
---|
140 | case 1:
|
---|
141 | playControl->setBackwardIcon(icon);
|
---|
142 | break;
|
---|
143 | case 2:
|
---|
144 | playControl->setPreviousIcon(icon);break;
|
---|
145 | case 3:
|
---|
146 | icon2.setPixmap(pix.copy(0, 0, w/2, h/4 ), MyIcon::Normal, MyIcon::Off);
|
---|
147 | icon2.setPixmap(pix.copy(0, h/4, w/2, h/4 ), MyIcon::MouseOver, MyIcon::Off);
|
---|
148 | icon2.setPixmap(pix.copy(0, h/2, w/2, h/4 ), MyIcon::MouseDown, MyIcon::Off);
|
---|
149 | icon2.setPixmap(pix.copy(0, 3*h/4, w/2, h/4 ), MyIcon::Disabled, MyIcon::Off);
|
---|
150 |
|
---|
151 | icon2.setPixmap(pix.copy(w/2, 0, w/2, h/4 ), MyIcon::Normal, MyIcon::On);
|
---|
152 | icon2.setPixmap(pix.copy(w/2, h/4, w/2, h/4 ), MyIcon::MouseOver, MyIcon::On);
|
---|
153 | icon2.setPixmap(pix.copy(w/2, h/2, w/2, h/4 ), MyIcon::MouseDown, MyIcon::On);
|
---|
154 | icon2.setPixmap(pix.copy(w/2, 3*h/4, w/2, h/4 ), MyIcon::Disabled, MyIcon::On);
|
---|
155 |
|
---|
156 | playControl->setPlayPauseIcon(icon2);
|
---|
157 | break;
|
---|
158 | case 4:
|
---|
159 | playControl->setStopIcon(icon);break;
|
---|
160 | case 5:
|
---|
161 | playControl->setRecordIcon(icon);break;
|
---|
162 | case 6:
|
---|
163 | playControl->setNextIcon(icon);break;
|
---|
164 | case 7:
|
---|
165 | playControl->setForwardIcon(icon);break;
|
---|
166 |
|
---|
167 | }
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | void IconSetter::mediaPanelButtonIcon( int n, QPixmap pix)
|
---|
172 | {
|
---|
173 | if(pix.isNull()) return;
|
---|
174 | MyIcon icon;
|
---|
175 | int w = pix.width();
|
---|
176 | int h = pix.height();
|
---|
177 | icon.setPixmap(pix.copy(0, 0, w/2, h/4 ), MyIcon::Normal, MyIcon::Off);
|
---|
178 | icon.setPixmap(pix.copy(0, h/4, w/2, h/4 ), MyIcon::MouseOver, MyIcon::Off);
|
---|
179 | icon.setPixmap(pix.copy(0, h/2, w/2, h/4 ), MyIcon::MouseDown, MyIcon::Off);
|
---|
180 | icon.setPixmap(pix.copy(0, 3*h/4, w/2, h/4 ), MyIcon::Disabled, MyIcon::Off);
|
---|
181 |
|
---|
182 | icon.setPixmap(pix.copy(w/2, 0, w/2, h/4 ), MyIcon::Normal, MyIcon::On);
|
---|
183 | icon.setPixmap(pix.copy(w/2, h/4, w/2, h/4 ), MyIcon::MouseOver, MyIcon::On);
|
---|
184 | icon.setPixmap(pix.copy(w/2, h/2, w/2, h/4 ), MyIcon::MouseDown, MyIcon::On);
|
---|
185 | icon.setPixmap(pix.copy(w/2, 3*h/4, w/2, h/4 ), MyIcon::Disabled, MyIcon::On);
|
---|
186 |
|
---|
187 | switch(n)
|
---|
188 | {
|
---|
189 | case 1:
|
---|
190 | mediaPanel->setShuffleIcon(icon);break;
|
---|
191 | case 2:
|
---|
192 | mediaPanel->setRepeatIcon(icon);break;
|
---|
193 | }
|
---|
194 | }
|
---|
195 |
|
---|
196 | #include "moc_qpropertysetter.cpp"
|
---|