Improved queue support + some GUI redesign.

This commit is contained in:
LoRd_MuldeR 2012-01-29 00:57:47 +01:00
parent 8d1c6d82ee
commit a1e0b85787
9 changed files with 182 additions and 63 deletions

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>640</width> <width>720</width>
<height>512</height> <height>640</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,31 +15,14 @@
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QSplitter" name="splitter"> <widget class="QSplitter" name="splitter">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="handleWidth">
<number>8</number>
</property>
<property name="childrenCollapsible"> <property name="childrenCollapsible">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -69,28 +52,72 @@
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
</widget> </widget>
<widget class="QListView" name="logView"> <widget class="QGroupBox" name="groupBox">
<property name="font"> <property name="title">
<font> <string> Job Details </string>
<family>Lucida Console</family>
</font>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>3</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QListView" name="logView">
<property name="font">
<font>
<family>Lucida Console</family>
</font>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="editDetails">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<widget class="QLineEdit" name="editDetails">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame">
<property name="frameShape"> <property name="frameShape">
@ -182,7 +209,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>640</width> <width>720</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>
@ -220,6 +247,14 @@
</property> </property>
</action> </action>
</widget> </widget>
<tabstops>
<tabstop>buttonAddJob</tabstop>
<tabstop>buttonStartJob</tabstop>
<tabstop>buttonAbortJob</tabstop>
<tabstop>jobsView</tabstop>
<tabstop>logView</tabstop>
<tabstop>editDetails</tabstop>
</tabstops>
<resources> <resources>
<include location="../res/resources.qrc"/> <include location="../res/resources.qrc"/>
</resources> </resources>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -68,7 +68,7 @@ QVariant JobListModel::headerData(int section, Qt::Orientation orientation, int
return QVariant::fromValue<QString>(tr("Progress")); return QVariant::fromValue<QString>(tr("Progress"));
break; break;
case 3: case 3:
return QVariant::fromValue<QString>(tr("Progress Details")); return QVariant::fromValue<QString>(tr("Details"));
break; break;
default: default:
return QVariant(); return QVariant();
@ -115,6 +115,12 @@ QVariant JobListModel::data(const QModelIndex &index, int role) const
case EncodeThread::JobStatus_Running: case EncodeThread::JobStatus_Running:
return QVariant::fromValue<QString>(tr("Running...")); return QVariant::fromValue<QString>(tr("Running..."));
break; break;
case EncodeThread::JobStatus_Running_Pass1:
return QVariant::fromValue<QString>(tr("Running... (Pass 1)"));
break;
case EncodeThread::JobStatus_Running_Pass2:
return QVariant::fromValue<QString>(tr("Running... (Pass 2)"));
break;
case EncodeThread::JobStatus_Completed: case EncodeThread::JobStatus_Completed:
return QVariant::fromValue<QString>(tr("Completed.")); return QVariant::fromValue<QString>(tr("Completed."));
break; break;
@ -160,6 +166,8 @@ QVariant JobListModel::data(const QModelIndex &index, int role) const
return QIcon(":/buttons/find.png"); return QIcon(":/buttons/find.png");
break; break;
case EncodeThread::JobStatus_Running: case EncodeThread::JobStatus_Running:
case EncodeThread::JobStatus_Running_Pass1:
case EncodeThread::JobStatus_Running_Pass2:
return QIcon(":/buttons/play.png"); return QIcon(":/buttons/play.png");
break; break;
case EncodeThread::JobStatus_Completed: case EncodeThread::JobStatus_Completed:

View File

@ -57,21 +57,21 @@ void EncodeThread::encode(void)
{ {
Sleep(1500); Sleep(1500);
for(int i = 0; i <= 100; i++) for(int i = 0; i <= 100; i += 5)
{ {
emit progressChanged(m_jobId, i); emit progressChanged(m_jobId, i);
emit statusChanged(m_jobId, (i % 2) ? JobStatus_Indexing : JobStatus_Running); emit statusChanged(m_jobId, (i % 2) ? JobStatus_Indexing : JobStatus_Running_Pass1);
emit messageLogged(m_jobId, QUuid::createUuid().toString()); emit messageLogged(m_jobId, QUuid::createUuid().toString());
for(int i = 0; i < 5; i++) for(int j = 0; j < 3; j++)
{ {
emit detailsChanged(m_jobId, QUuid::createUuid().toString()); emit detailsChanged(m_jobId, QUuid::createUuid().toString());
Sleep(200); Sleep(120);
} }
if(m_abort) if(m_abort)
{ {
Sleep(1500); Sleep(500);
emit statusChanged(m_jobId, JobStatus_Aborted); emit statusChanged(m_jobId, JobStatus_Aborted);
return; return;
} }
@ -79,5 +79,27 @@ void EncodeThread::encode(void)
Sleep(1500); Sleep(1500);
for(int i = 0; i <= 100; i += 5)
{
emit progressChanged(m_jobId, i);
emit statusChanged(m_jobId, (i % 2) ? JobStatus_Indexing : JobStatus_Running_Pass2);
emit messageLogged(m_jobId, QUuid::createUuid().toString());
for(int j = 0; j < 3; j++)
{
emit detailsChanged(m_jobId, QUuid::createUuid().toString());
Sleep(120);
}
if(m_abort)
{
Sleep(500);
emit statusChanged(m_jobId, JobStatus_Aborted);
return;
}
}
Sleep(250);
emit statusChanged(m_jobId, JobStatus_Completed); emit statusChanged(m_jobId, JobStatus_Completed);
} }

View File

@ -35,10 +35,12 @@ public:
JobStatus_Starting = 1, JobStatus_Starting = 1,
JobStatus_Indexing = 2, JobStatus_Indexing = 2,
JobStatus_Running = 3, JobStatus_Running = 3,
JobStatus_Completed = 4, JobStatus_Running_Pass1 = 4,
JobStatus_Failed = 5, JobStatus_Running_Pass2 = 5,
JobStatus_Aborting = 6, JobStatus_Completed = 6,
JobStatus_Aborted = 7 JobStatus_Failed = 7,
JobStatus_Aborting = 8,
JobStatus_Aborted = 9
}; };
EncodeThread(void); EncodeThread(void);

View File

@ -86,7 +86,7 @@ void MainWindow::addButtonPressed(void)
{ {
EncodeThread *thrd = new EncodeThread(); EncodeThread *thrd = new EncodeThread();
QModelIndex newIndex = m_jobList->insertJob(thrd); QModelIndex newIndex = m_jobList->insertJob(thrd);
jobsView->selectionModel()->setCurrentIndex(newIndex, QItemSelectionModel::ClearAndSelect); jobsView->selectRow(newIndex.row());
} }
void MainWindow::startButtonPressed(void) void MainWindow::startButtonPressed(void)
@ -98,6 +98,7 @@ void MainWindow::abortButtonPressed(void)
{ {
m_jobList->abortJob(jobsView->currentIndex()); m_jobList->abortJob(jobsView->currentIndex());
} }
void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & previous) void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & previous)
{ {
qDebug("Job selected: %d", current.row()); qDebug("Job selected: %d", current.row());
@ -124,11 +125,15 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex &
{ {
for(int i = topLeft.row(); i <= bottomRight.row(); i++) for(int i = topLeft.row(); i <= bottomRight.row(); i++)
{ {
EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
if(i == selected) if(i == selected)
{ {
qDebug("Current job changed status!"); qDebug("Current job changed status!");
updateButtons(m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()))); updateButtons(status);
break; }
if(status == EncodeThread::JobStatus_Completed)
{
QTimer::singleShot(0, this, SLOT(launchNextJob()));
} }
} }
} }
@ -166,15 +171,42 @@ void MainWindow::showAbout(void)
QString text; QString text;
const char *url = "http://mulder.brhack.net/"; const char *url = "http://mulder.brhack.net/";
text += QString().sprintf("<nobr><tt>Simple x264 Launcher v%u.%02u &minus; use 64&minus;Bit x264 with 32&minus;Bit Avisynth<br>", x264_version_major(), x264_version_minor()); text += QString().sprintf("<nobr><tt>Simple x264 Launcher v%u.%02u - use 64-Bit x264 with 32-Bit Avisynth<br>", x264_version_major(), x264_version_minor());
text += QString().sprintf("Copyright (c) 2004&minus;%04d LoRd_MuldeR &lt;mulder2@gmx.de&gt;. Some rights reserved.<br>", qMax(x264_version_date().year(),QDate::currentDate().year())); text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR &lt;mulder2@gmx.de&gt;. Some rights reserved.<br>", qMax(x264_version_date().year(),QDate::currentDate().year()));
text += QString().sprintf("Built on %s at %s with %s for Win&minus;%s.<br><br>", x264_version_date().toString(Qt::ISODate).toLatin1().constData(), x264_version_time(), x264_version_compiler(), x264_version_arch()); text += QString().sprintf("Built on %s at %s with %s for Win-%s.<br><br>", x264_version_date().toString(Qt::ISODate).toLatin1().constData(), x264_version_time(), x264_version_compiler(), x264_version_arch());
text += QString().sprintf("This program is free software: you can redistribute it and/or modify<br>"); text += QString().sprintf("This program is free software: you can redistribute it and/or modify<br>");
text += QString().sprintf("it under the terms of the GNU General Public License &lt;http://www.gnu.org/&gt;.<br>"); text += QString().sprintf("it under the terms of the GNU General Public License &lt;http://www.gnu.org/&gt;.<br>");
text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.<br><br>"); text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.<br><br>");
text += QString().sprintf("Please check the web&minus;site at <a href=\"%s\">%s</a> for updates !!!<br></tt></nobr>", url, url); text += QString().sprintf("Please check the web-site at <a href=\"%s\">%s</a> for updates !!!<br></tt></nobr>", url, url);
QMessageBox::information(this, tr("About..."), text); QMessageBox::information(this, tr("About..."), text.replace("-", "&minus;"));
}
void MainWindow::launchNextJob(void)
{
const int rows = m_jobList->rowCount(QModelIndex());
for(int i = 0; i < rows; i++)
{
EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
if(status == EncodeThread::JobStatus_Running || status == EncodeThread::JobStatus_Running_Pass1 || status == EncodeThread::JobStatus_Running_Pass2)
{
qWarning("Still have a job running, won't launch next yet!");
return;
}
}
for(int i = 0; i < rows; i++)
{
EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
if(status == EncodeThread::JobStatus_Enqueued)
{
m_jobList->startJob(m_jobList->index(i, 0, QModelIndex()));
return;
}
}
qWarning("No enqueued jobs left!");
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -206,5 +238,6 @@ void MainWindow::updateButtons(EncodeThread::JobStatus status)
qDebug("MainWindow::updateButtons(void)"); qDebug("MainWindow::updateButtons(void)");
buttonStartJob->setEnabled(status == EncodeThread::JobStatus_Enqueued); buttonStartJob->setEnabled(status == EncodeThread::JobStatus_Enqueued);
buttonAbortJob->setEnabled(status == EncodeThread::JobStatus_Indexing || status == EncodeThread::JobStatus_Running); buttonAbortJob->setEnabled(status == EncodeThread::JobStatus_Indexing || status == EncodeThread::JobStatus_Running ||
status == EncodeThread::JobStatus_Running_Pass1 || status == EncodeThread::JobStatus_Running_Pass2 );
} }

View File

@ -50,4 +50,5 @@ private slots:
void jobChangedData(const QModelIndex &top, const QModelIndex &bottom); void jobChangedData(const QModelIndex &top, const QModelIndex &bottom);
void jobLogExtended(const QModelIndex & parent, int start, int end); void jobLogExtended(const QModelIndex & parent, int start, int end);
void showAbout(void); void showAbout(void);
void launchNextJob(void);
}; };

View File

@ -66,8 +66,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
@ -80,14 +79,17 @@
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel> <FloatingPointModel>Fast</FloatingPointModel>
<CreateHotpatchableImage>false</CreateHotpatchableImage> <CreateHotpatchableImage>false</CreateHotpatchableImage>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>QtMain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>QtMain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
@ -111,6 +113,7 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\qrc\qrc_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\qrc\qrc_%(Filename).cpp;%(Outputs)</Outputs>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</CustomBuild> </CustomBuild>
<None Include="res\icons\movie.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="src\thread_encode.h"> <CustomBuild Include="src\thread_encode.h">
@ -121,6 +124,7 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild> </CustomBuild>
<ClInclude Include="resource.h" />
<ClInclude Include="src\global.h" /> <ClInclude Include="src\global.h" />
<CustomBuild Include="src\model_jobList.h"> <CustomBuild Include="src\model_jobList.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)"</Command>
@ -162,6 +166,9 @@
<ClCompile Include="tmp\moc\moc_win_main.cpp" /> <ClCompile Include="tmp\moc\moc_win_main.cpp" />
<ClCompile Include="tmp\qrc\qrc_resources.cpp" /> <ClCompile Include="tmp\qrc\qrc_resources.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="x264_launcher.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -22,6 +22,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="ReadMe.txt" /> <None Include="ReadMe.txt" />
<None Include="res\icons\movie.ico">
<Filter>Resource Files</Filter>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\global.h"> <ClInclude Include="src\global.h">
@ -33,6 +36,9 @@
<ClInclude Include="src\version.h"> <ClInclude Include="src\version.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\main.cpp"> <ClCompile Include="src\main.cpp">
@ -89,4 +95,9 @@
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</CustomBuild> </CustomBuild>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="x264_launcher.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project> </Project>