summaryrefslogtreecommitdiff
path: root/src/videoequalizer.cpp
blob: 29e91dc3db333b353222c8011b0442caad970990 (plain)
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
/*  smplayer, GUI front-end for mplayer.
    Copyright (C) 2006-2010 Ricardo Villalba <rvm@escomposlinux.org>

    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
*/

#include "videoequalizer.h"
#include "eqslider.h"
#include "images.h"
#include "preferences.h"
#include "global.h"
#include <QLayout>
#include <QPushButton>
#include <QMessageBox>

using namespace Global;

VideoEqualizer::VideoEqualizer( QWidget* parent, Qt::WindowFlags f)
	: QWidget(parent, f)
{
	contrast = new EqSlider(this);
	brightness = new EqSlider(this);
	hue = new EqSlider(this);
	saturation = new EqSlider(this);
	gamma = new EqSlider(this);

	QBoxLayout *bl = new QHBoxLayout; //(0, 4, 2);
	bl->addWidget(contrast);
	bl->addWidget(brightness);
	bl->addWidget(hue);
	bl->addWidget(saturation);
	bl->addWidget(gamma);

	reset_button = new QPushButton( "&Reset", this);
	connect( reset_button, SIGNAL(clicked()), this, SLOT(reset()) );
	set_default_button = new QPushButton( "&Set as default values", this );
	connect( set_default_button, SIGNAL(clicked()), this, SLOT(setDefaults()) );

	QBoxLayout *button_layout = new QVBoxLayout; //(0, 4, 2);
	button_layout->addWidget(set_default_button);
	button_layout->addWidget(reset_button);

	QBoxLayout *layout = new QVBoxLayout(this); //, 4, 2);
	layout->addLayout(bl);
	layout->addLayout(button_layout);

	retranslateStrings();

	adjustSize();
	//setFixedSize( sizeHint() );
}

VideoEqualizer::~VideoEqualizer() {
}

void VideoEqualizer::retranslateStrings() {
	setWindowTitle( tr("Video Equalizer") );
	setWindowIcon( Images::icon("logo") );

	contrast->setLabel( tr("Contrast") );
	contrast->setToolTip( tr("Contrast") );
	contrast->setIcon( Images::icon("contrast") );

	brightness->setLabel( tr("Brightness") );
	brightness->setToolTip( tr("Brightness") );
	brightness->setIcon( Images::icon("brightness") );

	hue->setLabel( tr("Hue") );
	hue->setToolTip( tr("Hue") );
	hue->setIcon( Images::icon("hue") );

	saturation->setLabel( tr("Saturation") );
	saturation->setToolTip( tr("Saturation") );
	saturation->setIcon( Images::icon("saturation") );

	gamma->setLabel( tr("Gamma") );
	gamma->setToolTip( tr("Gamma") );
	gamma->setIcon( Images::icon("gamma") );

	reset_button->setText( tr("&Reset") );
	set_default_button->setText( tr("&Set as default values") );

	// What's this help:
	set_default_button->setWhatsThis(
			tr("Use the current values as default values for new videos.") );

	reset_button->setWhatsThis( tr("Set all controls to zero.") );

}

void VideoEqualizer::reset() {
	contrast->setValue(0);
	brightness->setValue(0);
	hue->setValue(0);
	saturation->setValue(0);
	gamma->setValue(0);
}

void VideoEqualizer::setDefaults() {
	pref->initial_contrast = contrast->value();
	pref->initial_brightness = brightness->value();
	pref->initial_hue = hue->value();
	pref->initial_saturation = saturation->value();
	pref->initial_gamma = gamma->value();

	QMessageBox::information(this, tr("Information"), 
                             tr("The current values have been stored to be "
                                "used as default.") );
}

void VideoEqualizer::hideEvent( QHideEvent * ) {
	emit visibilityChanged();
}

void VideoEqualizer::showEvent( QShowEvent * ) {
	emit visibilityChanged();
}

// Language change stuff
void VideoEqualizer::changeEvent(QEvent *e) {
	if (e->type() == QEvent::LanguageChange) {
		retranslateStrings();
	} else {
		QWidget::changeEvent(e);
	}
}

#include "moc_videoequalizer.cpp"