[137] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[137] | 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 |
|
---|
| 21 | #include "myicon.h"
|
---|
| 22 |
|
---|
| 23 | MyIcon::MyIcon()
|
---|
| 24 | {
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | void MyIcon::setPixmap(QPixmap pix, Mode mode, State state )
|
---|
| 29 | {
|
---|
| 30 | switch(mode)
|
---|
| 31 | {
|
---|
| 32 | case Normal:
|
---|
| 33 | if(state == Off) normalPixOff = pix;
|
---|
| 34 | else normalPixOn = pix; break;
|
---|
| 35 | case MouseOver:
|
---|
| 36 | if(state == Off) mouseOverPixOff = pix;
|
---|
| 37 | else mouseOverPixOn = pix; break;
|
---|
| 38 | case MouseDown:
|
---|
| 39 | if(state == Off) mouseDownPixOff = pix;
|
---|
| 40 | else mouseDownPixOn = pix; break;
|
---|
| 41 | case Disabled:
|
---|
| 42 | if(state == Off) disabledPixOff = pix;
|
---|
| 43 | else disabledPixOn = pix;break;
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | QSize MyIcon::size(Mode mode, State state)
|
---|
| 48 | {
|
---|
| 49 | return pixmap(mode, state).size();
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | QPixmap MyIcon::pixmap(Mode mode, State state) const
|
---|
| 53 | {
|
---|
| 54 | QPixmap p = actualPixmap(mode, state);
|
---|
| 55 | if(p.isNull())
|
---|
| 56 | {
|
---|
| 57 | if(state == Off) return normalPixOff;
|
---|
| 58 | else return normalPixOn;
|
---|
| 59 | }
|
---|
| 60 | else return p;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | QPixmap MyIcon::actualPixmap(Mode mode, State state ) const
|
---|
| 64 | {
|
---|
| 65 | switch(mode)
|
---|
| 66 | {
|
---|
| 67 | case Normal:
|
---|
| 68 | if(state == Off) return normalPixOff;
|
---|
| 69 | else return normalPixOn;
|
---|
| 70 | case MouseOver:
|
---|
| 71 | if(state == Off) return mouseOverPixOff;
|
---|
| 72 | else return mouseOverPixOn;
|
---|
| 73 | case MouseDown:
|
---|
| 74 | if(state == Off) return mouseDownPixOff;
|
---|
| 75 | else return mouseDownPixOn;
|
---|
| 76 | case Disabled:
|
---|
| 77 | if(state == Off) return disabledPixOff;
|
---|
| 78 | else return disabledPixOn;
|
---|
| 79 | }
|
---|
| 80 | return QPixmap();
|
---|
| 81 | }
|
---|