#include <QDir>
#include <QInputDialog>
#include <QSettings>
+#include <QUrl>
#define VALID_DIR(PATH) ((!(PATH).isEmpty()) && QFileInfo(PATH).exists() && QFileInfo(PATH).isDir())
connect(cbxTemplate, SIGNAL(currentIndexChanged(int)), this, SLOT(templateSelected()));
//Load directories
- const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+ const QString appDir = x264_data_path();
QSettings settings(QString("%1/last.ini").arg(appDir), QSettings::IniFormat);
initialDir_src = settings.value("path/directory_openFrom", initialDir_src).toString();
initialDir_out = settings.value("path/directory_saveTo", initialDir_out).toString();
return false;
}
+void AddJobDialog::dragEnterEvent(QDragEnterEvent *event)
+{
+ QStringList formats = event->mimeData()->formats();
+
+ if(formats.contains("application/x-qt-windows-mime;value=\"FileNameW\"", Qt::CaseInsensitive) && formats.contains("text/uri-list", Qt::CaseInsensitive))
+ {
+ event->acceptProposedAction();
+ }
+}
+
+void AddJobDialog::dropEvent(QDropEvent *event)
+{
+ QString droppedFile;
+ QList<QUrl> urls = event->mimeData()->urls();
+
+ if(urls.count() > 1)
+ {
+ QDragEnterEvent dragEvent(event->pos(), event->proposedAction(), event->mimeData(), Qt::NoButton, Qt::NoModifier);
+ if(qApp->notify(parent(), &dragEvent))
+ {
+ qApp->notify(parent(), event);
+ reject(); return;
+ }
+ }
+
+ while((!urls.isEmpty()) && droppedFile.isEmpty())
+ {
+ QUrl currentUrl = urls.takeFirst();
+ QFileInfo file(currentUrl.toLocalFile());
+ if(file.exists() && file.isFile())
+ {
+ qDebug("AddJobDialog::dropEvent: %s", file.canonicalFilePath().toUtf8().constData());
+ droppedFile = file.canonicalFilePath();
+ }
+ }
+
+ if(!droppedFile.isEmpty())
+ {
+ editSource->setText(QDir::toNativeSeparators(droppedFile));
+ generateOutputFileName(droppedFile);
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
// Slots
///////////////////////////////////////////////////////////////////////////////
}
if(outputFile.exists() && (!outputFile.isFile()))
{
- QMessageBox::warning(this, tr("Not a File!"), tr("<nobr>Selected output files does not appear to be a file!</nobr>"));
+ QMessageBox::warning(this, tr("Not a File!"), tr("<nobr>Selected output file does not appear to be a valid file!</nobr>"));
return;
}
if(!editCustomParams->hasAcceptableInput())
}
//Save directories
- const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+ const QString appDir = x264_data_path();
QSettings settings(QString("%1/last.ini").arg(appDir), QSettings::IniFormat);
if(settings.isWritable())
{
// Constructor & Destructor
///////////////////////////////////////////////////////////////////////////////
+/*
+ * Constructor
+ */
MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures)
:
m_cpuFeatures(cpuFeatures),
m_appDir(QApplication::applicationDirPath()),
+ m_options(NULL),
+ m_jobList(NULL),
+ m_droppedFiles(NULL),
m_firstShow(true)
{
//Init the dialog, from the .ui file
updateLabelPos();
}
+/*
+ * Destructor
+ */
MainWindow::~MainWindow(void)
{
OptionsModel::saveTemplate(m_options, QString::fromLatin1(tpl_last));
X264_DELETE(m_jobList);
X264_DELETE(m_options);
+ X264_DELETE(m_droppedFiles);
X264_DELETE(m_label);
while(!m_toolsList.isEmpty())
// Slots
///////////////////////////////////////////////////////////////////////////////
+/*
+ * The "add" button was clicked
+ */
void MainWindow::addButtonPressed(const QString &filePath, int fileNo, int fileTotal, bool *ok)
{
+ qDebug("MainWindow::addButtonPressed");
+
if(ok) *ok = false;
AddJobDialog *addDialog = new AddJobDialog(this, m_options, m_cpuFeatures->x64);
X264_DELETE(addDialog);
}
+/*
+ * The "start" button was clicked
+ */
void MainWindow::startButtonPressed(void)
{
m_jobList->startJob(jobsView->currentIndex());
}
+/*
+ * The "abort" button was clicked
+ */
void MainWindow::abortButtonPressed(void)
{
m_jobList->abortJob(jobsView->currentIndex());
}
+/*
+ * The "delete" button was clicked
+ */
void MainWindow::deleteButtonPressed(void)
{
m_jobList->deleteJob(jobsView->currentIndex());
m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
}
+/*
+ * The "browse" button was clicked
+ */
void MainWindow::browseButtonPressed(void)
{
QString outputFile = m_jobList->getJobOutputFile(jobsView->currentIndex());
}
}
+/*
+ * The "pause" button was clicked
+ */
void MainWindow::pauseButtonPressed(bool checked)
{
if(checked)
}
}
+/*
+ * Job item selected by user
+ */
void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & previous)
{
qDebug("Job selected: %d", current.row());
progressBar->repaint();
}
+/*
+ * Handle update of job info (status, progress, details, etc)
+ */
void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
int selected = jobsView->currentIndex().row();
}
}
+/*
+ * Handle new log file content
+ */
void MainWindow::jobLogExtended(const QModelIndex & parent, int start, int end)
{
QTimer::singleShot(0, logView, SLOT(scrollToBottom()));
}
+/*
+ * About screen
+ */
void MainWindow::showAbout(void)
{
QString text;
}
}
+/*
+ * Open web-link
+ */
void MainWindow::showWebLink(void)
{
if(QObject::sender() == actionWebMulder) QDesktopServices::openUrl(QUrl(home_url));
if(QObject::sender() == actionWebSecret) QDesktopServices::openUrl(QUrl("http://www.youtube.com/watch_popup?v=AXIeHY-OYNI"));
}
+/*
+ * Pereferences dialog
+ */
void MainWindow::showPreferences(void)
{
PreferencesDialog *preferences = new PreferencesDialog(this, &m_preferences, m_cpuFeatures->x64);
X264_DELETE(preferences);
}
+/*
+ * Launch next job, after running job has finished
+ */
void MainWindow::launchNextJob(void)
{
qDebug("launchNextJob(void)");
qWarning("No enqueued jobs left!");
}
+/*
+ * Shut down the computer (with countdown)
+ */
void MainWindow::shutdownComputer(void)
{
qDebug("shutdownComputer(void)");
}
}
+/*
+ * Main initialization function (called only once!)
+ */
void MainWindow::init(void)
{
static const char *binFiles = "x264.exe:x264_x64.exe:avs2yuv.exe:avs2yuv_x64.exe";
{
bool ok = false;
static const char *data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
- QFile writeTest(QString("%1/%2").arg(QApplication::applicationDirPath(), QUuid::createUuid().toString()));
+ QFile writeTest(QString("%1/%2").arg(x264_data_path(), QUuid::createUuid().toString()));
if(writeTest.open(QIODevice::WriteOnly))
{
ok = (writeTest.write(data) == strlen(data));
}
}
+/*
+ * Update the label position
+ */
void MainWindow::updateLabelPos(void)
{
const QWidget *const viewPort = jobsView->viewport();
m_label->setGeometry(0, 0, viewPort->width(), viewPort->height());
}
+/*
+ * Copy the complete log to the clipboard
+ */
void MainWindow::copyLogToClipboard(bool checked)
{
qDebug("copyLogToClipboard");
}
}
+/*
+ * Process the dropped files
+ */
+void MainWindow::handleDroppedFiles(void)
+{
+ qDebug("MainWindow::handleDroppedFiles");
+ if(m_droppedFiles)
+ {
+ QStringList droppedFiles(*m_droppedFiles);
+ m_droppedFiles->clear();
+ int totalFiles = droppedFiles.count();
+ bool ok = true; int n = 0;
+ while((!droppedFiles.isEmpty()) && ok)
+ {
+ QString currentFile = droppedFiles.takeFirst();
+ qDebug("Adding file: %s", currentFile.toUtf8().constData());
+ addButtonPressed(currentFile, n++, totalFiles, &ok);
+ }
+ }
+ qDebug("Leave from MainWindow::handleDroppedFiles!");
+}
+
///////////////////////////////////////////////////////////////////////////////
// Event functions
///////////////////////////////////////////////////////////////////////////////
+/*
+ * Window shown event
+ */
void MainWindow::showEvent(QShowEvent *e)
{
QMainWindow::showEvent(e);
}
}
+/*
+ * Window close event
+ */
void MainWindow::closeEvent(QCloseEvent *e)
{
if(countRunningJobs() > 0)
QMainWindow::closeEvent(e);
}
+/*
+ * Window resize event
+ */
void MainWindow::resizeEvent(QResizeEvent *e)
{
QMainWindow::resizeEvent(e);
QFileInfo file(currentUrl.toLocalFile());
if(file.exists() && file.isFile())
{
- qDebug("Dropped File: %s", file.canonicalFilePath().toUtf8().constData());
+ qDebug("MainWindow::dropEvent: %s", file.canonicalFilePath().toUtf8().constData());
droppedFiles << file.canonicalFilePath();
}
}
- droppedFiles.sort();
- int totalFiles = droppedFiles.count();
-
- bool ok = true; int n = 0;
- while((!droppedFiles.isEmpty()) && ok)
+ if(droppedFiles.count() > 0)
{
- QString currentFile = droppedFiles.takeFirst();
- qDebug("Adding file: %s", currentFile.toUtf8().constData());
- addButtonPressed(currentFile, n++, totalFiles, &ok);
+ if(!m_droppedFiles)
+ {
+ m_droppedFiles = new QStringList();
+ }
+ m_droppedFiles->append(droppedFiles);
+ m_droppedFiles->sort();
+ QTimer::singleShot(0, this, SLOT(handleDroppedFiles()));
}
}
// Private functions
///////////////////////////////////////////////////////////////////////////////
-/*Jobs that are not completed (or failed, or aborted) yet*/
+/*
+ * Jobs that are not completed (or failed, or aborted) yet
+ */
unsigned int MainWindow::countPendingJobs(void)
{
unsigned int count = 0;
return count;
}
-/*Jobs that are still active, i.e. not terminated or enqueued*/
+/*
+ * Jobs that are still active, i.e. not terminated or enqueued
+ */
unsigned int MainWindow::countRunningJobs(void)
{
unsigned int count = 0;
return count;
}
+/*
+ * Update all buttons with respect to current job status
+ */
void MainWindow::updateButtons(EncodeThread::JobStatus status)
{
qDebug("MainWindow::updateButtons(void)");
editDetails->setEnabled(status != EncodeThread::JobStatus_Paused);
}
-
+/*
+ * Update the taskbar with current job status
+ */
void MainWindow::updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon)
{
qDebug("MainWindow::updateTaskbar(void)");