From 49975fd4bb0092b728b7731d2acb8e7450fb0289 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Wed, 3 Dec 2014 22:21:53 +0100 Subject: [PATCH] Moved code to set up the console icon into the MUtilities library. Also added the required icon resource to the MUtilities library. --- MUtilities_VS2013.vcxproj | 17 ++++++++++++++++- MUtilities_VS2013.vcxproj.filters | 12 +++++++++--- res/Resource.qrc | 6 ++++++ res/icons/bug.png | Bin 0 -> 774 bytes src/Startup.cpp | 3 +++ src/Terminal_Win32.cpp | 2 +- src/Version.cpp | 33 ++++++++------------------------- 7 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 res/Resource.qrc create mode 100644 res/icons/bug.png diff --git a/MUtilities_VS2013.vcxproj b/MUtilities_VS2013.vcxproj index 03d0d9d..8ae0cf5 100644 --- a/MUtilities_VS2013.vcxproj +++ b/MUtilities_VS2013.vcxproj @@ -15,6 +15,8 @@ + + @@ -27,7 +29,6 @@ - @@ -57,6 +58,20 @@ + + + Document + "$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)" + "$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)" + "$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" -name "%(Filename)" "%(FullPath)" + RCC "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" + RCC "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" + RCC "$(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp" + $(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\$(ProjectName)\QRC_%(Filename).cpp;%(Outputs) + + {55405FE1-149F-434C-9D72-4B64348D2A08} Win32Proj diff --git a/MUtilities_VS2013.vcxproj.filters b/MUtilities_VS2013.vcxproj.filters index ef79cac..17a0908 100644 --- a/MUtilities_VS2013.vcxproj.filters +++ b/MUtilities_VS2013.vcxproj.filters @@ -36,9 +36,6 @@ Source Files - - Source Files\Generated - Source Files @@ -66,6 +63,12 @@ Source Files\3rd Party + + Source Files\Generated + + + Source Files\Generated + @@ -118,5 +121,8 @@ Public Headers + + Resource Files + \ No newline at end of file diff --git a/res/Resource.qrc b/res/Resource.qrc new file mode 100644 index 0000000..728a58a --- /dev/null +++ b/res/Resource.qrc @@ -0,0 +1,6 @@ + + + + icons/bug.png + + diff --git a/res/icons/bug.png b/res/icons/bug.png new file mode 100644 index 0000000000000000000000000000000000000000..2d5fb90ec6ee08f53947e0266a87b03f75893446 GIT binary patch literal 774 zcmV+h1Nr=kP) zlgUq0Q544c8(ae&UR$8ps&snq6^bPY3v3xAmMW74Di$h~GCH6E3TaYs2#6A<7K*gC z777H71_Wa;(dfp+g-drPCSWu)#PInZi72LJ;o?i~$-U=y&UbQ89Dul3%3P+Axkzc* zbH-y;QF=hR{qLItf%ci2_&e5wNo0gnVatG?ul6Zw=o$I9Ljfn*ic3`U?>IfEim3g{ zujU&$-hy6wn;w(xme|zJm;lWJxtTFfM)q0`kX!Vu0+d${$}LCddK1<^htTe-fUYL3 zB`SdNsZD>RgvLj1<^@h6_+cDRK2Brcr2~>%$*5S)hyV33PV^teac3%|4lz@8p4?)5 z?t5o^?q+%^%)Yygo~I^U4VR!bTnWuE35hcWrfCDR3q+sxJ79e7Fg`&)RCqLA^2^y^ z0laVfadW90_Fz8Brm|r47sB^u1VgI>kanj)Z4`zMSfHlm8>CwXa$JVM`$2RrmZB-3 zN10m-!;BvH*Br3V8t`DH7m`jf#2upVDXl{5ff18_pzCPK1Zu$$CKKvd8FGeFf)+K<|x33pc7P&S#3GZT4mEw;nr(Ze*F z3&*?-4U-lm*#tber5 z%S_ceqB`b3ko6r~BbvDwdohTvP(3a(pq{x#T$yQsu#OKwEe}KuH^Mh@nxg_(Nw136 zq#a^3xNBke)In+!?qk3%4wB69{pF`Tzg`07*qoM6N<$ Eg55P&8UO$Q literal 0 HcmV?d00001 diff --git a/src/Startup.cpp b/src/Startup.cpp index 16da7a4..1558982 100644 --- a/src/Startup.cpp +++ b/src/Startup.cpp @@ -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 double fontScaleFactor = 1.0; if(arguments.contains("--huge-font", Qt::CaseInsensitive)) fontScaleFactor = 1.500; diff --git a/src/Terminal_Win32.cpp b/src/Terminal_Win32.cpp index b3ba9d9..f46ab57 100644 --- a/src/Terminal_Win32.cpp +++ b/src/Terminal_Win32.cpp @@ -339,7 +339,7 @@ void MUtils::Terminal::set_icon(const QIcon &icon) { 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"); if(kernel32.load()) diff --git a/src/Version.cpp b/src/Version.cpp index dbbc9a4..5c3d9d8 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -29,10 +29,6 @@ #include #include "Config.h" -#ifdef _MSC_VER -#define _snscanf(X, Y, Z, ...) _snscanf_s((X), (Y), (Z), __VA_ARGS__) -#endif - /////////////////////////////////////////////////////////////////////////////// // HELPER FUNCTIONS /////////////////////////////////////////////////////////////////////////////// @@ -45,7 +41,7 @@ static int month_str2int(const char *str) 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; break; @@ -57,40 +53,27 @@ static int month_str2int(const char *str) static const QDate decode_date_str(const char *const date_str) //Mmm dd yyyy { - bool ok = true; int date[3] = {0, 0, 0}; - char buffer[12]; - - strcpy_s(buffer, 12, date_str); - buffer[3] = buffer[6] = '\0'; - ok = ok && ((date[1] = month_str2int(&buffer[0])) > 0); - ok = ok && (sscanf_s(&buffer[4], "%d", &date[2]) == 1); - ok = ok && (sscanf_s(&buffer[7], "%d", &date[0]) == 1); + if(sscanf_s(date_str, "%*3s %2d %4d", &date[2], &date[0]) != 2) + { + MUTILS_THROW("Internal error: Date format could not be recognized!"); + } - if(!ok) + if((date[1] = month_str2int(date_str)) < 1) { MUTILS_THROW("Internal error: Date format could not be recognized!"); } - + //qWarning("MUtils::Version::build_date: y=%d, m=%d, d=%d", date[0], date[1], date[2]); return QDate(date[0], date[1], date[2]); } static const QTime decode_time_str(const char *const time_str) //hh:mm:ss { - bool ok = true; int time[3] = {0, 0, 0}; - char buffer[9]; - - strcpy_s(buffer, 9, time_str); - 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) + if(sscanf_s(time_str, "%2d:%2d:%2d", &time[0], &time[1], &time[2]) != 3) { MUTILS_THROW("Internal error: Time format could not be recognized!"); } -- 2.11.0