#include "moviedirectoryselectorpage.h" #include #include #include #include #include #include #include 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(QDir::toNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation) + QLatin1String("/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(); }