source: smplayer/vendor/current/src/skingui/volumecontrolpanel.cpp@ 137

Last change on this file since 137 was 137, checked in by Silvan Scherrer, 13 years ago

SMPlayer: updated vendor to 0.8.2

File size: 5.0 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2012 Ricardo Villalba <[email protected]>
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 "volumecontrolpanel.h"
21#include <QHBoxLayout>
22#include <QVBoxLayout>
23#include <QEvent>
24#include "widgetactions.h"
25#include "myaction.h"
26#include "actiontools.h"
27
28VolumeControlPanel::VolumeControlPanel(QWidget *parent) :
29 QWidget(parent)
30{
31 setAttribute(Qt::WA_StyledBackground, true);
32 setFixedWidth(108);
33 muteButton = new MyButton(this);
34 maxButton = new MyButton(this);
35 playlistButton = new MyButton(this);
36 equalizerButton = new MyButton(this);
37 fullscreenButton = new MyButton(this);
38 playlistButton->setCheckable(true);
39 equalizerButton->setCheckable(true);
40 fullscreenButton->setCheckable(true);
41 volumeBar = new PanelSeeker(this);
42 volumeBar->setLeftRightMargin(8);
43 volumeBar->setMinimum(0);
44 volumeBar->setMaximum(100);
45 volumeBar->setDelayPeriod(1);
46 volumeBar->setFrozenPeriod(10);
47 QHBoxLayout* upperLayout = new QHBoxLayout;
48 QHBoxLayout* lowerLayout = new QHBoxLayout;
49 QVBoxLayout* mainLayout = new QVBoxLayout;
50 upperLayout->addWidget(muteButton);
51 upperLayout->addWidget(volumeBar);
52 upperLayout->addWidget(maxButton);
53 upperLayout->setContentsMargins(0, 0, 0, 0);
54 upperLayout->setSpacing(0);
55 QSpacerItem* sp1 = new QSpacerItem(1, 10, QSizePolicy::Expanding, QSizePolicy::Preferred);
56 lowerLayout->addSpacerItem(sp1);
57 lowerLayout->addWidget(fullscreenButton);
58 lowerLayout->addWidget(playlistButton);
59 lowerLayout->addWidget(equalizerButton);
60 QSpacerItem* sp2 = new QSpacerItem(1, 10, QSizePolicy::Expanding, QSizePolicy::Preferred);
61 lowerLayout->addSpacerItem(sp2);
62 lowerLayout->setContentsMargins(0, 0, 0, 0);
63 lowerLayout->setSpacing(0);
64 mainLayout->addLayout(upperLayout);
65 mainLayout->addLayout(lowerLayout);
66 mainLayout->setContentsMargins(0,8,5,8);
67 mainLayout->setSpacing(2);
68 setLayout(mainLayout);
69
70 connect(muteButton, SIGNAL(clicked()), this, SLOT(setVolumeMin()));
71 connect(maxButton, SIGNAL(clicked()), this, SLOT(setVolumeMax()));
72
73 connect(volumeBar, SIGNAL(valueChanged(int)), this, SIGNAL(volumeChanged(int)));
74}
75
76void VolumeControlPanel::setButtonIcons( MyButton* button, QPixmap pix)
77{
78 MyIcon icon;
79 int w = pix.width();
80 int h = pix.height();
81 icon.setPixmap(pix.copy(0, 0, w, h/4 ), MyIcon::Normal, MyIcon::Off);
82 icon.setPixmap(pix.copy(0, h/4, w, h/4 ), MyIcon::MouseOver, MyIcon::Off);
83 icon.setPixmap(pix.copy(0, h/2, w, h/4 ), MyIcon::MouseDown, MyIcon::Off);
84 icon.setPixmap(pix.copy(0, 3*h/4, w, h/4 ), MyIcon::Disabled, MyIcon::Off);
85 icon.setPixmap(pix.copy(0, 0, w, h/4 ), MyIcon::Normal, MyIcon::On);
86 icon.setPixmap(pix.copy(0, h/4, w, h/4 ), MyIcon::MouseOver, MyIcon::On);
87 icon.setPixmap(pix.copy(0, h/2, w, h/4 ), MyIcon::MouseDown, MyIcon::On);
88 icon.setPixmap(pix.copy(0, 3*h/4, w, h/4 ), MyIcon::Disabled, MyIcon::On);
89 button->setMyIcon(icon);
90 button->setFixedSize(icon.size(MyIcon::Normal, MyIcon::Off));
91}
92
93void VolumeControlPanel::setActionCollection(QList<QAction*> actions)
94{
95 //ActionTools::findAction("aaa", actions);
96 volumeBar->setEnabled(true);
97 /* volumeSliderAction->installEventFilter(this); */
98 SETACTIONTOBUTTON(playlistButton, "show_playlist");
99 SETACTIONTOBUTTON(fullscreenButton, "fullscreen");
100 SETACTIONTOBUTTON(equalizerButton, "video_equalizer");
101
102 retranslateStrings();
103}
104
105void VolumeControlPanel::setVolume(int value)
106{
107 volumeBar->setSliderValue(value);
108}
109
110/*
111bool VolumeControlPanel::eventFilter(QObject *watched, QEvent *event)
112{
113 if(watched == volumeSliderAction && event->type() == QEvent::EnabledChange)
114 {
115 volumeBar->setEnabled(volumeSliderAction->isEnabled());
116 }
117 return false;
118}
119*/
120
121// Language change stuff
122void VolumeControlPanel::changeEvent(QEvent *e) {
123 if (e->type() == QEvent::LanguageChange) {
124 retranslateStrings();
125 } else {
126 QWidget::changeEvent(e);
127 }
128}
129
130void VolumeControlPanel::retranslateStrings() {
131 if (playlistButton) playlistButton->setToolTip(tr("Playlist"));
132 if (fullscreenButton) fullscreenButton->setToolTip(tr("Fullscreen on/off"));
133 if (equalizerButton) equalizerButton->setToolTip(tr("Video equalizer"));
134}
135
136#include "moc_volumecontrolpanel.cpp"
Note: See TracBrowser for help on using the repository browser.