More code refactoring: Moved most of the Win32 API dependencies into wrapper functions in Global.cpp, which greatly reduces platform-specific includes.

This commit is contained in:
LoRd_MuldeR 2013-10-07 00:01:15 +02:00
parent 7602317652
commit 24217c3b71
26 changed files with 1780 additions and 1483 deletions

View File

@ -312,6 +312,7 @@ del "$(TargetDir)imageformats\q???d4.dll"
<ClCompile Include="src\Filter_ToneAdjust.cpp" /> <ClCompile Include="src\Filter_ToneAdjust.cpp" />
<ClCompile Include="src\Genres.cpp" /> <ClCompile Include="src\Genres.cpp" />
<ClCompile Include="src\Global.cpp" /> <ClCompile Include="src\Global.cpp" />
<ClCompile Include="src\JobObject.cpp" />
<ClCompile Include="src\LockedFile.cpp" /> <ClCompile Include="src\LockedFile.cpp" />
<ClCompile Include="src\Main.cpp" /> <ClCompile Include="src\Main.cpp" />
<ClCompile Include="src\Model_Artwork.cpp" /> <ClCompile Include="src\Model_Artwork.cpp" />
@ -557,6 +558,7 @@ del "$(TargetDir)imageformats\q???d4.dll"
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild> </CustomBuild>
<ClInclude Include="src\JobObject.h" />
<ClInclude Include="src\Tools.h" /> <ClInclude Include="src\Tools.h" />
<CustomBuild Include="src\Tool_WaveProperties.h"> <CustomBuild Include="src\Tool_WaveProperties.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)"</Command>

View File

@ -388,6 +388,9 @@
<ClCompile Include="tmp\MOC_Registry_Encoder.cpp"> <ClCompile Include="tmp\MOC_Registry_Encoder.cpp">
<Filter>Generated Files\MOC</Filter> <Filter>Generated Files\MOC</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\JobObject.cpp">
<Filter>Source Files\Misc</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\Config.h"> <ClInclude Include="src\Config.h">
@ -516,7 +519,7 @@
<ClInclude Include="src\Decoder_Opus.h"> <ClInclude Include="src\Decoder_Opus.h">
<Filter>Header Files\Decoders</Filter> <Filter>Header Files\Decoders</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Registry_Encoder.h"> <ClInclude Include="src\JobObject.h">
<Filter>Header Files\Misc</Filter> <Filter>Header Files\Misc</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
@ -710,6 +713,7 @@
<CustomBuild Include="gui\AboutDialog.ui"> <CustomBuild Include="gui\AboutDialog.ui">
<Filter>Dialogs</Filter> <Filter>Dialogs</Filter>
</CustomBuild> </CustomBuild>
<CustomBuild Include="src\Registry_Encoder.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="res\MainIcon.ico" /> <None Include="res\MainIcon.ico" />

View File

@ -17,6 +17,11 @@ a:visited { color: #0000EE; }
<body> <body>
<h3>LameXP - Version History</h3><br> <h3>LameXP - Version History</h3><br>
<a name="4.09"></a>Changes between v4.08 and v4.09 [<font color="darkred">unreleased</font>]:<br><ul>
<li>Improved internal encoder API, so each encoder can define its own configuration options
<li>Complete overhaul of the file analyzer, resulting in up to 2.5x faster file import speed
</ul><br>
<a name="4.08"></a>Changes between v4.07 and v4.08 [2013-09-04]:<br><ul> <a name="4.08"></a>Changes between v4.07 and v4.08 [2013-09-04]:<br><ul>
<li>Upgraded build environment to Microsoft Visual Studio 2012 with Update-3 <li>Upgraded build environment to Microsoft Visual Studio 2012 with Update-3
<li>Encoder settings (RC mode + bitrate/quality) are now stored separately for each encoder <li>Encoder settings (RC mode + bitrate/quality) are now stored separately for each encoder

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
<context> <context>
<name>MainWindow</name> <name>MainWindow</name>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_MainWindow.cpp" line="730"/> <location filename="../../src/Dialog_MainWindow.cpp" line="719"/>
<source>%n file(s) have been rejected, because read access was not granted!</source> <source>%n file(s) have been rejected, because read access was not granted!</source>
<translation> <translation>
<numerusform>%n file have been rejected, because read access was not granted!</numerusform> <numerusform>%n file have been rejected, because read access was not granted!</numerusform>
@ -39,7 +39,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_MainWindow.cpp" line="734"/> <location filename="../../src/Dialog_MainWindow.cpp" line="723"/>
<source>%n file(s) have been rejected, because they are dummy CDDA files!</source> <source>%n file(s) have been rejected, because they are dummy CDDA files!</source>
<translation> <translation>
<numerusform>%n file have been rejected, because they are dummy CDDA files!</numerusform> <numerusform>%n file have been rejected, because they are dummy CDDA files!</numerusform>
@ -47,7 +47,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_MainWindow.cpp" line="738"/> <location filename="../../src/Dialog_MainWindow.cpp" line="727"/>
<source>%n file(s) have been rejected, because they appear to be Cue Sheet images!</source> <source>%n file(s) have been rejected, because they appear to be Cue Sheet images!</source>
<translation> <translation>
<numerusform>%n file have been rejected, because they appear to be Cue Sheet images!</numerusform> <numerusform>%n file have been rejected, because they appear to be Cue Sheet images!</numerusform>
@ -55,7 +55,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_MainWindow.cpp" line="742"/> <location filename="../../src/Dialog_MainWindow.cpp" line="731"/>
<source>%n file(s) have been rejected, because the file format could not be recognized!</source> <source>%n file(s) have been rejected, because the file format could not be recognized!</source>
<translation> <translation>
<numerusform>%n file have been rejected, because the file format could not be recognized!</numerusform> <numerusform>%n file have been rejected, because the file format could not be recognized!</numerusform>
@ -63,7 +63,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_MainWindow.cpp" line="3802"/> <location filename="../../src/Dialog_MainWindow.cpp" line="3734"/>
<source>%n Instance(s)</source> <source>%n Instance(s)</source>
<translation> <translation>
<numerusform>%n Instance</numerusform> <numerusform>%n Instance</numerusform>
@ -74,7 +74,7 @@
<context> <context>
<name>ProcessingDialog</name> <name>ProcessingDialog</name>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="569"/> <location filename="../../src/Dialog_Processing.cpp" line="556"/>
<source>Encoding: %n file(s) of %1 completed so far, please wait...</source> <source>Encoding: %n file(s) of %1 completed so far, please wait...</source>
<translation> <translation>
<numerusform>Encoding: %n file of %1 completed so far, please wait...</numerusform> <numerusform>Encoding: %n file of %1 completed so far, please wait...</numerusform>
@ -82,7 +82,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="607"/> <location filename="../../src/Dialog_Processing.cpp" line="594"/>
<source>Process was aborted by the user after %n file(s)!</source> <source>Process was aborted by the user after %n file(s)!</source>
<translation> <translation>
<numerusform>Process was aborted by the user after %n file!</numerusform> <numerusform>Process was aborted by the user after %n file!</numerusform>
@ -90,7 +90,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="635"/> <location filename="../../src/Dialog_Processing.cpp" line="623"/>
<source>Error: %1 of %n file(s) failed (%2). Double-click failed items for detailed information!</source> <source>Error: %1 of %n file(s) failed (%2). Double-click failed items for detailed information!</source>
<translation> <translation>
<numerusform>Error: %1 of %n file failed (%2). Double-click failed items for detailed information!</numerusform> <numerusform>Error: %1 of %n file failed (%2). Double-click failed items for detailed information!</numerusform>
@ -98,7 +98,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="635"/> <location filename="../../src/Dialog_Processing.cpp" line="623"/>
<source>%n file(s) skipped</source> <source>%n file(s) skipped</source>
<translation> <translation>
<numerusform>%n file skipped</numerusform> <numerusform>%n file skipped</numerusform>
@ -106,7 +106,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="639"/> <location filename="../../src/Dialog_Processing.cpp" line="627"/>
<source>Error: %1 of %n file(s) failed. Double-click failed items for detailed information!</source> <source>Error: %1 of %n file(s) failed. Double-click failed items for detailed information!</source>
<translation> <translation>
<numerusform>Error: %1 of %n file failed. Double-click failed items for detailed information!</numerusform> <numerusform>Error: %1 of %n file failed. Double-click failed items for detailed information!</numerusform>
@ -114,7 +114,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="653"/> <location filename="../../src/Dialog_Processing.cpp" line="641"/>
<source>All files completed successfully. Skipped %n file(s).</source> <source>All files completed successfully. Skipped %n file(s).</source>
<translation> <translation>
<numerusform>All files completed successfully. Skipped %n file.</numerusform> <numerusform>All files completed successfully. Skipped %n file.</numerusform>
@ -122,7 +122,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="1316"/> <location filename="../../src/Dialog_Processing.cpp" line="1298"/>
<source>%n hour(s)</source> <source>%n hour(s)</source>
<translation> <translation>
<numerusform>%n hour</numerusform> <numerusform>%n hour</numerusform>
@ -130,8 +130,8 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="1317"/> <location filename="../../src/Dialog_Processing.cpp" line="1299"/>
<location filename="../../src/Dialog_Processing.cpp" line="1321"/> <location filename="../../src/Dialog_Processing.cpp" line="1303"/>
<source>%n minute(s)</source> <source>%n minute(s)</source>
<translation> <translation>
<numerusform>%n minute</numerusform> <numerusform>%n minute</numerusform>
@ -139,8 +139,8 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="1322"/> <location filename="../../src/Dialog_Processing.cpp" line="1304"/>
<location filename="../../src/Dialog_Processing.cpp" line="1326"/> <location filename="../../src/Dialog_Processing.cpp" line="1308"/>
<source>%n second(s)</source> <source>%n second(s)</source>
<translation> <translation>
<numerusform>%n second</numerusform> <numerusform>%n second</numerusform>
@ -148,7 +148,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../../src/Dialog_Processing.cpp" line="1327"/> <location filename="../../src/Dialog_Processing.cpp" line="1309"/>
<source>%n millisecond(s)</source> <source>%n millisecond(s)</source>
<translation> <translation>
<numerusform>%n millisecond</numerusform> <numerusform>%n millisecond</numerusform>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@
#define VER_LAMEXP_MINOR_LO 9 #define VER_LAMEXP_MINOR_LO 9
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 1 #define VER_LAMEXP_PATCH 1
#define VER_LAMEXP_BUILD 1357 #define VER_LAMEXP_BUILD 1361
#define VER_LAMEXP_CONFG 1348 #define VER_LAMEXP_CONFG 1348
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -47,13 +47,6 @@
#include <QWindowsVistaStyle> #include <QWindowsVistaStyle>
#include <QWindowsXPStyle> #include <QWindowsXPStyle>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <ShellAPI.h>
#include <MMSystem.h>
//Helper macros //Helper macros
#define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "&minus;")) #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "&minus;"))
#define TRIM_RIGHT(STR) do { while(STR.endsWith(QChar(' ')) || STR.endsWith(QChar('\t')) || STR.endsWith(QChar('\r')) || STR.endsWith(QChar('\n'))) STR.chop(1); } while(0) #define TRIM_RIGHT(STR) do { while(STR.endsWith(QChar(' ')) || STR.endsWith(QChar('\t')) || STR.endsWith(QChar('\r')) || STR.endsWith(QChar('\n'))) STR.chop(1); } while(0)
@ -114,10 +107,7 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta
//Disable "X" button //Disable "X" button
if(firstStart) if(firstStart)
{ {
if(HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE)) lamexp_enable_close_button(this, false);
{
EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
}
} }
//Init images //Init images
@ -220,14 +210,14 @@ int AboutDialog::exec()
{ {
if(m_firstShow) if(m_firstShow)
{ {
if(!playResoureSound("imageres.dll", 5080, true)) if(!lamexp_play_sound_file("imageres.dll", 5080, true))
{ {
PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC); lamexp_play_sound(0, true, L"SystemStart");
} }
} }
else else
{ {
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); lamexp_play_sound(IDR_WAVE_ABOUT, true);
} }
} }
@ -321,7 +311,7 @@ void AboutDialog::openURL(const QString &url)
{ {
if(!QDesktopServices::openUrl(QUrl(url))) if(!QDesktopServices::openUrl(QUrl(url)))
{ {
ShellExecuteW(this->winId(), L"open", QWCHAR(url), NULL, NULL, SW_SHOW); lamexp_exec_shell(this, url);
} }
} }
@ -341,16 +331,17 @@ void AboutDialog::gotoLicenseTab(void)
void AboutDialog::moveDisque(void) void AboutDialog::moveDisque(void)
{ {
int delta = 2; int delta = 2;
LARGE_INTEGER perfCount, perfFrequ; const __int64 perfFrequ = lamexp_perfcounter_frequ();
const __int64 perfCount = lamexp_perfcounter_value();
if(QueryPerformanceFrequency(&perfFrequ) && QueryPerformanceCounter(&perfCount)) if((perfFrequ >= 0) && (perfCount >= 0))
{ {
if(m_disqueDelay != _I64_MAX) if(m_disqueDelay != _I64_MAX)
{ {
const double delay = static_cast<double>(perfCount.QuadPart) - static_cast<double>(m_disqueDelay); const double delay = static_cast<double>(perfCount) - static_cast<double>(m_disqueDelay);
delta = qMax(1, qMin(128, static_cast<int>(ceil(delay / static_cast<double>(perfFrequ.QuadPart) / 0.00512)))); delta = qMax(1, qMin(128, static_cast<int>(ceil(delay / static_cast<double>(perfFrequ) / 0.00512))));
} }
m_disqueDelay = perfCount.QuadPart; m_disqueDelay = perfCount;
} }
if(m_disque) if(m_disque)
@ -876,43 +867,3 @@ QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBi
return toolText; return toolText;
} }
bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
{
HMODULE module = 0;
DWORD flags = SND_RESOURCE;
bool result = false;
QFileInfo libraryFile(library);
if(!libraryFile.isAbsolute())
{
unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
unsigned int result = GetSystemDirectory(buffer, buffSize);
if(result > 0 && result < buffSize)
{
libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
}
_freea(buffer);
}
if(async)
{
flags |= SND_ASYNC;
}
else
{
flags |= SND_SYNC;
}
module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
if(module)
{
result = PlaySound((LPCTSTR) soundId, module, flags);
FreeLibrary(module);
}
return result;
}

View File

@ -85,5 +85,4 @@ private:
void initLicenseTab(void); void initLicenseTab(void);
QString makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo = QString()); QString makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo = QString());
bool playResoureSound(const QString &library, const unsigned long soundId, const bool async);
}; };

View File

@ -33,11 +33,6 @@
#include <QMimeData> #include <QMimeData>
#include <QTimer> #include <QTimer>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
LogViewDialog::LogViewDialog(QWidget *parent) LogViewDialog::LogViewDialog(QWidget *parent)
: :
QDialog(parent), QDialog(parent),
@ -91,7 +86,7 @@ void LogViewDialog::copyButtonClicked(void)
ui->buttonCopy->setIcon(*m_acceptIcon); ui->buttonCopy->setIcon(*m_acceptIcon);
ui->buttonCopy->blockSignals(true); ui->buttonCopy->blockSignals(true);
QTimer::singleShot(1250, this, SLOT(restoreIcon())); QTimer::singleShot(1250, this, SLOT(restoreIcon()));
MessageBeep(MB_ICONINFORMATION); lamexp_beep(lamexp_beep_info);
} }
void LogViewDialog::saveButtonClicked(void) void LogViewDialog::saveButtonClicked(void)

View File

@ -73,13 +73,6 @@
#include <QResource> #include <QResource>
#include <QScrollBar> #include <QScrollBar>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <MMSystem.h>
#include <ShellAPI.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Helper macros // Helper macros
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -88,7 +81,7 @@
{ \ { \
if(m_banner->isVisible() || m_delayedFileTimer->isActive()) \ if(m_banner->isVisible() || m_delayedFileTimer->isActive()) \
{ \ { \
MessageBeep(MB_ICONEXCLAMATION); \ lamexp_beep(lamexp_beep_warning); \
return; \ return; \
} \ } \
} \ } \
@ -168,7 +161,7 @@ while(0)
//#define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP)) //#define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP))
#define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel())) #define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel()))
static const DWORD IDM_ABOUTBOX = 0xEFF0; static const unsigned int IDM_ABOUTBOX = 0xEFF0;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -204,11 +197,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabPageChanged(int))); connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabPageChanged(int)));
//Add system menu //Add system menu
if(HMENU hMenu = ::GetSystemMenu(winId(), FALSE)) lamexp_append_sysmenu(this, IDM_ABOUTBOX, "About...");
{
AppendMenuW(hMenu, MF_SEPARATOR, 0, 0);
AppendMenuW(hMenu, MF_STRING, IDM_ABOUTBOX, L"About...");
}
//-------------------------------- //--------------------------------
// Setup "Source" tab // Setup "Source" tab
@ -758,13 +747,13 @@ void MainWindow::addFolder(const QString &path, bool recursive, bool delayed)
m_banner->show(tr("Scanning folder(s) for files, please wait...")); m_banner->show(tr("Scanning folder(s) for files, please wait..."));
QApplication::processEvents(); QApplication::processEvents();
GetAsyncKeyState(VK_ESCAPE); lamexp_check_escape_state();
while(!folderInfoList.isEmpty()) while(!folderInfoList.isEmpty())
{ {
if(GetAsyncKeyState(VK_ESCAPE) & 0x0001) if(lamexp_check_escape_state())
{ {
MessageBeep(MB_ICONERROR); lamexp_beep(lamexp_beep_error);
qWarning("Operation cancelled by user!"); qWarning("Operation cancelled by user!");
fileList.clear(); fileList.clear();
break; break;
@ -1022,10 +1011,7 @@ void MainWindow::changeEvent(QEvent *e)
} }
//Translate system menu //Translate system menu
if(HMENU hMenu = ::GetSystemMenu(winId(), FALSE)) lamexp_update_sysmenu(this, IDM_ABOUTBOX, ui->buttonAbout->text());
{
ModifyMenu(hMenu, IDM_ABOUTBOX, MF_STRING | MF_BYCOMMAND, IDM_ABOUTBOX, QWCHAR(ui->buttonAbout->text()));
}
//Force resize, if needed //Force resize, if needed
tabPageChanged(ui->tabWidget->currentIndex()); tabPageChanged(ui->tabWidget->currentIndex());
@ -1105,7 +1091,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{ {
if(m_banner->isVisible() || m_delayedFileTimer->isActive()) if(m_banner->isVisible() || m_delayedFileTimer->isActive())
{ {
MessageBeep(MB_ICONEXCLAMATION); lamexp_beep(lamexp_beep_warning);
event->ignore(); event->ignore();
} }
@ -1150,7 +1136,7 @@ void MainWindow::keyPressEvent(QKeyEvent *e)
if(e->modifiers().testFlag(Qt::ControlModifier) && (e->key() == Qt::Key_F5)) if(e->modifiers().testFlag(Qt::ControlModifier) && (e->key() == Qt::Key_F5))
{ {
initializeTranslation(); initializeTranslation();
MessageBeep(MB_ICONINFORMATION); lamexp_beep(lamexp_beep_info);
return; return;
} }
@ -1215,7 +1201,7 @@ bool MainWindow::event(QEvent *e)
bool MainWindow::winEvent(MSG *message, long *result) bool MainWindow::winEvent(MSG *message, long *result)
{ {
if((message->message == WM_SYSCOMMAND) && ((message->wParam & 0xFFF0) == IDM_ABOUTBOX)) if(lamexp_check_sysmenu_msg(message, IDM_ABOUTBOX))
{ {
QTimer::singleShot(0, ui->buttonAbout, SLOT(click())); QTimer::singleShot(0, ui->buttonAbout, SLOT(click()));
*result = 0; *result = 0;
@ -1268,7 +1254,7 @@ void MainWindow::windowShown(void)
m_settings->licenseAccepted(++iAccepted); m_settings->licenseAccepted(++iAccepted);
m_settings->syncNow(); m_settings->syncNow();
QApplication::processEvents(); QApplication::processEvents();
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); lamexp_play_sound(IDR_WAVE_WHAMMY, false);
QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!")); QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!"));
QFileInfo uninstallerInfo = QFileInfo(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath())); QFileInfo uninstallerInfo = QFileInfo(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()));
if(uninstallerInfo.exists()) if(uninstallerInfo.exists())
@ -1277,15 +1263,14 @@ void MainWindow::windowShown(void)
QString uninstallerPath = uninstallerInfo.canonicalFilePath(); QString uninstallerPath = uninstallerInfo.canonicalFilePath();
for(int i = 0; i < 3; i++) for(int i = 0; i < 3; i++)
{ {
HINSTANCE res = ShellExecuteW(reinterpret_cast<HWND>(this->winId()), L"open", QWCHAR(QDir::toNativeSeparators(uninstallerPath)), L"/Force", QWCHAR(QDir::toNativeSeparators(uninstallerDir)), SW_SHOWNORMAL); if(lamexp_exec_shell(this, QDir::toNativeSeparators(uninstallerPath), "/Force", QDir::toNativeSeparators(uninstallerDir))) break;
if(reinterpret_cast<int>(res) > 32) break;
} }
} }
QApplication::quit(); QApplication::quit();
return; return;
} }
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WOOHOO), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); lamexp_play_sound(IDR_WAVE_WOOHOO, false);
m_settings->licenseAccepted(1); m_settings->licenseAccepted(1);
m_settings->syncNow(); m_settings->syncNow();
if(lamexp_version_demo()) showAnnounceBox(); if(lamexp_version_demo()) showAnnounceBox();
@ -1297,7 +1282,7 @@ void MainWindow::windowShown(void)
if(lamexp_current_date_safe() >= lamexp_version_expires()) if(lamexp_current_date_safe() >= lamexp_version_expires())
{ {
qWarning("Binary has expired !!!"); qWarning("Binary has expired !!!");
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); lamexp_play_sound(IDR_WAVE_WHAMMY, false);
if(QMessageBox::warning(this, tr("LameXP - Expired"), QString("%1<br>%2").arg(NOBR(tr("This demo (pre-release) version of LameXP has expired at %1.").arg(lamexp_version_expires().toString(Qt::ISODate))), NOBR(tr("LameXP is free software and release versions won't expire."))), tr("Check for Updates"), tr("Exit Program")) == 0) if(QMessageBox::warning(this, tr("LameXP - Expired"), QString("%1<br>%2").arg(NOBR(tr("This demo (pre-release) version of LameXP has expired at %1.").arg(lamexp_version_expires().toString(Qt::ISODate))), NOBR(tr("LameXP is free software and release versions won't expire."))), tr("Check for Updates"), tr("Exit Program")) == 0)
{ {
checkForUpdates(); checkForUpdates();
@ -1339,7 +1324,7 @@ void MainWindow::windowShown(void)
return; return;
default: default:
QEventLoop loop; QTimer::singleShot(7000, &loop, SLOT(quit())); QEventLoop loop; QTimer::singleShot(7000, &loop, SLOT(quit()));
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WAITING), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); lamexp_play_sound(IDR_WAVE_WAITING, true);
m_banner->show(tr("Skipping update check this time, please be patient..."), &loop); m_banner->show(tr("Skipping update check this time, please be patient..."), &loop);
break; break;
} }
@ -1542,7 +1527,7 @@ void MainWindow::encodeButtonClicked(void)
{ {
QStringList tempFolderParts = tempFolder.split("/", QString::SkipEmptyParts, Qt::CaseInsensitive); QStringList tempFolderParts = tempFolder.split("/", QString::SkipEmptyParts, Qt::CaseInsensitive);
tempFolderParts.takeLast(); tempFolderParts.takeLast();
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_WHAMMY, false);
QString lowDiskspaceMsg = QString("%1<br>%2<br><br>%3<br>%4<br>").arg QString lowDiskspaceMsg = QString("%1<br>%2<br><br>%3<br>%4<br>").arg
( (
NOBR(tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.").arg(QString::number(minimumFreeDiskspaceMultiplier))), NOBR(tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.").arg(QString::number(minimumFreeDiskspaceMultiplier))),
@ -2365,70 +2350,17 @@ void MainWindow::sourceFilesScrollbarMoved(int)
*/ */
void MainWindow::previewContextActionTriggered(void) void MainWindow::previewContextActionTriggered(void)
{ {
const static wchar_t *registryPrefix[2] = { L"SOFTWARE\\", L"SOFTWARE\\Wow6432Node\\" };
const static wchar_t *registryKeys[3] =
{
L"Microsoft\\Windows\\CurrentVersion\\Uninstall\\{97D341C8-B0D1-4E4A-A49A-C30B52F168E9}",
L"Microsoft\\Windows\\CurrentVersion\\Uninstall\\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}",
L"foobar2000"
};
const static wchar_t *appNames[4] = { L"smplayer_portable.exe", L"smplayer.exe", L"MPUI.exe", L"foobar2000.exe" };
const static wchar_t *valueNames[2] = { L"InstallLocation", L"InstallDir" };
QModelIndex index = ui->sourceFileView->currentIndex(); QModelIndex index = ui->sourceFileView->currentIndex();
if(!index.isValid()) if(!index.isValid())
{ {
return; return;
} }
for(size_t i = 0; i < 3; i++) if(!lamexp_open_media_file(m_fileListModel->getFile(index).filePath()))
{ {
for(size_t j = 0; j < 2; j++) qDebug("Player not found, falling back to default application...");
{ QDesktopServices::openUrl(QString("file:///").append(m_fileListModel->getFile(index).filePath()));
QString mplayerPath;
HKEY registryKeyHandle = NULL;
const QString currentKey = WCHAR2QSTR(registryPrefix[j]).append(WCHAR2QSTR(registryKeys[i]));
if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, QWCHAR(currentKey), 0, KEY_READ, &registryKeyHandle) == ERROR_SUCCESS)
{
for(size_t k = 0; k < 2; k++)
{
wchar_t Buffer[4096];
DWORD BuffSize = sizeof(wchar_t*) * 4096;
DWORD DataType = REG_NONE;
if(RegQueryValueExW(registryKeyHandle, valueNames[k], 0, &DataType, reinterpret_cast<BYTE*>(Buffer), &BuffSize) == ERROR_SUCCESS)
{
if((DataType == REG_SZ) || (DataType == REG_EXPAND_SZ) || (DataType == REG_LINK))
{
mplayerPath = WCHAR2QSTR(Buffer);
break;
}
}
}
RegCloseKey(registryKeyHandle);
}
if(!mplayerPath.isEmpty())
{
QDir mplayerDir(mplayerPath);
if(mplayerDir.exists())
{
for(size_t k = 0; k < 4; k++)
{
if(mplayerDir.exists(WCHAR2QSTR(appNames[k])))
{
qDebug("Player found at:\n%s\n", mplayerDir.absoluteFilePath(WCHAR2QSTR(appNames[k])).toUtf8().constData());
QProcess::startDetached(mplayerDir.absoluteFilePath(WCHAR2QSTR(appNames[k])), QStringList() << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath()));
return;
}
}
}
}
}
} }
qDebug("Player not found, falling back to default application...");
QDesktopServices::openUrl(QString("file:///").append(m_fileListModel->getFile(index).filePath()));
} }
/* /*
@ -2750,7 +2682,7 @@ void MainWindow::gotoFavoriteFolder(void)
} }
else else
{ {
MessageBeep(MB_ICONERROR); lamexp_beep(lamexp_beep_error);
m_outputFolderFavoritesMenu->removeAction(item); m_outputFolderFavoritesMenu->removeAction(item);
item->deleteLater(); item->deleteLater();
} }
@ -2822,7 +2754,7 @@ void MainWindow::makeFolderButtonClicked(void)
if(folderName.isEmpty()) if(folderName.isEmpty())
{ {
MessageBeep(MB_ICONERROR); lamexp_beep(lamexp_beep_error);
continue; continue;
} }
@ -2897,7 +2829,7 @@ void MainWindow::showFolderContextActionTriggered(void)
QString path = QDir::toNativeSeparators(m_fileSystemModel->filePath(ui->outputFolderView->currentIndex())); QString path = QDir::toNativeSeparators(m_fileSystemModel->filePath(ui->outputFolderView->currentIndex()));
if(!path.endsWith(QDir::separator())) path.append(QDir::separator()); if(!path.endsWith(QDir::separator())) path.append(QDir::separator());
ShellExecuteW(reinterpret_cast<HWND>(this->winId()), L"explore", QWCHAR(path), NULL, NULL, SW_SHOW); lamexp_exec_shell(this, path, true);
} }
/* /*
@ -2926,7 +2858,7 @@ void MainWindow::goUpFolderContextActionTriggered(void)
} }
else else
{ {
MessageBeep(MB_ICONWARNING); lamexp_beep(lamexp_beep_warning);
} }
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
} }
@ -2947,7 +2879,7 @@ void MainWindow::addFavoriteFolderActionTriggered(void)
} }
else else
{ {
MessageBeep(MB_ICONWARNING); lamexp_beep(lamexp_beep_warning);
} }
m_settings->favoriteOutputFolders(favorites.join("|")); m_settings->favoriteOutputFolders(favorites.join("|"));
@ -3013,7 +2945,7 @@ void MainWindow::outputFolderEditFinished(void)
ui->outputFolderLabel->setVisible(true); ui->outputFolderLabel->setVisible(true);
ui->outputFolderView->setEnabled(true); ui->outputFolderView->setEnabled(true);
if(!ok) MessageBeep(MB_ICONERROR); if(!ok) lamexp_beep(lamexp_beep_error);
CENTER_CURRENT_OUTPUT_FOLDER_DELAYED; CENTER_CURRENT_OUTPUT_FOLDER_DELAYED;
} }
@ -3168,7 +3100,7 @@ void MainWindow::outputFolderMouseEventOccurred(QWidget *sender, QEvent *event)
{ {
QString path = ui->outputFolderLabel->text(); QString path = ui->outputFolderLabel->text();
if(!path.endsWith(QDir::separator())) path.append(QDir::separator()); if(!path.endsWith(QDir::separator())) path.append(QDir::separator());
ShellExecuteW(reinterpret_cast<HWND>(this->winId()), L"explore", QWCHAR(path), NULL, NULL, SW_SHOW); lamexp_exec_shell(this, path, true);
} }
break; break;
case QEvent::Enter: case QEvent::Enter:
@ -3455,7 +3387,7 @@ void MainWindow::compressionTabEventOccurred(QWidget *sender, QEvent *event)
{ {
if(m_settings->soundsEnabled()) if(m_settings->soundsEnabled())
{ {
PlaySound(MAKEINTRESOURCE(IDR_WAVE_BLAST), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); lamexp_play_sound(IDR_WAVE_BLAST, true);
} }
EncoderRegistry::resetAllEncoders(m_settings); EncoderRegistry::resetAllEncoders(m_settings);
@ -3745,7 +3677,7 @@ void MainWindow::renameOutputPatternChanged(const QString &text, bool silent)
{ {
if(ui->lineEditRenamePattern->palette().color(QPalette::Text) != Qt::red) if(ui->lineEditRenamePattern->palette().color(QPalette::Text) != Qt::red)
{ {
if(!silent) MessageBeep(MB_ICONERROR); if(!silent) lamexp_beep(lamexp_beep_error);
SET_TEXT_COLOR(ui->lineEditRenamePattern, Qt::red); SET_TEXT_COLOR(ui->lineEditRenamePattern, Qt::red);
} }
} }
@ -3753,7 +3685,7 @@ void MainWindow::renameOutputPatternChanged(const QString &text, bool silent)
{ {
if(ui->lineEditRenamePattern->palette() != QPalette()) if(ui->lineEditRenamePattern->palette() != QPalette())
{ {
if(!silent) MessageBeep(MB_ICONINFORMATION); if(!silent) lamexp_beep(lamexp_beep_info);
ui->lineEditRenamePattern->setPalette(QPalette()); ui->lineEditRenamePattern->setPalette(QPalette());
} }
} }
@ -3892,13 +3824,13 @@ void MainWindow::customParamsHelpRequested(QWidget *obj, QEvent *event)
case SettingsModel::AAC_ENCODER_QAAC: showCustomParamsHelpScreen("qaac.exe", "--help"); break; case SettingsModel::AAC_ENCODER_QAAC: showCustomParamsHelpScreen("qaac.exe", "--help"); break;
case SettingsModel::AAC_ENCODER_FHG : showCustomParamsHelpScreen("fhgaacenc.exe", ""); break; case SettingsModel::AAC_ENCODER_FHG : showCustomParamsHelpScreen("fhgaacenc.exe", ""); break;
case SettingsModel::AAC_ENCODER_NERO: showCustomParamsHelpScreen("neroAacEnc.exe", "-help"); break; case SettingsModel::AAC_ENCODER_NERO: showCustomParamsHelpScreen("neroAacEnc.exe", "-help"); break;
default: MessageBeep(MB_ICONERROR); break; default: lamexp_beep(lamexp_beep_error); break;
} }
} }
else if(obj == ui->helpCustomParamFLAC) showCustomParamsHelpScreen("flac.exe", "--help"); else if(obj == ui->helpCustomParamFLAC) showCustomParamsHelpScreen("flac.exe", "--help");
else if(obj == ui->helpCustomParamAften) showCustomParamsHelpScreen("aften.exe", "-h"); else if(obj == ui->helpCustomParamAften) showCustomParamsHelpScreen("aften.exe", "-h");
else if(obj == ui->helpCustomParamOpus) showCustomParamsHelpScreen("opusenc.exe", "--help"); else if(obj == ui->helpCustomParamOpus) showCustomParamsHelpScreen("opusenc.exe", "--help");
else MessageBeep(MB_ICONERROR); else lamexp_beep(lamexp_beep_error);
} }
/* /*
@ -3909,7 +3841,7 @@ void MainWindow::showCustomParamsHelpScreen(const QString &toolName, const QStri
const QString binary = lamexp_lookup_tool(toolName); const QString binary = lamexp_lookup_tool(toolName);
if(binary.isEmpty()) if(binary.isEmpty())
{ {
MessageBeep(MB_ICONERROR); lamexp_beep(lamexp_beep_error);
qWarning("customParamsHelpRequested: Binary could not be found!"); qWarning("customParamsHelpRequested: Binary could not be found!");
return; return;
} }
@ -3954,7 +3886,7 @@ void MainWindow::showCustomParamsHelpScreen(const QString &toolName, const QStri
if(output.count() < 1) if(output.count() < 1)
{ {
qWarning("Empty output, cannot show help screen!"); qWarning("Empty output, cannot show help screen!");
MessageBeep(MB_ICONERROR); lamexp_beep(lamexp_beep_error);
} }
LogViewDialog *dialog = new LogViewDialog(this); LogViewDialog *dialog = new LogViewDialog(this);
@ -3984,7 +3916,7 @@ void MainWindow::resetAdvancedOptionsButtonClicked(void)
{ {
if(m_settings->soundsEnabled()) if(m_settings->soundsEnabled())
{ {
PlaySound(MAKEINTRESOURCE(IDR_WAVE_BLAST), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); lamexp_play_sound(IDR_WAVE_BLAST, true);
} }
ui->sliderLameAlgoQuality->setValue(m_settings->lameAlgoQualityDefault()); ui->sliderLameAlgoQuality->setValue(m_settings->lameAlgoQualityDefault());

View File

@ -61,12 +61,6 @@
#include <QResizeEvent> #include <QResizeEvent>
#include <QTime> #include <QTime>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <MMSystem.h>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
@ -358,15 +352,12 @@ void ProcessingDialog::showEvent(QShowEvent *event)
{ {
static const char *NA = " N/A"; static const char *NA = " N/A";
setCloseButtonEnabled(false); lamexp_enable_close_button(this, false);
ui->button_closeDialog->setEnabled(false); ui->button_closeDialog->setEnabled(false);
ui->button_AbortProcess->setEnabled(false); ui->button_AbortProcess->setEnabled(false);
m_systemTray->setVisible(true); m_systemTray->setVisible(true);
if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS)) lamexp_change_process_priority(1);
{
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
}
ui->label_cpu->setText(NA); ui->label_cpu->setText(NA);
ui->label_disk->setText(NA); ui->label_disk->setText(NA);
@ -539,11 +530,7 @@ void ProcessingDialog::initEncoding(void)
qApp->processEvents(); qApp->processEvents();
} }
LARGE_INTEGER counter; m_timerStart = lamexp_perfcounter_value();
if(QueryPerformanceCounter(&counter))
{
m_timerStart = counter.QuadPart;
}
} }
void ProcessingDialog::abortEncoding(bool force) void ProcessingDialog::abortEncoding(bool force)
@ -610,17 +597,18 @@ void ProcessingDialog::doneEncoding(void)
QApplication::processEvents(); QApplication::processEvents();
if(m_settings->soundsEnabled() && !m_forcedAbort) if(m_settings->soundsEnabled() && !m_forcedAbort)
{ {
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); lamexp_play_sound(IDR_WAVE_ABORTED, false);
} }
} }
else else
{ {
LARGE_INTEGER counter, frequency; const __int64 counter = lamexp_perfcounter_value();
if(QueryPerformanceCounter(&counter) && QueryPerformanceFrequency(&frequency)) const __int64 frequency = lamexp_perfcounter_frequ();
if((counter >= 0I64) && (frequency >= 0))
{ {
if((m_timerStart > 0I64) && (frequency.QuadPart > 0I64) && (m_timerStart < counter.QuadPart)) if((m_timerStart >= 0I64) && (m_timerStart < counter))
{ {
double timeElapsed = static_cast<double>(counter.QuadPart - m_timerStart) / static_cast<double>(frequency.QuadPart); double timeElapsed = static_cast<double>(counter - m_timerStart) / static_cast<double>(frequency);
m_progressModel->addSystemMessage(tr("Process finished after %1.").arg(time2text(timeElapsed)), ProgressModel::SysMsg_Performance); m_progressModel->addSystemMessage(tr("Process finished after %1.").arg(time2text(timeElapsed)), ProgressModel::SysMsg_Performance);
} }
} }
@ -641,7 +629,7 @@ void ProcessingDialog::doneEncoding(void)
m_systemTray->showMessage(tr("LameXP - Error"), tr("At least one file has failed!"), QSystemTrayIcon::Critical); m_systemTray->showMessage(tr("LameXP - Error"), tr("At least one file has failed!"), QSystemTrayIcon::Critical);
m_systemTray->setIcon(QIcon(":/icons/cd_delete.png")); m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
QApplication::processEvents(); QApplication::processEvents();
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_ERROR, false);
} }
else else
{ {
@ -659,11 +647,11 @@ void ProcessingDialog::doneEncoding(void)
m_systemTray->showMessage(tr("LameXP - Done"), tr("All files completed successfully."), QSystemTrayIcon::Information); m_systemTray->showMessage(tr("LameXP - Done"), tr("All files completed successfully."), QSystemTrayIcon::Information);
m_systemTray->setIcon(QIcon(":/icons/cd_add.png")); m_systemTray->setIcon(QIcon(":/icons/cd_add.png"));
QApplication::processEvents(); QApplication::processEvents();
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_SUCCESS), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_SUCCESS, false);
} }
} }
setCloseButtonEnabled(true); lamexp_enable_close_button(this, true);
ui->button_closeDialog->setEnabled(true); ui->button_closeDialog->setEnabled(true);
ui->button_AbortProcess->setEnabled(false); ui->button_AbortProcess->setEnabled(false);
ui->checkBox_shutdownComputer->setEnabled(false); ui->checkBox_shutdownComputer->setEnabled(false);
@ -741,7 +729,7 @@ void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index)
} }
else else
{ {
MessageBeep(MB_ICONWARNING); lamexp_beep(lamexp_beep_warning);
} }
} }
@ -781,7 +769,7 @@ void ProcessingDialog::contextMenuShowFileActionTriggered(void)
if(filePath.isEmpty()) if(filePath.isEmpty())
{ {
MessageBeep(MB_ICONWARNING); lamexp_beep(lamexp_beep_warning);
return; return;
} }
@ -812,7 +800,7 @@ void ProcessingDialog::contextMenuShowFileActionTriggered(void)
else else
{ {
qWarning("File not found: %s", filePath.toLatin1().constData()); qWarning("File not found: %s", filePath.toLatin1().constData());
MessageBeep(MB_ICONERROR); lamexp_beep(lamexp_beep_error);
} }
} }
@ -1204,17 +1192,11 @@ AudioFileModel ProcessingDialog::updateMetaInfo(const AudioFileModel &audioFile)
return result; return result;
} }
void ProcessingDialog::setCloseButtonEnabled(bool enabled)
{
HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE);
EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason reason) void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason reason)
{ {
if(reason == QSystemTrayIcon::DoubleClick) if(reason == QSystemTrayIcon::DoubleClick)
{ {
SetForegroundWindow(reinterpret_cast<HWND>(this->winId())); lamexp_bring_to_front(this);
} }
} }
@ -1271,7 +1253,7 @@ bool ProcessingDialog::shutdownComputer(void)
if(m_settings->soundsEnabled()) if(m_settings->soundsEnabled())
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
PlaySound(MAKEINTRESOURCE(IDR_WAVE_SHUTDOWN), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); lamexp_play_sound(IDR_WAVE_SHUTDOWN, false);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@ -1295,7 +1277,7 @@ bool ProcessingDialog::shutdownComputer(void)
progressDialog.setLabelText(text.arg(iTimeout-i)); progressDialog.setLabelText(text.arg(iTimeout-i));
if(iTimeout-i == 3) progressDialog.setCancelButton(NULL); if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
QApplication::processEvents(); QApplication::processEvents();
PlaySound(MAKEINTRESOURCE((i < iTimeout) ? IDR_WAVE_BEEP : IDR_WAVE_BEEP_LONG), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); lamexp_play_sound(((i < iTimeout) ? IDR_WAVE_BEEP : IDR_WAVE_BEEP_LONG), false);
} }
progressDialog.close(); progressDialog.close();

View File

@ -93,7 +93,6 @@ protected:
private: private:
Ui::ProcessingDialog *ui; //for Qt UIC Ui::ProcessingDialog *ui; //for Qt UIC
void setCloseButtonEnabled(bool enabled);
void startNextJob(void); void startNextJob(void);
AudioFileModel updateMetaInfo(const AudioFileModel &audioFile); AudioFileModel updateMetaInfo(const AudioFileModel &audioFile);
void writePlayList(void); void writePlayList(void);

View File

@ -28,11 +28,6 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QTimer> #include <QTimer>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "WinSevenTaskbar.h" #include "WinSevenTaskbar.h"
#define FADE_DELAY 16 #define FADE_DELAY 16
@ -140,7 +135,7 @@ void SplashScreen::showSplash(QThread *thread)
splashScreen->update(); splashScreen->update();
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, FADE_DELAY); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, FADE_DELAY);
SET_TASKBAR_STATE(true); SET_TASKBAR_STATE(true);
Sleep(FADE_DELAY); lamexp_sleep(FADE_DELAY);
} }
//Start the timer //Start the timer
@ -171,7 +166,7 @@ void SplashScreen::showSplash(QThread *thread)
splashScreen->setWindowOpacity(opacity); splashScreen->setWindowOpacity(opacity);
splashScreen->update(); splashScreen->update();
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, FADE_DELAY); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, FADE_DELAY);
Sleep(FADE_DELAY); lamexp_sleep(FADE_DELAY);
} }
//Restore taskbar //Restore taskbar

View File

@ -44,13 +44,6 @@
#include <QMovie> #include <QMovie>
#include <QtConcurrentRun> #include <QtConcurrentRun>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <MMSystem.h>
#include <WinInet.h>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
static const char *header_id = "!Update"; static const char *header_id = "!Update";
@ -169,28 +162,6 @@ static const int MIN_CONNSCORE = 8;
static const int VERSION_INFO_EXPIRES_MONTHS = 6; static const int VERSION_INFO_EXPIRES_MONTHS = 6;
static char *USER_AGENT_STR = "Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111106 IceCat/7.0.1"; static char *USER_AGENT_STR = "Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111106 IceCat/7.0.1";
static BOOL getInternetConnectedState(void)
{
DWORD lpdwFlags = NULL;
BOOL result = InternetGetConnectedState(&lpdwFlags, NULL);
return result;
}
static BOOL CALLBACK focusUpdaterWindow(HWND hwnd, LPARAM lParam)
{
DWORD processId = *reinterpret_cast<WORD*>(lParam);
DWORD windowProcessId = NULL;
GetWindowThreadProcessId(hwnd, &windowProcessId);
if(windowProcessId == processId)
{
SwitchToThisWindow(hwnd, TRUE);
SetForegroundWindow(hwnd);
return FALSE;
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class UpdateInfo class UpdateInfo
@ -245,8 +216,7 @@ UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent)
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
//Disable "X" button //Disable "X" button
HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE); lamexp_enable_close_button(this, false);
EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
//Init animation //Init animation
m_animator = new QMovie(":/images/Loading3.gif"); m_animator = new QMovie(":/images/Loading3.gif");
@ -354,7 +324,7 @@ bool UpdateDialog::event(QEvent *e)
{ {
if((e->type() == QEvent::ActivationChange) && (m_updaterProcess != NULL)) if((e->type() == QEvent::ActivationChange) && (m_updaterProcess != NULL))
{ {
EnumWindows(focusUpdaterWindow, reinterpret_cast<LPARAM>(&m_updaterProcess)); lamexp_bring_process_to_front(m_updaterProcess);
} }
return QDialog::event(e); return QDialog::event(e);
} }
@ -403,7 +373,7 @@ void UpdateDialog::checkForUpdates(void)
m_logFile->clear(); m_logFile->clear();
m_logFile->append("Checking internet connection..."); m_logFile->append("Checking internet connection...");
QFuture<BOOL> connectedState = QtConcurrent::run(getInternetConnectedState); QFuture<bool> connectedState = QtConcurrent::run(lamexp_get_connection_state);
while(!connectedState.isFinished()) while(!connectedState.isFinished())
{ {
QApplication::processEvents(QEventLoop::WaitForMoreEvents); QApplication::processEvents(QEventLoop::WaitForMoreEvents);
@ -425,7 +395,7 @@ void UpdateDialog::checkForUpdates(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
LAMEXP_DELETE(m_updateInfo); LAMEXP_DELETE(m_updateInfo);
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_ERROR, true);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
ui->progressBar->setValue(ui->progressBar->maximum()); ui->progressBar->setValue(ui->progressBar->maximum());
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState); WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState);
@ -458,14 +428,14 @@ void UpdateDialog::checkForUpdates(void)
connectionScore++; connectionScore++;
ui->progressBar->setValue(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1)); ui->progressBar->setValue(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1));
QApplication::processEvents(); QApplication::processEvents();
Sleep(64); lamexp_sleep(64);
} }
if(httpOk) if(httpOk)
{ {
connectionScore++; connectionScore++;
ui->progressBar->setValue(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1)); ui->progressBar->setValue(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1));
QApplication::processEvents(); QApplication::processEvents();
Sleep(64); lamexp_sleep(64);
} }
QFile::remove(outFile); QFile::remove(outFile);
} }
@ -486,7 +456,7 @@ void UpdateDialog::checkForUpdates(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
LAMEXP_DELETE(m_updateInfo); LAMEXP_DELETE(m_updateInfo);
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_ERROR, true);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
ui->progressBar->setValue(ui->progressBar->maximum()); ui->progressBar->setValue(ui->progressBar->maximum());
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState); WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState);
@ -536,7 +506,7 @@ void UpdateDialog::checkForUpdates(void)
else else
{ {
QApplication::processEvents(); QApplication::processEvents();
Sleep(64); lamexp_sleep(64);
} }
} }
@ -560,7 +530,7 @@ void UpdateDialog::checkForUpdates(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
LAMEXP_DELETE(m_updateInfo); LAMEXP_DELETE(m_updateInfo);
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_ERROR, true);
return; return;
} }
@ -581,7 +551,7 @@ void UpdateDialog::checkForUpdates(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_exclamation.png")); WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_exclamation.png"));
MessageBeep(MB_ICONINFORMATION); lamexp_beep(lamexp_beep_info);
} }
else if(m_updateInfo->m_buildNo == lamexp_version_build()) else if(m_updateInfo->m_buildNo == lamexp_version_build())
{ {
@ -592,7 +562,7 @@ void UpdateDialog::checkForUpdates(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_green.png")); WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_green.png"));
MessageBeep(MB_ICONINFORMATION); lamexp_beep(lamexp_beep_info);
} }
else else
{ {
@ -603,7 +573,7 @@ void UpdateDialog::checkForUpdates(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_error.png")); WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_error.png"));
MessageBeep(MB_ICONEXCLAMATION); lamexp_beep(lamexp_beep_warning);
} }
ui->closeButton->setEnabled(true); ui->closeButton->setEnabled(true);
@ -922,7 +892,7 @@ void UpdateDialog::applyUpdate(void)
bool updateStarted = process.waitForStarted(); bool updateStarted = process.waitForStarted();
if(updateStarted) if(updateStarted)
{ {
m_updaterProcess = process.pid()->dwProcessId; m_updaterProcess = lamexp_process_id(&process);
loop.exec(); loop.exec();
} }
m_updaterProcess = NULL; m_updaterProcess = NULL;
@ -995,7 +965,7 @@ void UpdateDialog::testKnownWebSites(void)
m_logFile->clear(); m_logFile->clear();
m_logFile->append("Checking internet connection..."); m_logFile->append("Checking internet connection...");
QFuture<BOOL> connectedState = QtConcurrent::run(getInternetConnectedState); QFuture<bool> connectedState = QtConcurrent::run(lamexp_get_connection_state);
while(!connectedState.isFinished()) while(!connectedState.isFinished())
{ {
QApplication::processEvents(QEventLoop::WaitForMoreEvents); QApplication::processEvents(QEventLoop::WaitForMoreEvents);
@ -1017,7 +987,7 @@ void UpdateDialog::testKnownWebSites(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
LAMEXP_DELETE(m_updateInfo); LAMEXP_DELETE(m_updateInfo);
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_ERROR, true);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
ui->progressBar->setValue(ui->progressBar->maximum()); ui->progressBar->setValue(ui->progressBar->maximum());
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState); WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState);
@ -1078,7 +1048,7 @@ void UpdateDialog::testKnownWebSites(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
LAMEXP_DELETE(m_updateInfo); LAMEXP_DELETE(m_updateInfo);
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); if(m_settings->soundsEnabled()) lamexp_play_sound(IDR_WAVE_ERROR, true);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
ui->progressBar->setValue(ui->progressBar->maximum()); ui->progressBar->setValue(ui->progressBar->maximum());
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState); WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState);
@ -1098,7 +1068,7 @@ void UpdateDialog::testKnownWebSites(void)
ui->hintIcon->show(); ui->hintIcon->show();
ui->hintLabel->show(); ui->hintLabel->show();
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_green.png")); WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_green.png"));
MessageBeep(MB_ICONINFORMATION); lamexp_beep(lamexp_beep_info);
ui->closeButton->setEnabled(true); ui->closeButton->setEnabled(true);
if(ui->retryButton->isVisible()) ui->retryButton->hide(); if(ui->retryButton->isVisible()) ui->retryButton->hide();

View File

@ -25,6 +25,9 @@
#define NOMINMAX #define NOMINMAX
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <Windows.h> #include <Windows.h>
#include <MMSystem.h>
#include <ShellAPI.h>
#include <WinInet.h>
//Qt includes //Qt includes
#include <QApplication> #include <QApplication>
@ -53,6 +56,7 @@
#include <QReadWriteLock> #include <QReadWriteLock>
#include <QReadLocker> #include <QReadLocker>
#include <QWriteLocker> #include <QWriteLocker>
#include <QProcess>
//LameXP includes //LameXP includes
#define LAMEXP_INC_CONFIG #define LAMEXP_INC_CONFIG
@ -2457,6 +2461,382 @@ void lamexp_natural_string_sort(QStringList &list, const bool bIgnoreCase)
qSort(list.begin(), list.end(), bIgnoreCase ? lamexp_natural_string_sort_helper_fold_case : lamexp_natural_string_sort_helper); qSort(list.begin(), list.end(), bIgnoreCase ? lamexp_natural_string_sort_helper_fold_case : lamexp_natural_string_sort_helper);
} }
/*
* Suspend calling thread for N milliseconds
*/
void lamexp_sleep(const unsigned int delay)
{
Sleep(delay);
}
bool lamexp_beep(int beepType)
{
switch(beepType)
{
case lamexp_beep_info: return MessageBeep(MB_ICONASTERISK) == TRUE; break;
case lamexp_beep_warning: return MessageBeep(MB_ICONEXCLAMATION) == TRUE; break;
case lamexp_beep_error: return MessageBeep(MB_ICONHAND) == TRUE; break;
default: return false;
}
}
/*
* Play a sound (from resources)
*/
bool lamexp_play_sound(const unsigned short uiSoundIdx, const bool bAsync, const wchar_t *alias)
{
if(alias)
{
return PlaySound(alias, GetModuleHandle(NULL), (SND_ALIAS | (bAsync ? SND_ASYNC : SND_SYNC))) == TRUE;
}
else
{
return PlaySound(MAKEINTRESOURCE(uiSoundIdx), GetModuleHandle(NULL), (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) == TRUE;
}
}
/*
* Play a sound (from resources)
*/
bool lamexp_play_sound_file(const QString &library, const unsigned short uiSoundIdx, const bool bAsync)
{
bool result = false;
HMODULE module = NULL;
QFileInfo libraryFile(library);
if(!libraryFile.isAbsolute())
{
unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
unsigned int result = GetSystemDirectory(buffer, buffSize);
if(result > 0 && result < buffSize)
{
libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
}
_freea(buffer);
}
module = LoadLibraryW(QWCHAR(QDir::toNativeSeparators(libraryFile.absoluteFilePath())));
if(module)
{
result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) == TRUE);
FreeLibrary(module);
}
return result;
}
/*
* Open file using the shell
*/
bool lamexp_exec_shell(const QWidget *win, const QString &url, const bool explore)
{
return lamexp_exec_shell(win, url, QString(), QString(), explore);
}
/*
* Open file using the shell (with parameters)
*/
bool lamexp_exec_shell(const QWidget *win, const QString &url, const QString &parameters, const QString &directory, const bool explore)
{
return ((int) ShellExecuteW(((win) ? win->winId() : NULL), (explore ? L"explore" : L"open"), QWCHAR(url), ((!parameters.isEmpty()) ? QWCHAR(parameters) : NULL), ((!directory.isEmpty()) ? QWCHAR(directory) : NULL), SW_SHOW)) > 32;
}
/*
* Query value of the performance counter
*/
__int64 lamexp_perfcounter_value(void)
{
LARGE_INTEGER counter;
if(QueryPerformanceCounter(&counter) == TRUE)
{
return counter.QuadPart;
}
return -1;
}
/*
* Query frequency of the performance counter
*/
__int64 lamexp_perfcounter_frequ(void)
{
LARGE_INTEGER frequency;
if(QueryPerformanceFrequency(&frequency) == TRUE)
{
return frequency.QuadPart;
}
return -1;
}
/*
* Insert entry to the window's system menu
*/
bool lamexp_append_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text)
{
bool ok = false;
if(HMENU hMenu = GetSystemMenu(win->winId(), FALSE))
{
ok = (AppendMenuW(hMenu, MF_SEPARATOR, 0, 0) == TRUE);
ok = (AppendMenuW(hMenu, MF_STRING, identifier, QWCHAR(text)) == TRUE);
}
return ok;
}
/*
* Insert entry to the window's system menu
*/
bool lamexp_check_sysmenu_msg(void *message, const unsigned int identifier)
{
return (((MSG*)message)->message == WM_SYSCOMMAND) && ((((MSG*)message)->wParam & 0xFFF0) == identifier);
}
/*
* Update system menu entry
*/
bool lamexp_update_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text)
{
bool ok = false;
if(HMENU hMenu = ::GetSystemMenu(win->winId(), FALSE))
{
ok = (ModifyMenu(hMenu, identifier, MF_STRING | MF_BYCOMMAND, identifier, QWCHAR(text)) == TRUE);
}
return ok;
}
/*
* Display the window's close button
*/
bool lamexp_enable_close_button(const QWidget *win, const bool bEnable)
{
bool ok = false;
if(HMENU hMenu = GetSystemMenu(win->winId(), FALSE))
{
ok = (EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | (bEnable ? MF_ENABLED : MF_GRAYED)) == TRUE);
}
return ok;
}
/*
* Check whether ESC key has been pressed since the previous call to this function
*/
bool lamexp_check_escape_state(void)
{
return (GetAsyncKeyState(VK_ESCAPE) & 0x0001) != 0;
}
/*
* Set the process priority class for current process
*/
bool lamexp_change_process_priority(const int priority)
{
return lamexp_change_process_priority(GetCurrentProcess(), priority);
}
/*
* Set the process priority class for specified process
*/
bool lamexp_change_process_priority(const QProcess *proc, const int priority)
{
return lamexp_change_process_priority(proc->pid()->hProcess, priority);
}
/*
* Set the process priority class for specified process
*/
bool lamexp_change_process_priority(void *hProcess, const int priority)
{
bool ok = false;
switch(qBound(-2, priority, 2))
{
case 2:
ok = (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS) == TRUE);
break;
case 1:
if(!(ok = (SetPriorityClass(hProcess, ABOVE_NORMAL_PRIORITY_CLASS) == TRUE)))
{
ok = (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS) == TRUE);
}
break;
case 0:
ok = (SetPriorityClass(hProcess, NORMAL_PRIORITY_CLASS) == TRUE);
break;
case -1:
if(!(ok = (SetPriorityClass(hProcess, BELOW_NORMAL_PRIORITY_CLASS) == TRUE)))
{
ok = (SetPriorityClass(hProcess, IDLE_PRIORITY_CLASS) == TRUE);
}
break;
case -2:
ok = (SetPriorityClass(hProcess, IDLE_PRIORITY_CLASS) == TRUE);
break;
}
return ok;
}
/*
* Returns the current file time
*/
unsigned __int64 lamexp_current_file_time(void)
{
FILETIME fileTime;
GetSystemTimeAsFileTime(&fileTime);
ULARGE_INTEGER temp;
temp.HighPart = fileTime.dwHighDateTime;
temp.LowPart = fileTime.dwLowDateTime;
return temp.QuadPart;
}
/*
* Bring the specifed window to the front
*/
bool lamexp_bring_to_front(const QWidget *win)
{
const bool ret = (SetForegroundWindow(win->winId()) == TRUE);
SwitchToThisWindow(win->winId(), TRUE);
return ret;
}
/*
* Bring window of the specifed process to the front (callback)
*/
static BOOL CALLBACK lamexp_bring_process_to_front_helper(HWND hwnd, LPARAM lParam)
{
DWORD processId = *reinterpret_cast<WORD*>(lParam);
DWORD windowProcessId = NULL;
GetWindowThreadProcessId(hwnd, &windowProcessId);
if(windowProcessId == processId)
{
SwitchToThisWindow(hwnd, TRUE);
SetForegroundWindow(hwnd);
return FALSE;
}
return TRUE;
}
/*
* Bring window of the specifed process to the front
*/
bool lamexp_bring_process_to_front(const unsigned long pid)
{
return EnumWindows(lamexp_bring_process_to_front_helper, reinterpret_cast<LPARAM>(&pid)) == TRUE;
}
/*
* Check the Internet connection status
*/
bool lamexp_get_connection_state(void)
{
DWORD lpdwFlags = NULL;
BOOL result = InternetGetConnectedState(&lpdwFlags, NULL);
return result == TRUE;
}
/*
* Retrun the process ID of the given QProcess
*/
unsigned long lamexp_process_id(const QProcess *proc)
{
PROCESS_INFORMATION *procInf = proc->pid();
return (procInf) ? procInf->dwProcessId : NULL;
}
/*
* Convert long path to short path
*/
QString lamexp_path_to_short(const QString &longPath)
{
QString shortPath;
DWORD buffSize = GetShortPathNameW(reinterpret_cast<const wchar_t*>(longPath.utf16()), NULL, NULL);
if(buffSize > 0)
{
wchar_t *buffer = new wchar_t[buffSize];
DWORD result = GetShortPathNameW(reinterpret_cast<const wchar_t*>(longPath.utf16()), buffer, buffSize);
if(result > 0 && result < buffSize)
{
shortPath = QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer));
}
delete[] buffer;
}
return (shortPath.isEmpty() ? longPath : shortPath);
}
/*
* Open media file in external player
*/
bool lamexp_open_media_file(const QString &mediaFilePath)
{
const static wchar_t *registryPrefix[2] = { L"SOFTWARE\\", L"SOFTWARE\\Wow6432Node\\" };
const static wchar_t *registryKeys[3] =
{
L"Microsoft\\Windows\\CurrentVersion\\Uninstall\\{97D341C8-B0D1-4E4A-A49A-C30B52F168E9}",
L"Microsoft\\Windows\\CurrentVersion\\Uninstall\\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}",
L"foobar2000"
};
const static wchar_t *appNames[4] = { L"smplayer_portable.exe", L"smplayer.exe", L"MPUI.exe", L"foobar2000.exe" };
const static wchar_t *valueNames[2] = { L"InstallLocation", L"InstallDir" };
for(size_t i = 0; i < 3; i++)
{
for(size_t j = 0; j < 2; j++)
{
QString mplayerPath;
HKEY registryKeyHandle = NULL;
const QString currentKey = WCHAR2QSTR(registryPrefix[j]).append(WCHAR2QSTR(registryKeys[i]));
if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, QWCHAR(currentKey), 0, KEY_READ, &registryKeyHandle) == ERROR_SUCCESS)
{
for(size_t k = 0; k < 2; k++)
{
wchar_t Buffer[4096];
DWORD BuffSize = sizeof(wchar_t*) * 4096;
DWORD DataType = REG_NONE;
if(RegQueryValueExW(registryKeyHandle, valueNames[k], 0, &DataType, reinterpret_cast<BYTE*>(Buffer), &BuffSize) == ERROR_SUCCESS)
{
if((DataType == REG_SZ) || (DataType == REG_EXPAND_SZ) || (DataType == REG_LINK))
{
mplayerPath = WCHAR2QSTR(Buffer);
break;
}
}
}
RegCloseKey(registryKeyHandle);
}
if(!mplayerPath.isEmpty())
{
QDir mplayerDir(mplayerPath);
if(mplayerDir.exists())
{
for(size_t k = 0; k < 4; k++)
{
if(mplayerDir.exists(WCHAR2QSTR(appNames[k])))
{
qDebug("Player found at:\n%s\n", mplayerDir.absoluteFilePath(WCHAR2QSTR(appNames[k])).toUtf8().constData());
QProcess::startDetached(mplayerDir.absoluteFilePath(WCHAR2QSTR(appNames[k])), QStringList() << QDir::toNativeSeparators(mediaFilePath));
return true;
}
}
}
}
}
}
return false;
}
/* /*
* Entry point checks * Entry point checks
*/ */

View File

@ -39,6 +39,7 @@ class QDate;
class QTime; class QTime;
class QIcon; class QIcon;
class QWidget; class QWidget;
class QProcess;
class LockedFile; class LockedFile;
enum QtMsgType; enum QtMsgType;
@ -87,6 +88,15 @@ typedef struct
} }
lamexp_os_version_t; lamexp_os_version_t;
//Beep types
typedef enum
{
lamexp_beep_info = 0,
lamexp_beep_warning = 1,
lamexp_beep_error = 2
}
lamexp_beep_t;
//LameXP version info //LameXP version info
unsigned int lamexp_version_major(void); unsigned int lamexp_version_major(void);
unsigned int lamexp_version_minor(void); unsigned int lamexp_version_minor(void);
@ -156,7 +166,30 @@ const QString lamexp_clean_filepath(const QString &str);
void lamexp_seed_rand(void); void lamexp_seed_rand(void);
unsigned int lamexp_rand(void); unsigned int lamexp_rand(void);
QDate lamexp_current_date_safe(void); QDate lamexp_current_date_safe(void);
void lamexp_sleep(const unsigned int delay);
bool lamexp_beep(int beepType);
bool lamexp_play_sound(const unsigned short uiSoundIdx, const bool bAsync, const wchar_t *alias = NULL);
bool lamexp_play_sound_file(const QString &library, const unsigned short uiSoundIdx, const bool bAsync);
bool lamexp_exec_shell(const QWidget *win, const QString &url, const bool explore = false);
bool lamexp_exec_shell(const QWidget *win, const QString &url, const QString &parameters, const QString &directory, const bool explore = false);
__int64 lamexp_perfcounter_frequ(void);
__int64 lamexp_perfcounter_value(void);
bool lamexp_append_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text);
bool lamexp_update_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text);
bool lamexp_check_sysmenu_msg(void *message, const unsigned int identifier);
bool lamexp_enable_close_button(const QWidget *win, const bool bEnable = true);
bool lamexp_check_escape_state(void);
bool lamexp_change_process_priority(const int priority);
bool lamexp_change_process_priority(const QProcess *proc, const int priority);
bool lamexp_change_process_priority(void *hProcess, const int priority);
bool lamexp_bring_to_front(const QWidget *win);
bool lamexp_bring_process_to_front(const unsigned long pid);
bool lamexp_get_connection_state(void);
unsigned long lamexp_process_id(const QProcess *proc);
unsigned __int64 lamexp_current_file_time(void);
void lamexp_natural_string_sort(QStringList &list, const bool bIgnoreCase); void lamexp_natural_string_sort(QStringList &list, const bool bIgnoreCase);
bool lamexp_open_media_file(const QString &mediaFilePath);
QString lamexp_path_to_short(const QString &longPath);
void lamexp_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL); void lamexp_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL);
//Debug-only functions //Debug-only functions

91
src/JobObject.cpp Normal file
View File

@ -0,0 +1,91 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#include "JobObject.h"
#include "Global.h"
#include <QProcess>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <MMSystem.h>
#include <ShellAPI.h>
#include <WinInet.h>
JobObject::JobObject(void)
:
m_hJobObject(NULL)
{
HANDLE jobObject = CreateJobObject(NULL, NULL);
if((jobObject != NULL) && (jobObject != INVALID_HANDLE_VALUE))
{
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobExtendedLimitInfo;
memset(&jobExtendedLimitInfo, 0, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
memset(&jobExtendedLimitInfo.BasicLimitInformation, 0, sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION));
jobExtendedLimitInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION;
if(SetInformationJobObject(jobObject, JobObjectExtendedLimitInformation, &jobExtendedLimitInfo, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION)))
{
m_hJobObject = jobObject;
}
else
{
qWarning("Failed to set job object information!");
CloseHandle(jobObject);
}
}
else
{
qWarning("Failed to create the job object!");
}
}
JobObject::~JobObject(void)
{
if(m_hJobObject)
{
CloseHandle(m_hJobObject);
m_hJobObject = NULL;
}
}
bool JobObject::addProcessToJob(const QProcess *proc)
{
if(m_hJobObject)
{
if(AssignProcessToJobObject(m_hJobObject, proc->pid()->hProcess))
{
return true;
}
else
{
qWarning("Failed to assign process to job object!");
return false;
}
}
else
{
qWarning("Cannot assign process to job: No job bject available!");
return false;
}
}

36
src/JobObject.h Normal file
View File

@ -0,0 +1,36 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#pragma once
class QProcess;
class JobObject
{
public:
JobObject(void);
~JobObject(void);
bool addProcessToJob(const QProcess *proc);
private:
void *m_hJobObject;
};

View File

@ -44,6 +44,9 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <Windows.h> #include <Windows.h>
//Forward declaration
LONG WINAPI lamexp_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo);
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Main function // Main function
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -221,8 +224,6 @@ static int lamexp_main(int argc, char* argv[])
// Applicaton entry point // Applicaton entry point
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
LONG WINAPI lamexp_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo);
static int _main(int argc, char* argv[]) static int _main(int argc, char* argv[])
{ {
if(LAMEXP_DEBUG) if(LAMEXP_DEBUG)

View File

@ -31,11 +31,6 @@
#include <QTextCodec> #include <QTextCodec>
#include <QTextStream> #include <QTextStream>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <float.h> #include <float.h>
#include <limits> #include <limits>
@ -609,7 +604,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
if(application) if(application)
{ {
application->processEvents(); application->processEvents();
if(lines < 128) Sleep(10); if(lines < 128) lamexp_sleep(10);
} }
if(cueStream.atEnd()) if(cueStream.atEnd())
@ -833,7 +828,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
if(application) if(application)
{ {
application->processEvents(); application->processEvents();
Sleep(10); lamexp_sleep(10);
} }
CueSheetFile *currentFile = m_files.at(i); CueSheetFile *currentFile = m_files.at(i);
@ -866,7 +861,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
if(application) if(application)
{ {
application->processEvents(); application->processEvents();
Sleep(10); lamexp_sleep(10);
} }
CueSheetFile *currentFile = m_files.at(i); CueSheetFile *currentFile = m_files.at(i);
int nTracks = currentFile->trackCount(); int nTracks = currentFile->trackCount();

View File

@ -39,11 +39,6 @@
#include <QMutex> #include <QMutex>
#include <QSet> #include <QSet>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// SettingsCache Class // SettingsCache Class
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -540,7 +535,7 @@ QString SettingsModel::initDirectory(const QString &path) const
for(int i = 0; i < 32; i++) for(int i = 0; i < 32; i++)
{ {
if(QDir(path).mkpath(".")) break; if(QDir(path).mkpath(".")) break;
Sleep(1); lamexp_sleep(1);
} }
} }

View File

@ -29,11 +29,6 @@
#include <limits.h> #include <limits.h>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Constructor // Constructor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -74,7 +69,7 @@ void MessageHandlerThread::run()
case 666: case 666:
if(!_stricmp(m_parameter, "Force!")) if(!_stricmp(m_parameter, "Force!"))
{ {
ExitProcess(-2); _exit(-2);
} }
else else
{ {

View File

@ -22,6 +22,7 @@
#include "Tool_Abstract.h" #include "Tool_Abstract.h"
#include "Global.h" #include "Global.h"
#include "JobObject.h"
#include <QProcess> #include <QProcess>
#include <QMutex> #include <QMutex>
@ -30,23 +31,18 @@
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QDir> #include <QDir>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
/* /*
* Static vars * Static vars
*/ */
quint64 AbstractTool::s_lastLaunchTime = 0ui64; quint64 AbstractTool::s_lastLaunchTime = 0ui64;
QMutex AbstractTool::s_mutex_startProcess; QMutex AbstractTool::s_mutex_startProcess;
HANDLE AbstractTool::s_handle_jobObject = NULL; JobObject *AbstractTool::s_jobObject = NULL;
unsigned int AbstractTool::s_jobObjRefCount = 0U; unsigned int AbstractTool::s_jobObjRefCount = 0U;
/* /*
* Const * Const
*/ */
static const DWORD START_DELAY = 333; //in milliseconds static const unsigned int START_DELAY = 333; //in milliseconds
static const quint64 START_DELAY_NANO = START_DELAY * 1000 * 10; //in 100-nanosecond intervals static const quint64 START_DELAY_NANO = START_DELAY * 1000 * 10; //in 100-nanosecond intervals
/* /*
@ -58,28 +54,8 @@ AbstractTool::AbstractTool(void)
if(s_jobObjRefCount < 1U) if(s_jobObjRefCount < 1U)
{ {
HANDLE jobObject = CreateJobObject(NULL, NULL); s_jobObject = new JobObject();
if((jobObject != NULL) && (jobObject != INVALID_HANDLE_VALUE)) s_jobObjRefCount = 1U;
{
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobExtendedLimitInfo;
memset(&jobExtendedLimitInfo, 0, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
memset(&jobExtendedLimitInfo.BasicLimitInformation, 0, sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION));
jobExtendedLimitInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION;
if(SetInformationJobObject(jobObject, JobObjectExtendedLimitInformation, &jobExtendedLimitInfo, sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION)))
{
s_handle_jobObject = jobObject;
s_jobObjRefCount = 1U;
}
else
{
qWarning("Failed to set job object information!");
CloseHandle(jobObject);
}
}
else
{
qWarning("Failed to create the job object!");
}
} }
else else
{ {
@ -99,10 +75,9 @@ AbstractTool::~AbstractTool(void)
if(s_jobObjRefCount >= 1U) if(s_jobObjRefCount >= 1U)
{ {
s_jobObjRefCount--; s_jobObjRefCount--;
if((s_jobObjRefCount < 1U) && s_handle_jobObject) if(s_jobObjRefCount < 1U)
{ {
CloseHandle(s_handle_jobObject); LAMEXP_DELETE(s_jobObject);
s_handle_jobObject = NULL;
} }
} }
} }
@ -114,9 +89,9 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
{ {
QMutexLocker lock(&s_mutex_startProcess); QMutexLocker lock(&s_mutex_startProcess);
if(currentTime() <= s_lastLaunchTime) if(lamexp_current_file_time() <= s_lastLaunchTime)
{ {
Sleep(START_DELAY); lamexp_sleep(START_DELAY);
} }
emit messageLogged(commandline2string(program, args) + "\n"); emit messageLogged(commandline2string(program, args) + "\n");
@ -133,18 +108,15 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
if(process.waitForStarted()) if(process.waitForStarted())
{ {
if(s_handle_jobObject) if(s_jobObject)
{ {
if(!AssignProcessToJobObject(s_handle_jobObject, process.pid()->hProcess)) if(!s_jobObject->addProcessToJob(&process))
{ {
qWarning("Failed to assign process to job object!"); qWarning("Failed to assign process to job object!");
} }
} }
if(!SetPriorityClass(process.pid()->hProcess, BELOW_NORMAL_PRIORITY_CLASS))
{ lamexp_change_process_priority(&process, -1);
SetPriorityClass(process.pid()->hProcess, IDLE_PRIORITY_CLASS);
}
lock.unlock(); lock.unlock();
if(m_firstLaunch) if(m_firstLaunch)
@ -153,7 +125,7 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
m_firstLaunch = false; m_firstLaunch = false;
} }
s_lastLaunchTime = currentTime() + START_DELAY_NANO; s_lastLaunchTime = lamexp_current_file_time() + START_DELAY_NANO;
return true; return true;
} }
@ -164,7 +136,7 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
process.kill(); process.kill();
process.waitForFinished(-1); process.waitForFinished(-1);
s_lastLaunchTime = currentTime() + START_DELAY_NANO; s_lastLaunchTime = lamexp_current_file_time() + START_DELAY_NANO;
return false; return false;
} }
@ -183,38 +155,4 @@ QString AbstractTool::commandline2string(const QString &program, const QStringLi
return commandline; return commandline;
} }
/*
* Convert long path to short path
*/
QString AbstractTool::pathToShort(const QString &longPath)
{
QString shortPath;
DWORD buffSize = GetShortPathNameW(reinterpret_cast<const wchar_t*>(longPath.utf16()), NULL, NULL);
if(buffSize > 0)
{
wchar_t *buffer = new wchar_t[buffSize];
DWORD result = GetShortPathNameW(reinterpret_cast<const wchar_t*>(longPath.utf16()), buffer, buffSize);
if(result > 0 && result < buffSize)
{
shortPath = QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer));
}
delete[] buffer;
}
return (shortPath.isEmpty() ? longPath : shortPath);
}
const quint64 AbstractTool::currentTime(void)
{
FILETIME fileTime;
GetSystemTimeAsFileTime(&fileTime);
ULARGE_INTEGER temp;
temp.HighPart = fileTime.dwHighDateTime;
temp.LowPart = fileTime.dwLowDateTime;
return temp.QuadPart;
}

View File

@ -25,6 +25,7 @@
class QMutex; class QMutex;
class QProcess; class QProcess;
class JobObject;
class AbstractTool : public QObject class AbstractTool : public QObject
{ {
@ -36,8 +37,6 @@ public:
bool startProcess(QProcess &process, const QString &program, const QStringList &args); bool startProcess(QProcess &process, const QString &program, const QStringList &args);
static QString commandline2string(const QString &program, const QStringList &arguments); static QString commandline2string(const QString &program, const QStringList &arguments);
static QString AbstractTool::pathToShort(const QString &longPath);
static inline const quint64 currentTime(void);
signals: signals:
void statusUpdated(int progress); void statusUpdated(int progress);
@ -50,7 +49,7 @@ private:
static quint64 s_lastLaunchTime; static quint64 s_lastLaunchTime;
static QMutex s_mutex_startProcess; static QMutex s_mutex_startProcess;
static unsigned int s_jobObjRefCount; static unsigned int s_jobObjRefCount;
static void *s_handle_jobObject; static JobObject *s_jobObject;
bool m_firstLaunch; bool m_firstLaunch;
}; };