Moved code to set up the console icon into the MUtilities library. Also added the required icon resource to the MUtilities library.

This commit is contained in:
LoRd_MuldeR 2014-12-03 22:21:53 +01:00
parent 370c5e65f1
commit 49975fd4bb
7 changed files with 44 additions and 31 deletions

View File

@ -15,6 +15,8 @@
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="$(SolutionDir)\tmp\$(ProjectName)\QRC_Resource.cpp" />
<ClCompile Include="$(SolutionDir)\tmp\$(ProjectName)\MOC_UpdateChecker.cpp" />
<ClCompile Include="src\3rd_party\strnatcmp\src\strnatcmp.cpp" /> <ClCompile Include="src\3rd_party\strnatcmp\src\strnatcmp.cpp" />
<ClCompile Include="src\CPUFeatures_Win32.cpp" /> <ClCompile Include="src\CPUFeatures_Win32.cpp" />
<ClCompile Include="src\DLLMain.cpp" /> <ClCompile Include="src\DLLMain.cpp" />
@ -27,7 +29,6 @@
<ClCompile Include="src\Terminal_Win32.cpp" /> <ClCompile Include="src\Terminal_Win32.cpp" />
<ClCompile Include="src\UpdateChecker.cpp" /> <ClCompile Include="src\UpdateChecker.cpp" />
<ClCompile Include="src\Version.cpp" /> <ClCompile Include="src\Version.cpp" />
<ClCompile Include="tmp\MUtilities_VS2013\MOC_UpdateChecker.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="include\MUtils\CPUFeatures.h" /> <ClInclude Include="include\MUtils\CPUFeatures.h" />
@ -57,6 +58,20 @@
<ClInclude Include="include\MUtils\Version.h" /> <ClInclude Include="include\MUtils\Version.h" />
<ClInclude Include="src\CriticalSection_Win32.h" /> <ClInclude Include="src\CriticalSection_Win32.h" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<CustomBuild Include="res\Resource.qrc">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">"$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">RCC "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">RCC "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">RCC "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{55405FE1-149F-434C-9D72-4B64348D2A08}</ProjectGuid> <ProjectGuid>{55405FE1-149F-434C-9D72-4B64348D2A08}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>

View File

@ -36,9 +36,6 @@
<ClCompile Include="src\OSSupport_Win32.cpp"> <ClCompile Include="src\OSSupport_Win32.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="tmp\MUtilities_VS2013\MOC_UpdateChecker.cpp">
<Filter>Source Files\Generated</Filter>
</ClCompile>
<ClCompile Include="src\Version.cpp"> <ClCompile Include="src\Version.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -66,6 +63,12 @@
<ClCompile Include="src\3rd_party\strnatcmp\src\strnatcmp.cpp"> <ClCompile Include="src\3rd_party\strnatcmp\src\strnatcmp.cpp">
<Filter>Source Files\3rd Party</Filter> <Filter>Source Files\3rd Party</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\tmp\$(ProjectName)\QRC_Resource.cpp">
<Filter>Source Files\Generated</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\tmp\$(ProjectName)\MOC_UpdateChecker.cpp">
<Filter>Source Files\Generated</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\CriticalSection_Win32.h"> <ClInclude Include="src\CriticalSection_Win32.h">
@ -118,5 +121,8 @@
<CustomBuild Include="include\Mutils\UpdateChecker.h"> <CustomBuild Include="include\Mutils\UpdateChecker.h">
<Filter>Public Headers</Filter> <Filter>Public Headers</Filter>
</CustomBuild> </CustomBuild>
<CustomBuild Include="res\Resource.qrc">
<Filter>Resource Files</Filter>
</CustomBuild>
</ItemGroup> </ItemGroup>
</Project> </Project>

6
res/Resource.qrc Normal file
View File

@ -0,0 +1,6 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/mutils">
<file>icons/bug.png</file>
</qresource>
</RCC>

BIN
res/icons/bug.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

View File

@ -242,6 +242,9 @@ bool MUtils::Startup::init_qt(int &argc, char **argv, const QString &appName)
} }
} }
//Setup console icon
MUtils::Terminal::set_icon(QIcon(":/mutils/icons/bug.png"));
//Enable larger/smaller font size //Enable larger/smaller font size
double fontScaleFactor = 1.0; double fontScaleFactor = 1.0;
if(arguments.contains("--huge-font", Qt::CaseInsensitive)) fontScaleFactor = 1.500; if(arguments.contains("--huge-font", Qt::CaseInsensitive)) fontScaleFactor = 1.500;

View File

@ -339,7 +339,7 @@ void MUtils::Terminal::set_icon(const QIcon &icon)
{ {
MUtils::Internal::CSLocker lock(g_terminal_lock); MUtils::Internal::CSLocker lock(g_terminal_lock);
if(!(icon.isNull() || MUtils::OS::running_on_wine())) if(g_terminal_attached && (!(icon.isNull() || MUtils::OS::running_on_wine())))
{ {
QLibrary kernel32("kernel32.dll"); QLibrary kernel32("kernel32.dll");
if(kernel32.load()) if(kernel32.load())

View File

@ -29,10 +29,6 @@
#include <MUtils/OSSupport.h> #include <MUtils/OSSupport.h>
#include "Config.h" #include "Config.h"
#ifdef _MSC_VER
#define _snscanf(X, Y, Z, ...) _snscanf_s((X), (Y), (Z), __VA_ARGS__)
#endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// HELPER FUNCTIONS // HELPER FUNCTIONS
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -45,7 +41,7 @@ static int month_str2int(const char *str)
for(int j = 0; j < 12; j++) for(int j = 0; j < 12; j++)
{ {
if(!_strcmpi(str, g_months_lut[j])) if(!_strnicmp(str, g_months_lut[j], 3))
{ {
ret = j+1; ret = j+1;
break; break;
@ -57,18 +53,14 @@ static int month_str2int(const char *str)
static const QDate decode_date_str(const char *const date_str) //Mmm dd yyyy static const QDate decode_date_str(const char *const date_str) //Mmm dd yyyy
{ {
bool ok = true;
int date[3] = {0, 0, 0}; int date[3] = {0, 0, 0};
char buffer[12];
strcpy_s(buffer, 12, date_str); if(sscanf_s(date_str, "%*3s %2d %4d", &date[2], &date[0]) != 2)
buffer[3] = buffer[6] = '\0'; {
MUTILS_THROW("Internal error: Date format could not be recognized!");
}
ok = ok && ((date[1] = month_str2int(&buffer[0])) > 0); if((date[1] = month_str2int(date_str)) < 1)
ok = ok && (sscanf_s(&buffer[4], "%d", &date[2]) == 1);
ok = ok && (sscanf_s(&buffer[7], "%d", &date[0]) == 1);
if(!ok)
{ {
MUTILS_THROW("Internal error: Date format could not be recognized!"); MUTILS_THROW("Internal error: Date format could not be recognized!");
} }
@ -79,18 +71,9 @@ static const QDate decode_date_str(const char *const date_str) //Mmm dd yyyy
static const QTime decode_time_str(const char *const time_str) //hh:mm:ss static const QTime decode_time_str(const char *const time_str) //hh:mm:ss
{ {
bool ok = true;
int time[3] = {0, 0, 0}; int time[3] = {0, 0, 0};
char buffer[9];
strcpy_s(buffer, 9, time_str); if(sscanf_s(time_str, "%2d:%2d:%2d", &time[0], &time[1], &time[2]) != 3)
buffer[2] = buffer[5] = '\0';
ok = ok && (sscanf_s(&time_str[0], "%d", &time[0]) == 1);
ok = ok && (sscanf_s(&time_str[3], "%d", &time[1]) == 1);
ok = ok && (sscanf_s(&time_str[6], "%d", &time[2]) == 1);
if(!ok)
{ {
MUTILS_THROW("Internal error: Time format could not be recognized!"); MUTILS_THROW("Internal error: Time format could not be recognized!");
} }