summaryrefslogtreecommitdiffstats
path: root/moviedirectoryselectorpage.cpp
blob: 8b0a7285248ffdde4d83494848578bce2a8c900e (plain) (blame)
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
#include "moviedirectoryselectorpage.h"
#include <QGridLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QFileDialog>
#include <QDir>
#include <QLabel>

MovieDirectorySelectorPage::MovieDirectorySelectorPage(QWidget *parent)
		: QWizardPage(parent)
{
	setTitle(tr("Movie Directory Selection"));
	setSubTitle(tr("Select the directory where MP4s are stored and where subtitles will eventually be saved"));
	QGridLayout *layout = new QGridLayout;
	m_directoryEdit = new QLineEdit;
	m_directoryEdit->setText(QLatin1String("/home/anyclip/Desktop/uploaded"));
	registerField("directory", m_directoryEdit);
	connect(m_directoryEdit, SIGNAL(textChanged(const QString&)), this, SIGNAL(completeChanged()));
	QPushButton *button = new QPushButton;
	button->setText(tr("&Browse"));
	button->setAutoDefault(true);
	connect(button, SIGNAL(clicked()), this, SLOT(showSelector()));
	QLabel *instructions = new QLabel;
	instructions->setWordWrap(true);
	instructions->setText(tr("The subtitler will scan your chosen directory for MP4 files and SRT files. It will then make available all MP4s that do not already have a corresponding SRT file. When you move to the next step, the wizard will always use the selected directory for all movie selections."));
	QLabel *directoryLabel = new QLabel;
	directoryLabel->setText(tr("&Directory:"));
	directoryLabel->setBuddy(m_directoryEdit);
	layout->addWidget(directoryLabel, 0, 0);
	layout->addWidget(m_directoryEdit, 0, 1);
	layout->addWidget(button, 0, 2);
	layout->addWidget(instructions, 1, 0, 1, 3);
	setLayout(layout);
}
void MovieDirectorySelectorPage::showSelector()
{
	m_directoryEdit->setText(QFileDialog::getExistingDirectory(this, tr("Choose Movie Directory"), QDir::homePath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
}
bool MovieDirectorySelectorPage::isComplete() const
{
	if (m_directoryEdit->text().isEmpty() || m_directoryEdit->text().isNull())
		return false;
	return QDir(m_directoryEdit->text()).exists();
}