summaryrefslogtreecommitdiff
path: root/src/videopreview/videopreviewconfigdialog.cpp
blob: 62073173f5c76c4cf8a6c1070a3f19daccaebac7 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*  smplayer, GUI front-end for mplayer.
    Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>

    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 "videopreviewconfigdialog.h"
#include <QImageReader>
#include <QPushButton>

VideoPreviewConfigDialog::VideoPreviewConfigDialog( QWidget* parent, Qt::WindowFlags f )
	: QDialog(parent, f)
{
	setupUi(this);

	button_box->button(QDialogButtonBox::Ok)->setText(tr("&OK"));
	button_box->button(QDialogButtonBox::Cancel)->setText(tr("&Cancel"));

	connect(filename_edit, SIGNAL(textChanged(const QString &)),
            this, SLOT(filenameChanged(const QString &)) );

	dvd_device_label->setVisible(false);
	dvd_device_edit->setVisible(false);

	aspect_ratio_combo->addItem(tr("Default"), 0);
	aspect_ratio_combo->addItem("4:3", (double) 4/3);
	aspect_ratio_combo->addItem("16:9", (double) 16/9);
	aspect_ratio_combo->addItem("2.35:1", 2.35);

	format_combo->addItem("png", VideoPreview::PNG);
	if (QImageReader::supportedImageFormats().contains("jpg")) {
		format_combo->addItem("jpg", VideoPreview::JPEG);
	}

	filename_edit->setWhatsThis( tr("The preview will be created for the video you specify here.") );
	dvd_device_edit->setWhatsThis( tr("Enter here the DVD device or a folder with a DVD image.") );
	columns_spin->setWhatsThis( tr("The thumbnails will be arranged on a table.") +" "+ tr("This option specifies the number of columns of the table.") );
	rows_spin->setWhatsThis( tr("The thumbnails will be arranged on a table.") +" "+ tr("This option specifies the number of rows of the table.") );
	osd_check->setWhatsThis( tr("If you check this option, the playing time will be displayed at the bottom of each thumbnail.") );
	aspect_ratio_combo->setWhatsThis( tr("If the aspect ratio of the video is wrong, you can specify a different one here.") );
	initial_step_spin->setWhatsThis( tr("Usually the first frames are black, so it's a good idea to skip some seconds at the beginning of the video. "
                                        "This option allows to specify how many seconds will be skipped.") );
	max_width_spin->setWhatsThis( tr("This option specifies the maximum width in pixels that the generated preview image will have.") );
	format_combo->setWhatsThis( tr("Some frames will be extracted from the video in order to create the preview. Here you can choose "
                                   "the image format for the extracted frames. PNG may give better quality.") );

	layout()->setSizeConstraint(QLayout::SetFixedSize);
}

VideoPreviewConfigDialog::~VideoPreviewConfigDialog() {
}

void VideoPreviewConfigDialog::setVideoFile(const QString & video_file) {
	filename_edit->setText(video_file);
}

QString VideoPreviewConfigDialog::videoFile() {
	return filename_edit->text();
}

void VideoPreviewConfigDialog::setDVDDevice(const QString & dvd_device) {
	dvd_device_edit->setText(dvd_device);
}

QString VideoPreviewConfigDialog::DVDDevice() {
	return dvd_device_edit->text();
}

void VideoPreviewConfigDialog::setCols(int cols) {
	columns_spin->setValue(cols);
}

int VideoPreviewConfigDialog::cols() {
	return columns_spin->value();
}

void VideoPreviewConfigDialog::setRows(int rows) {
	rows_spin->setValue(rows);
}

int VideoPreviewConfigDialog::rows() {
	return rows_spin->value();
}

void VideoPreviewConfigDialog::setInitialStep(int step) {
	initial_step_spin->setValue(step);
}

int VideoPreviewConfigDialog::initialStep() {
	return initial_step_spin->value();
}

void VideoPreviewConfigDialog::setMaxWidth(int w) {
	max_width_spin->setValue(w);
}

int VideoPreviewConfigDialog::maxWidth() {
	return max_width_spin->value();
}

void VideoPreviewConfigDialog::setDisplayOSD(bool b) {
	osd_check->setChecked(b);
}

bool VideoPreviewConfigDialog::displayOSD() {
	return osd_check->isChecked();
}

void VideoPreviewConfigDialog::setAspectRatio(double asp) {
	int idx = aspect_ratio_combo->findData(asp);
	if (idx < 0) idx = 0;
	aspect_ratio_combo->setCurrentIndex(idx);
}

double VideoPreviewConfigDialog::aspectRatio() {
	int idx = aspect_ratio_combo->currentIndex();
	return aspect_ratio_combo->itemData(idx).toDouble();
}

void VideoPreviewConfigDialog::setFormat(VideoPreview::ExtractFormat format) {
	int idx = format_combo->findData(format);
	if (idx < 0) idx = 0;
	format_combo->setCurrentIndex(idx);
}

VideoPreview::ExtractFormat VideoPreviewConfigDialog::format() {
	int idx = format_combo->currentIndex();
	return (VideoPreview::ExtractFormat) format_combo->itemData(idx).toInt();
}

void VideoPreviewConfigDialog::setSaveLastDirectory(bool b) {
	save_last_directory_check->setChecked(b);
}

bool VideoPreviewConfigDialog::saveLastDirectory() {
	return save_last_directory_check->isChecked();
}

void VideoPreviewConfigDialog::filenameChanged(const QString & text) {
	qDebug("VideoPreviewConfigDialog::filenameChanged");

	bool b = text.startsWith("dvd:");
	dvd_device_label->setVisible(b);
	dvd_device_edit->setVisible(b);
}

#include "moc_videopreviewconfigdialog.cpp"