Moved JobObject as well as the remaining GUI functions into the MUtilities library.
This commit is contained in:
parent
f064187bb1
commit
3a582a028c
@ -319,7 +319,6 @@ copy /Y "$(SolutionDir)\..\Prerequisites\VisualLeakDetector\bin\Win32\*.manifest
|
|||||||
<ClCompile Include="src\Global_Version.cpp" />
|
<ClCompile Include="src\Global_Version.cpp" />
|
||||||
<ClCompile Include="src\Global_Win32.cpp" />
|
<ClCompile Include="src\Global_Win32.cpp" />
|
||||||
<ClCompile Include="src\Global_Tools.cpp" />
|
<ClCompile Include="src\Global_Tools.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" />
|
||||||
@ -576,7 +575,6 @@ copy /Y "$(SolutionDir)\..\Prerequisites\VisualLeakDetector\bin\Win32\*.manifest
|
|||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\$(ProjectName)\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\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
|
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
|
||||||
|
@ -217,9 +217,6 @@
|
|||||||
<ClCompile Include="src\Registry_Encoder.cpp">
|
<ClCompile Include="src\Registry_Encoder.cpp">
|
||||||
<Filter>Source Files\Misc</Filter>
|
<Filter>Source Files\Misc</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\JobObject.cpp">
|
|
||||||
<Filter>Source Files\Misc</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Global_Tools.cpp">
|
<ClCompile Include="src\Global_Tools.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -519,9 +516,6 @@
|
|||||||
<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\JobObject.h">
|
|
||||||
<Filter>Header Files\Misc</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tmp\LameXP\UIC_WorkingBanner.h">
|
<ClInclude Include="tmp\LameXP\UIC_WorkingBanner.h">
|
||||||
<Filter>Generated Files\UIC</Filter>
|
<Filter>Generated Files\UIC</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
#define VER_LAMEXP_MINOR_HI 1
|
#define VER_LAMEXP_MINOR_HI 1
|
||||||
#define VER_LAMEXP_MINOR_LO 1
|
#define VER_LAMEXP_MINOR_LO 1
|
||||||
#define VER_LAMEXP_TYPE Beta
|
#define VER_LAMEXP_TYPE Beta
|
||||||
#define VER_LAMEXP_PATCH 5
|
#define VER_LAMEXP_PATCH 7
|
||||||
#define VER_LAMEXP_BUILD 1621
|
#define VER_LAMEXP_BUILD 1624
|
||||||
#define VER_LAMEXP_CONFG 1558
|
#define VER_LAMEXP_CONFG 1558
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <MUtils/Global.h>
|
#include <MUtils/Global.h>
|
||||||
#include <MUtils/OSSupport.h>
|
#include <MUtils/OSSupport.h>
|
||||||
#include <MUtils/Sound.h>
|
#include <MUtils/Sound.h>
|
||||||
|
#include <MUtils/GUI.h>
|
||||||
#include <MUtils/Version.h>
|
#include <MUtils/Version.h>
|
||||||
|
|
||||||
//Qt
|
//Qt
|
||||||
@ -157,7 +158,7 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta
|
|||||||
//Disable "X" button
|
//Disable "X" button
|
||||||
if(firstStart)
|
if(firstStart)
|
||||||
{
|
{
|
||||||
lamexp_enable_close_button(this, false);
|
MUtils::GUI::enable_close_button(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Init images
|
//Init images
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
//MUtils
|
//MUtils
|
||||||
#include <MUtils/Global.h>
|
#include <MUtils/Global.h>
|
||||||
#include <MUtils/OSSupport.h>
|
#include <MUtils/OSSupport.h>
|
||||||
|
#include <MUtils/GUI.h>
|
||||||
|
|
||||||
//Qt includes
|
//Qt includes
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -255,7 +256,7 @@ void CueImportDialog::browseButtonClicked(void)
|
|||||||
if(pos > 0) currentDir.left(pos - 1); else break;
|
if(pos > 0) currentDir.left(pos - 1); else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lamexp_themes_enabled())
|
if(MUtils::GUI::themes_enabled())
|
||||||
{
|
{
|
||||||
newOutDir = QFileDialog::getExistingDirectory(this, tr("Choose Output Directory"), currentDir);
|
newOutDir = QFileDialog::getExistingDirectory(this, tr("Choose Output Directory"), currentDir);
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel_MetaInfo *me
|
|||||||
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
|
||||||
lamexp_append_sysmenu(this, IDM_ABOUTBOX, "About...");
|
MUtils::GUI::sysmenu_append(this, IDM_ABOUTBOX, "About...");
|
||||||
|
|
||||||
//Setup corner widget
|
//Setup corner widget
|
||||||
QLabel *cornerWidget = new QLabel(ui->menubar);
|
QLabel *cornerWidget = new QLabel(ui->menubar);
|
||||||
@ -595,8 +595,8 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel_MetaInfo *me
|
|||||||
ui->actionStyleWindowsXP->setData(3);
|
ui->actionStyleWindowsXP->setData(3);
|
||||||
ui->actionStyleWindowsClassic->setData(4);
|
ui->actionStyleWindowsClassic->setData(4);
|
||||||
ui->actionStylePlastique->setChecked(true);
|
ui->actionStylePlastique->setChecked(true);
|
||||||
ui->actionStyleWindowsXP->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_XP && lamexp_themes_enabled());
|
ui->actionStyleWindowsXP->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_XP && MUtils::GUI::themes_enabled());
|
||||||
ui->actionStyleWindowsVista->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_VISTA && lamexp_themes_enabled());
|
ui->actionStyleWindowsVista->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_VISTA && MUtils::GUI::themes_enabled());
|
||||||
connect(m_styleActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(styleActionActivated(QAction*)));
|
connect(m_styleActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(styleActionActivated(QAction*)));
|
||||||
styleActionActivated(NULL);
|
styleActionActivated(NULL);
|
||||||
|
|
||||||
@ -831,14 +831,14 @@ void MainWindow::addFolder(const QString &path, bool recursive, bool delayed)
|
|||||||
SHOW_BANNER(tr("Scanning folder(s) for files, please wait..."));
|
SHOW_BANNER(tr("Scanning folder(s) for files, please wait..."));
|
||||||
|
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
lamexp_check_escape_state();
|
MUtils::OS::check_key_state_esc();
|
||||||
|
|
||||||
while(!folderInfoList.isEmpty())
|
while(!folderInfoList.isEmpty())
|
||||||
{
|
{
|
||||||
if(lamexp_check_escape_state())
|
if(MUtils::OS::check_key_state_esc())
|
||||||
{
|
{
|
||||||
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
|
|
||||||
qWarning("Operation cancelled by user!");
|
qWarning("Operation cancelled by user!");
|
||||||
|
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
|
||||||
fileList.clear();
|
fileList.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1103,7 +1103,7 @@ void MainWindow::changeEvent(QEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Translate system menu
|
//Translate system menu
|
||||||
lamexp_update_sysmenu(this, IDM_ABOUTBOX, ui->buttonAbout->text());
|
MUtils::GUI::sysmenu_update(this, IDM_ABOUTBOX, ui->buttonAbout->text());
|
||||||
|
|
||||||
//Force resize event
|
//Force resize event
|
||||||
QApplication::postEvent(this, new QResizeEvent(this->size(), QSize()));
|
QApplication::postEvent(this, new QResizeEvent(this->size(), QSize()));
|
||||||
@ -1263,7 +1263,7 @@ bool MainWindow::event(QEvent *e)
|
|||||||
|
|
||||||
bool MainWindow::winEvent(MSG *message, long *result)
|
bool MainWindow::winEvent(MSG *message, long *result)
|
||||||
{
|
{
|
||||||
if(lamexp_check_sysmenu_msg(message, IDM_ABOUTBOX))
|
if(MUtils::GUI::sysmenu_check_msg(message, IDM_ABOUTBOX))
|
||||||
{
|
{
|
||||||
QTimer::singleShot(0, ui->buttonAbout, SLOT(click()));
|
QTimer::singleShot(0, ui->buttonAbout, SLOT(click()));
|
||||||
*result = 0;
|
*result = 0;
|
||||||
@ -2033,7 +2033,7 @@ void MainWindow::importCueSheetActionTriggered(bool checked)
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
QString selectedCueFile;
|
QString selectedCueFile;
|
||||||
|
|
||||||
if(lamexp_themes_enabled())
|
if(MUtils::GUI::themes_enabled())
|
||||||
{
|
{
|
||||||
selectedCueFile = QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
|
selectedCueFile = QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File")));
|
||||||
}
|
}
|
||||||
@ -2084,7 +2084,7 @@ void MainWindow::showDropBoxWidgetActionTriggered(bool checked)
|
|||||||
QTimer::singleShot(2500, m_dropBox, SLOT(showToolTip()));
|
QTimer::singleShot(2500, m_dropBox, SLOT(showToolTip()));
|
||||||
}
|
}
|
||||||
|
|
||||||
lamexp_blink_window(m_dropBox);
|
MUtils::GUI::blink_window(m_dropBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2267,7 +2267,7 @@ void MainWindow::addFilesButtonClicked(void)
|
|||||||
|
|
||||||
TEMP_HIDE_DROPBOX
|
TEMP_HIDE_DROPBOX
|
||||||
(
|
(
|
||||||
if(lamexp_themes_enabled())
|
if(MUtils::GUI::themes_enabled())
|
||||||
{
|
{
|
||||||
QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes();
|
QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes();
|
||||||
QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings->mostRecentInputPath(), fileTypeFilters.join(";;"));
|
QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings->mostRecentInputPath(), fileTypeFilters.join(";;"));
|
||||||
@ -2309,7 +2309,7 @@ void MainWindow::openFolderActionActivated(void)
|
|||||||
{
|
{
|
||||||
TEMP_HIDE_DROPBOX
|
TEMP_HIDE_DROPBOX
|
||||||
(
|
(
|
||||||
if(lamexp_themes_enabled())
|
if(MUtils::GUI::themes_enabled())
|
||||||
{
|
{
|
||||||
selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings->mostRecentInputPath());
|
selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings->mostRecentInputPath());
|
||||||
}
|
}
|
||||||
@ -2612,7 +2612,7 @@ void MainWindow::exportCsvContextActionTriggered(void)
|
|||||||
(
|
(
|
||||||
QString selectedCsvFile;
|
QString selectedCsvFile;
|
||||||
|
|
||||||
if(lamexp_themes_enabled())
|
if(MUtils::GUI::themes_enabled())
|
||||||
{
|
{
|
||||||
selectedCsvFile = QFileDialog::getSaveFileName(this, tr("Save CSV file"), m_settings->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
|
selectedCsvFile = QFileDialog::getSaveFileName(this, tr("Save CSV file"), m_settings->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
|
||||||
}
|
}
|
||||||
@ -2663,7 +2663,7 @@ void MainWindow::importCsvContextActionTriggered(void)
|
|||||||
(
|
(
|
||||||
QString selectedCsvFile;
|
QString selectedCsvFile;
|
||||||
|
|
||||||
if(lamexp_themes_enabled())
|
if(MUtils::GUI::themes_enabled())
|
||||||
{
|
{
|
||||||
selectedCsvFile = QFileDialog::getOpenFileName(this, tr("Open CSV file"), m_settings->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
|
selectedCsvFile = QFileDialog::getOpenFileName(this, tr("Open CSV file"), m_settings->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File")));
|
||||||
}
|
}
|
||||||
@ -3925,7 +3925,7 @@ void MainWindow::browseCustomTempFolderButtonClicked(void)
|
|||||||
{
|
{
|
||||||
QString newTempFolder;
|
QString newTempFolder;
|
||||||
|
|
||||||
if(lamexp_themes_enabled())
|
if(MUtils::GUI::themes_enabled())
|
||||||
{
|
{
|
||||||
newTempFolder = QFileDialog::getExistingDirectory(this, QString(), m_settings->customTempPath());
|
newTempFolder = QFileDialog::getExistingDirectory(this, QString(), m_settings->customTempPath());
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ void ProcessingDialog::showEvent(QShowEvent *event)
|
|||||||
{
|
{
|
||||||
static const char *NA = " N/A";
|
static const char *NA = " N/A";
|
||||||
|
|
||||||
lamexp_enable_close_button(this, false);
|
MUtils::GUI::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_progressIndicator->start();
|
m_progressIndicator->start();
|
||||||
@ -752,7 +752,7 @@ void ProcessingDialog::doneEncoding(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lamexp_enable_close_button(this, true);
|
MUtils::GUI::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);
|
||||||
@ -1064,7 +1064,7 @@ void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason rea
|
|||||||
{
|
{
|
||||||
if(reason == QSystemTrayIcon::DoubleClick)
|
if(reason == QSystemTrayIcon::DoubleClick)
|
||||||
{
|
{
|
||||||
lamexp_bring_to_front(this);
|
MUtils::GUI::bring_to_front(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
//MUtils
|
//MUtils
|
||||||
#include <MUtils/Global.h>
|
#include <MUtils/Global.h>
|
||||||
|
#include <MUtils/GUI.h>
|
||||||
|
|
||||||
//Qt
|
//Qt
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -79,7 +80,7 @@ SplashScreen::SplashScreen(QWidget *parent)
|
|||||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateHandler()));
|
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateHandler()));
|
||||||
|
|
||||||
//Enable "sheet of glass" effect on splash screen
|
//Enable "sheet of glass" effect on splash screen
|
||||||
if(!lamexp_sheet_of_glass(this))
|
if(!MUtils::GUI::sheet_of_glass(this))
|
||||||
{
|
{
|
||||||
setStyleSheet("background-image: url(:/images/Background.jpg)");
|
setStyleSheet("background-image: url(:/images/Background.jpg)");
|
||||||
}
|
}
|
||||||
@ -130,7 +131,7 @@ void SplashScreen::showSplash(QThread *thread)
|
|||||||
|
|
||||||
//Wait for window to show
|
//Wait for window to show
|
||||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||||
splashScreen->repaint(); lamexp_bring_to_front(splashScreen);
|
splashScreen->repaint(); MUtils::GUI::bring_to_front(splashScreen);
|
||||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||||
|
|
||||||
//Connect thread signals
|
//Connect thread signals
|
||||||
@ -185,7 +186,7 @@ void SplashScreen::updateHandler(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
setWindowOpacity(1.0);
|
setWindowOpacity(1.0);
|
||||||
lamexp_bring_to_front(this);
|
MUtils::GUI::bring_to_front(this);
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
m_status = STATUS_WAIT;
|
m_status = STATUS_WAIT;
|
||||||
}
|
}
|
||||||
@ -214,7 +215,7 @@ void SplashScreen::threadComplete(void)
|
|||||||
{
|
{
|
||||||
m_timer->start(FADE_DELAY);
|
m_timer->start(FADE_DELAY);
|
||||||
}
|
}
|
||||||
lamexp_bring_to_front(this);
|
MUtils::GUI::bring_to_front(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <MUtils/Version.h>
|
#include <MUtils/Version.h>
|
||||||
#include <MUtils/Exception.h>
|
#include <MUtils/Exception.h>
|
||||||
#include <MUtils/Sound.h>
|
#include <MUtils/Sound.h>
|
||||||
|
#include <MUtils/GUI.h>
|
||||||
#include <MUtils/OSSupport.h>
|
#include <MUtils/OSSupport.h>
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent)
|
|||||||
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
|
||||||
|
|
||||||
//Disable "X" button
|
//Disable "X" button
|
||||||
lamexp_enable_close_button(this, false);
|
MUtils::GUI::enable_close_button(this, false);
|
||||||
|
|
||||||
//Init animation
|
//Init animation
|
||||||
m_animator = new QMovie(":/images/Loading3.gif");
|
m_animator = new QMovie(":/images/Loading3.gif");
|
||||||
@ -220,7 +221,7 @@ bool UpdateDialog::event(QEvent *e)
|
|||||||
{
|
{
|
||||||
if((e->type() == QEvent::ActivationChange) && (m_updaterProcess != NULL))
|
if((e->type() == QEvent::ActivationChange) && (m_updaterProcess != NULL))
|
||||||
{
|
{
|
||||||
lamexp_bring_process_to_front(m_updaterProcess);
|
MUtils::GUI::bring_to_front(m_updaterProcess);
|
||||||
}
|
}
|
||||||
return QDialog::event(e);
|
return QDialog::event(e);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
//MUtils
|
//MUtils
|
||||||
#include <MUtils/Global.h>
|
#include <MUtils/Global.h>
|
||||||
|
#include <MUtils/GUI.h>
|
||||||
|
|
||||||
//Qt
|
//Qt
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -90,7 +91,7 @@ WorkingBanner::WorkingBanner(QWidget *parent)
|
|||||||
setModal(true);
|
setModal(true);
|
||||||
|
|
||||||
//Enable the "sheet of glass" effect
|
//Enable the "sheet of glass" effect
|
||||||
if(lamexp_sheet_of_glass(this))
|
if(MUtils::GUI::sheet_of_glass(this))
|
||||||
{
|
{
|
||||||
m_style = new QWindowsVistaStyle();
|
m_style = new QWindowsVistaStyle();
|
||||||
this->setStyle(m_style);
|
this->setStyle(m_style);
|
||||||
@ -289,7 +290,7 @@ void WorkingBanner::hideEvent(QHideEvent *event)
|
|||||||
|
|
||||||
void WorkingBanner::windowShown(void)
|
void WorkingBanner::windowShown(void)
|
||||||
{
|
{
|
||||||
lamexp_bring_to_front(this);
|
MUtils::GUI::bring_to_front(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkingBanner::setText(const QString &text)
|
void WorkingBanner::setText(const QString &text)
|
||||||
|
26
src/Global.h
26
src/Global.h
@ -41,34 +41,13 @@ enum QtMsgType;
|
|||||||
extern const char* LAMEXP_DEFAULT_LANGID;
|
extern const char* LAMEXP_DEFAULT_LANGID;
|
||||||
extern const char* LAMEXP_DEFAULT_TRANSLATION;
|
extern const char* LAMEXP_DEFAULT_TRANSLATION;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TYPE DEFINITIONS
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//System color types
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
lamexp_syscolor_text = 0,
|
|
||||||
lamexp_syscolor_background = 1,
|
|
||||||
lamexp_syscolor_caption = 2
|
|
||||||
}
|
|
||||||
lamexp_syscolor_t;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// GLOBAL FUNCTIONS
|
// GLOBAL FUNCTIONS
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
const QIcon &lamexp_app_icon(void);
|
const QIcon &lamexp_app_icon(void);
|
||||||
bool lamexp_append_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text);
|
|
||||||
QStringList lamexp_available_codepages(bool noAliases = true);
|
QStringList lamexp_available_codepages(bool noAliases = true);
|
||||||
void lamexp_blink_window(QWidget *poWindow, unsigned int count = 10, unsigned int delay = 150);
|
|
||||||
bool lamexp_block_window_move(void *message);
|
|
||||||
bool lamexp_bring_process_to_front(const unsigned long pid);
|
|
||||||
bool lamexp_bring_to_front(const QWidget *win);
|
|
||||||
bool lamexp_check_escape_state(void);
|
|
||||||
bool lamexp_check_sysmenu_msg(void *message, const unsigned int identifier);
|
|
||||||
bool lamexp_check_tool(const QString &toolName);
|
bool lamexp_check_tool(const QString &toolName);
|
||||||
bool lamexp_enable_close_button(const QWidget *win, const bool bEnable = true);
|
|
||||||
void lamexp_finalization(void);
|
void lamexp_finalization(void);
|
||||||
int lamexp_init_ipc(void);
|
int lamexp_init_ipc(void);
|
||||||
bool lamexp_install_translator(const QString &language);
|
bool lamexp_install_translator(const QString &language);
|
||||||
@ -80,11 +59,7 @@ const char *lamexp_mulders_url(void);
|
|||||||
bool lamexp_portable_mode(void);
|
bool lamexp_portable_mode(void);
|
||||||
QStringList lamexp_query_translations(void);
|
QStringList lamexp_query_translations(void);
|
||||||
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
|
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
|
||||||
bool lamexp_sheet_of_glass(QWidget *window);
|
|
||||||
bool lamexp_sheet_of_glass_update(QWidget *window);
|
|
||||||
QColor lamexp_system_color(const int color_id);
|
|
||||||
const char *lamexp_support_url(void);
|
const char *lamexp_support_url(void);
|
||||||
bool lamexp_themes_enabled(void);
|
|
||||||
unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
|
unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
|
||||||
unsigned int lamexp_toolver_coreaudio(void);
|
unsigned int lamexp_toolver_coreaudio(void);
|
||||||
unsigned int lamexp_toolver_fhgaacenc(void);
|
unsigned int lamexp_toolver_fhgaacenc(void);
|
||||||
@ -96,7 +71,6 @@ bool lamexp_translation_init(void);
|
|||||||
QString lamexp_translation_name(const QString &language);
|
QString lamexp_translation_name(const QString &language);
|
||||||
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country);
|
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country);
|
||||||
unsigned int lamexp_translation_sysid(const QString &langId);
|
unsigned int lamexp_translation_sysid(const QString &langId);
|
||||||
bool lamexp_update_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text);
|
|
||||||
const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag = NULL);
|
const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag = NULL);
|
||||||
unsigned int lamexp_version_build(void);
|
unsigned int lamexp_version_build(void);
|
||||||
unsigned int lamexp_version_confg(void);
|
unsigned int lamexp_version_confg(void);
|
||||||
|
@ -87,57 +87,6 @@ QStringList lamexp_available_codepages(bool noAliases)
|
|||||||
return codecList;
|
return codecList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Make a window blink (to draw user's attention)
|
|
||||||
*/
|
|
||||||
void lamexp_blink_window(QWidget *poWindow, unsigned int count, unsigned int delay)
|
|
||||||
{
|
|
||||||
static QMutex blinkMutex;
|
|
||||||
|
|
||||||
const double maxOpac = 1.0;
|
|
||||||
const double minOpac = 0.3;
|
|
||||||
const double delOpac = 0.1;
|
|
||||||
|
|
||||||
if(!blinkMutex.tryLock())
|
|
||||||
{
|
|
||||||
qWarning("Blinking is already in progress, skipping!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const int steps = static_cast<int>(ceil(maxOpac - minOpac) / delOpac);
|
|
||||||
const int sleep = static_cast<int>(floor(static_cast<double>(delay) / static_cast<double>(steps)));
|
|
||||||
const double opacity = poWindow->windowOpacity();
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
for(double x = maxOpac; x >= minOpac; x -= delOpac)
|
|
||||||
{
|
|
||||||
poWindow->setWindowOpacity(x);
|
|
||||||
QApplication::processEvents();
|
|
||||||
MUtils::OS::sleep_ms(sleep);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(double x = minOpac; x <= maxOpac; x += delOpac)
|
|
||||||
{
|
|
||||||
poWindow->setWindowOpacity(x);
|
|
||||||
QApplication::processEvents();
|
|
||||||
MUtils::OS::sleep_ms(sleep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
poWindow->setWindowOpacity(opacity);
|
|
||||||
QApplication::processEvents();
|
|
||||||
blinkMutex.unlock();
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
blinkMutex.unlock();
|
|
||||||
qWarning("Exception error while blinking!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Computus according to H. Lichtenberg
|
* Computus according to H. Lichtenberg
|
||||||
*/
|
*/
|
||||||
|
@ -28,62 +28,6 @@
|
|||||||
//Visual Leaks Detector
|
//Visual Leaks Detector
|
||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
|
|
||||||
//Windows includes
|
|
||||||
#define NOMINMAX
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <MMSystem.h>
|
|
||||||
#include <ShellAPI.h>
|
|
||||||
#include <SensAPI.h>
|
|
||||||
#include <Objbase.h>
|
|
||||||
#include <PowrProf.h>
|
|
||||||
#include <Psapi.h>
|
|
||||||
#include <dwmapi.h>
|
|
||||||
|
|
||||||
//Qt includes
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QDate>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QEvent>
|
|
||||||
#include <QIcon>
|
|
||||||
#include <QImageReader>
|
|
||||||
#include <QLibrary>
|
|
||||||
#include <QLibraryInfo>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QPlastiqueStyle>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QReadWriteLock>
|
|
||||||
#include <QRegExp>
|
|
||||||
#include <QSysInfo>
|
|
||||||
#include <QTextCodec>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QTranslator>
|
|
||||||
#include <QUuid>
|
|
||||||
#include <QResource>
|
|
||||||
|
|
||||||
//LameXP includes
|
|
||||||
#define LAMEXP_INC_CONFIG
|
|
||||||
#include "Resource.h"
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
//MUtils
|
|
||||||
#include <MUtils/Global.h>
|
|
||||||
#include <MUtils/OSSupport.h>
|
|
||||||
#include <MUtils/Terminal.h>
|
|
||||||
|
|
||||||
//CRT includes
|
|
||||||
#include <cstdio>
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <io.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <intrin.h>
|
|
||||||
#include <cmath>
|
|
||||||
#include <ctime>
|
|
||||||
#include <process.h>
|
|
||||||
#include <csignal>
|
|
||||||
|
|
||||||
//Initialize static Qt plugins
|
//Initialize static Qt plugins
|
||||||
#ifdef QT_NODLL
|
#ifdef QT_NODLL
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||||
@ -95,402 +39,16 @@ Q_IMPORT_PLUGIN(QICOPlugin)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// HELPER MACROS
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define _LAMEXP_MAKE_STR(STR) #STR
|
|
||||||
#define LAMEXP_MAKE_STR(STR) _LAMEXP_MAKE_STR(STR)
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// GLOBAL VARS
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//Wine detection
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
bool bInitialized;
|
|
||||||
bool bIsWine;
|
|
||||||
QReadWriteLock lock;
|
|
||||||
}
|
|
||||||
g_lamexp_wine;
|
|
||||||
|
|
||||||
//Win32 Theme support
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
bool bInitialized;
|
|
||||||
bool bThemesEnabled;
|
|
||||||
QReadWriteLock lock;
|
|
||||||
}
|
|
||||||
g_lamexp_themes_enabled;
|
|
||||||
|
|
||||||
//Win32 DWM API functions
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
bool bInitialized;
|
|
||||||
HRESULT (__stdcall *dwmIsCompositionEnabled)(BOOL *bEnabled);
|
|
||||||
HRESULT (__stdcall *dwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset);
|
|
||||||
HRESULT (__stdcall *dwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind);
|
|
||||||
QLibrary *dwmapi_dll;
|
|
||||||
QReadWriteLock lock;
|
|
||||||
}
|
|
||||||
g_lamexp_dwmapi;
|
|
||||||
|
|
||||||
//Sound file cache
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
QHash<const QString, const unsigned char*> *sound_db;
|
|
||||||
QReadWriteLock lock;
|
|
||||||
}
|
|
||||||
g_lamexp_sounds;
|
|
||||||
|
|
||||||
//Main thread ID
|
|
||||||
static const DWORD g_main_thread_id = GetCurrentThreadId();
|
|
||||||
|
|
||||||
//Localization
|
//Localization
|
||||||
const char* LAMEXP_DEFAULT_LANGID = "en";
|
const char* LAMEXP_DEFAULT_LANGID = "en";
|
||||||
const char* LAMEXP_DEFAULT_TRANSLATION = "LameXP_EN.qm";
|
const char* LAMEXP_DEFAULT_TRANSLATION = "LameXP_EN.qm";
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// GLOBAL FUNCTIONS
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if visual themes are enabled (WinXP and later)
|
|
||||||
*/
|
|
||||||
bool lamexp_themes_enabled(void)
|
|
||||||
{
|
|
||||||
typedef int (WINAPI *IsAppThemedFun)(void);
|
|
||||||
|
|
||||||
QReadLocker readLock(&g_lamexp_themes_enabled.lock);
|
|
||||||
if(g_lamexp_themes_enabled.bInitialized)
|
|
||||||
{
|
|
||||||
return g_lamexp_themes_enabled.bThemesEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
readLock.unlock();
|
|
||||||
QWriteLocker writeLock(&g_lamexp_themes_enabled.lock);
|
|
||||||
|
|
||||||
if(!g_lamexp_themes_enabled.bInitialized)
|
|
||||||
{
|
|
||||||
g_lamexp_themes_enabled.bThemesEnabled = false;
|
|
||||||
const MUtils::OS::Version::os_version_t &osVersion = MUtils::OS::os_version();
|
|
||||||
if(osVersion >= MUtils::OS::Version::WINDOWS_WINXP)
|
|
||||||
{
|
|
||||||
IsAppThemedFun IsAppThemedPtr = NULL;
|
|
||||||
QLibrary uxTheme(QString("%1/UxTheme.dll").arg(MUtils::OS::known_folder(MUtils::OS::FOLDER_SYSTEMFOLDER)));
|
|
||||||
if(uxTheme.load())
|
|
||||||
{
|
|
||||||
IsAppThemedPtr = (IsAppThemedFun) uxTheme.resolve("IsAppThemed");
|
|
||||||
}
|
|
||||||
if(IsAppThemedPtr)
|
|
||||||
{
|
|
||||||
g_lamexp_themes_enabled.bThemesEnabled = IsAppThemedPtr();
|
|
||||||
if(!g_lamexp_themes_enabled.bThemesEnabled)
|
|
||||||
{
|
|
||||||
qWarning("Theme support is disabled for this process!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_lamexp_themes_enabled.bInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_lamexp_themes_enabled.bThemesEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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, MUTILS_WCHR(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, MUTILS_WCHR(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Bring the specifed window to the front
|
|
||||||
*/
|
|
||||||
bool lamexp_bring_to_front(const QWidget *window)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if(window)
|
|
||||||
{
|
|
||||||
for(int i = 0; (i < 5) && (!ret); i++)
|
|
||||||
{
|
|
||||||
ret = (SetForegroundWindow(window->winId()) != FALSE);
|
|
||||||
SwitchToThisWindow(window->winId(), TRUE);
|
|
||||||
}
|
|
||||||
LockSetForegroundWindow(LSFW_LOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lamexp_init_dwmapi(void)
|
|
||||||
{
|
|
||||||
QReadLocker writeLock(&g_lamexp_dwmapi.lock);
|
|
||||||
|
|
||||||
//Not initialized yet?
|
|
||||||
if(g_lamexp_dwmapi.bInitialized)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Reset function pointers
|
|
||||||
g_lamexp_dwmapi.dwmIsCompositionEnabled = NULL;
|
|
||||||
g_lamexp_dwmapi.dwmExtendFrameIntoClientArea = NULL;
|
|
||||||
g_lamexp_dwmapi.dwmEnableBlurBehindWindow = NULL;
|
|
||||||
|
|
||||||
//Does OS support DWM?
|
|
||||||
const MUtils::OS::Version::os_version_t &osVersion = MUtils::OS::os_version();
|
|
||||||
if(osVersion >= MUtils::OS::Version::WINDOWS_VISTA)
|
|
||||||
{
|
|
||||||
//Load DWMAPI.DLL
|
|
||||||
g_lamexp_dwmapi.dwmapi_dll = new QLibrary("dwmapi.dll");
|
|
||||||
if(g_lamexp_dwmapi.dwmapi_dll->load())
|
|
||||||
{
|
|
||||||
//Initialize function pointers
|
|
||||||
g_lamexp_dwmapi.dwmIsCompositionEnabled = (HRESULT (__stdcall*)(BOOL*)) g_lamexp_dwmapi.dwmapi_dll->resolve("DwmIsCompositionEnabled");
|
|
||||||
g_lamexp_dwmapi.dwmExtendFrameIntoClientArea = (HRESULT (__stdcall*)(HWND, const MARGINS*)) g_lamexp_dwmapi.dwmapi_dll->resolve("DwmExtendFrameIntoClientArea");
|
|
||||||
g_lamexp_dwmapi.dwmEnableBlurBehindWindow = (HRESULT (__stdcall*)(HWND, const DWM_BLURBEHIND*)) g_lamexp_dwmapi.dwmapi_dll->resolve("DwmEnableBlurBehindWindow");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MUTILS_DELETE(g_lamexp_dwmapi.dwmapi_dll);
|
|
||||||
qWarning("Failed to load DWMAPI.DLL on a DWM-enabled system!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_lamexp_dwmapi.bInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enable "sheet of glass" effect on the given Window
|
|
||||||
*/
|
|
||||||
bool lamexp_sheet_of_glass(QWidget *window)
|
|
||||||
{
|
|
||||||
QReadLocker readLock(&g_lamexp_dwmapi.lock);
|
|
||||||
|
|
||||||
//Initialize the DWM API
|
|
||||||
while(!g_lamexp_dwmapi.bInitialized)
|
|
||||||
{
|
|
||||||
readLock.unlock();
|
|
||||||
lamexp_init_dwmapi();
|
|
||||||
readLock.relock();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL bCompositionEnabled = FALSE;
|
|
||||||
|
|
||||||
//Required functions available?
|
|
||||||
if((g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL) && (g_lamexp_dwmapi.dwmExtendFrameIntoClientArea != NULL) && (g_lamexp_dwmapi.dwmEnableBlurBehindWindow != NULL))
|
|
||||||
{
|
|
||||||
//Check if composition is currently enabled
|
|
||||||
if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bCompositionEnabled))
|
|
||||||
{
|
|
||||||
qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//All functions available *and* composition enabled?
|
|
||||||
if(!bCompositionEnabled)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Enable the "sheet of glass" effect on this window
|
|
||||||
MARGINS margins = {-1, -1, -1, -1};
|
|
||||||
if(HRESULT hr = g_lamexp_dwmapi.dwmExtendFrameIntoClientArea(window->winId(), &margins))
|
|
||||||
{
|
|
||||||
qWarning("DwmExtendFrameIntoClientArea function has failed! (error %d)", hr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create and populate the Blur Behind structure
|
|
||||||
DWM_BLURBEHIND bb;
|
|
||||||
memset(&bb, 0, sizeof(DWM_BLURBEHIND));
|
|
||||||
bb.fEnable = TRUE;
|
|
||||||
bb.dwFlags = DWM_BB_ENABLE;
|
|
||||||
if(HRESULT hr = g_lamexp_dwmapi.dwmEnableBlurBehindWindow(window->winId(), &bb))
|
|
||||||
{
|
|
||||||
qWarning("DwmEnableBlurBehindWindow function has failed! (error %d)", hr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Required for Qt
|
|
||||||
window->setAutoFillBackground(false);
|
|
||||||
window->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
window->setAttribute(Qt::WA_NoSystemBackground);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Update "sheet of glass" effect on the given Window
|
|
||||||
*/
|
|
||||||
bool lamexp_sheet_of_glass_update(QWidget *window)
|
|
||||||
{
|
|
||||||
QReadLocker readLock(&g_lamexp_dwmapi.lock);
|
|
||||||
|
|
||||||
//Initialize the DWM API
|
|
||||||
while(!g_lamexp_dwmapi.bInitialized)
|
|
||||||
{
|
|
||||||
readLock.unlock();
|
|
||||||
lamexp_init_dwmapi();
|
|
||||||
readLock.relock();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL bCompositionEnabled = FALSE;
|
|
||||||
|
|
||||||
//Required functions available?
|
|
||||||
if((g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL) && (g_lamexp_dwmapi.dwmEnableBlurBehindWindow != NULL))
|
|
||||||
{
|
|
||||||
//Check if composition is currently enabled
|
|
||||||
if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bCompositionEnabled))
|
|
||||||
{
|
|
||||||
qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//All functions available *and* composition enabled?
|
|
||||||
if(!bCompositionEnabled)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create and populate the Blur Behind structure
|
|
||||||
DWM_BLURBEHIND bb;
|
|
||||||
memset(&bb, 0, sizeof(DWM_BLURBEHIND));
|
|
||||||
bb.fEnable = TRUE;
|
|
||||||
bb.dwFlags = DWM_BB_ENABLE;
|
|
||||||
if(HRESULT hr = g_lamexp_dwmapi.dwmEnableBlurBehindWindow(window->winId(), &bb))
|
|
||||||
{
|
|
||||||
qWarning("DwmEnableBlurBehindWindow function has failed! (error %d)", hr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get system color info
|
|
||||||
*/
|
|
||||||
QColor lamexp_system_color(const int color_id)
|
|
||||||
{
|
|
||||||
int nIndex = -1;
|
|
||||||
|
|
||||||
switch(color_id)
|
|
||||||
{
|
|
||||||
case lamexp_syscolor_text:
|
|
||||||
nIndex = COLOR_WINDOWTEXT; /*Text in windows*/
|
|
||||||
break;
|
|
||||||
case lamexp_syscolor_background:
|
|
||||||
nIndex = COLOR_WINDOW; /*Window background*/
|
|
||||||
break;
|
|
||||||
case lamexp_syscolor_caption:
|
|
||||||
nIndex = COLOR_CAPTIONTEXT; /*Text in caption, size box, and scroll bar arrow box*/
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
qWarning("Unknown system color id (%d) specified!", color_id);
|
|
||||||
nIndex = COLOR_WINDOWTEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
const DWORD rgb = GetSysColor(nIndex);
|
|
||||||
QColor color(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// INITIALIZATION
|
// INITIALIZATION
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
extern "C" void _lamexp_global_init_win32(void)
|
extern "C" void _lamexp_global_init_win32(void)
|
||||||
{
|
{
|
||||||
//Zero *before* constructors are called
|
|
||||||
MUTILS_ZERO_MEMORY(g_lamexp_wine);
|
|
||||||
MUTILS_ZERO_MEMORY(g_lamexp_themes_enabled);
|
|
||||||
MUTILS_ZERO_MEMORY(g_lamexp_dwmapi);
|
|
||||||
MUTILS_ZERO_MEMORY(g_lamexp_sounds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -499,12 +57,4 @@ extern "C" void _lamexp_global_init_win32(void)
|
|||||||
|
|
||||||
extern "C" void _lamexp_global_free_win32(void)
|
extern "C" void _lamexp_global_free_win32(void)
|
||||||
{
|
{
|
||||||
//Release DWM API
|
|
||||||
g_lamexp_dwmapi.dwmIsCompositionEnabled = NULL;
|
|
||||||
g_lamexp_dwmapi.dwmExtendFrameIntoClientArea = NULL;
|
|
||||||
g_lamexp_dwmapi.dwmEnableBlurBehindWindow = NULL;
|
|
||||||
MUTILS_DELETE(g_lamexp_dwmapi.dwmapi_dll);
|
|
||||||
|
|
||||||
//Clear sound cache
|
|
||||||
MUTILS_DELETE(g_lamexp_sounds.sound_db);
|
|
||||||
}
|
}
|
||||||
|
@ -1,130 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// LameXP - Audio Encoder Front-End
|
|
||||||
// Copyright (C) 2004-2014 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, but always including the *additional*
|
|
||||||
// restrictions defined in the "License.txt" file.
|
|
||||||
//
|
|
||||||
// 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)
|
|
||||||
{
|
|
||||||
qWarning("Cannot assign process to job: No job bject available!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Q_PID pid = proc->pid())
|
|
||||||
{
|
|
||||||
DWORD exitCode;
|
|
||||||
if(!GetExitCodeProcess(pid->hProcess, &exitCode))
|
|
||||||
{
|
|
||||||
qWarning("Cannot assign process to job: Failed to query process status!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(exitCode != STILL_ACTIVE)
|
|
||||||
{
|
|
||||||
qWarning("Cannot assign process to job: Process is not running anymore!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!AssignProcessToJobObject(m_hJobObject, pid->hProcess))
|
|
||||||
{
|
|
||||||
qWarning("Failed to assign process to job object!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning("Cannot assign process to job: Process handle not available!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool JobObject::terminateJob(unsigned int exitCode)
|
|
||||||
{
|
|
||||||
if(m_hJobObject)
|
|
||||||
{
|
|
||||||
if(TerminateJobObject(m_hJobObject, exitCode))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning("Failed to terminate job object!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning("Cannot assign process to job: No job bject available!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// LameXP - Audio Encoder Front-End
|
|
||||||
// Copyright (C) 2004-2014 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, but always including the *additional*
|
|
||||||
// restrictions defined in the "License.txt" file.
|
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
bool terminateJob(unsigned int exitCode);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void *m_hJobObject;
|
|
||||||
};
|
|
@ -24,11 +24,11 @@
|
|||||||
|
|
||||||
//Internal
|
//Internal
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "JobObject.h"
|
|
||||||
|
|
||||||
//MUtils
|
//MUtils
|
||||||
#include <MUtils/Global.h>
|
#include <MUtils/Global.h>
|
||||||
#include <MUtils/OSSupport.h>
|
#include <MUtils/OSSupport.h>
|
||||||
|
#include <MUtils/JobObject.h>
|
||||||
|
|
||||||
//Qt
|
//Qt
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
@ -42,7 +42,7 @@
|
|||||||
/*
|
/*
|
||||||
* Static Objects
|
* Static Objects
|
||||||
*/
|
*/
|
||||||
QScopedPointer<JobObject> AbstractTool::s_jobObjectInstance;
|
QScopedPointer<MUtils::JobObject> AbstractTool::s_jobObjectInstance;
|
||||||
QScopedPointer<QElapsedTimer> AbstractTool::s_startProcessTimer;
|
QScopedPointer<QElapsedTimer> AbstractTool::s_startProcessTimer;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -73,7 +73,7 @@ AbstractTool::AbstractTool(void)
|
|||||||
|
|
||||||
if(s_referenceCounter++ == 0)
|
if(s_referenceCounter++ == 0)
|
||||||
{
|
{
|
||||||
s_jobObjectInstance.reset(new JobObject());
|
s_jobObjectInstance.reset(new MUtils::JobObject());
|
||||||
s_startProcessTimer.reset(new QElapsedTimer());
|
s_startProcessTimer.reset(new QElapsedTimer());
|
||||||
if(!MUtils::OS::setup_timer_resolution())
|
if(!MUtils::OS::setup_timer_resolution())
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,11 @@
|
|||||||
class QMutex;
|
class QMutex;
|
||||||
class QProcess;
|
class QProcess;
|
||||||
class QElapsedTimer;
|
class QElapsedTimer;
|
||||||
class JobObject;
|
|
||||||
|
namespace MUtils
|
||||||
|
{
|
||||||
|
class JobObject;
|
||||||
|
}
|
||||||
|
|
||||||
class AbstractTool : public QObject
|
class AbstractTool : public QObject
|
||||||
{
|
{
|
||||||
@ -48,7 +52,7 @@ protected:
|
|||||||
static const int m_processTimeoutInterval = 600000;
|
static const int m_processTimeoutInterval = 600000;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QScopedPointer<JobObject> s_jobObjectInstance;
|
static QScopedPointer<MUtils::JobObject> s_jobObjectInstance;
|
||||||
static QScopedPointer<QElapsedTimer> s_startProcessTimer;
|
static QScopedPointer<QElapsedTimer> s_startProcessTimer;
|
||||||
|
|
||||||
static QMutex s_startProcessMutex;
|
static QMutex s_startProcessMutex;
|
||||||
|
Loading…
Reference in New Issue
Block a user