mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-07 03:30:44 +00:00
Mac build fix take #1
This commit is contained in:
parent
3ffbc14138
commit
231e8749c6
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#if QT_VERSION<0x400800
|
#if QT_VERSION<0x400800
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
#include "cocoacommon.h"
|
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -15,9 +14,12 @@
|
|||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// This function has been "borrowed".. Ahem..
|
||||||
Qt::DayOfWeek firstDayOfWeekFromLocale()
|
Qt::DayOfWeek firstDayOfWeekFromLocale()
|
||||||
{
|
{
|
||||||
Qt::DayOfWeek firstDay = Qt::Monday;
|
Qt::DayOfWeek firstDay = Qt::Monday; // Fallback, acknowledging the awesome concept of Week End.
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
WCHAR wsDay[4];
|
WCHAR wsDay[4];
|
||||||
# if defined(_WIN32_WINNT_VISTA) && WINVER >= _WIN32_WINNT_VISTA && defined(LOCALE_NAME_USER_DEFAULT)
|
# if defined(_WIN32_WINNT_VISTA) && WINVER >= _WIN32_WINNT_VISTA && defined(LOCALE_NAME_USER_DEFAULT)
|
||||||
@ -25,8 +27,8 @@ Qt::DayOfWeek firstDayOfWeekFromLocale()
|
|||||||
# else
|
# else
|
||||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, wsDay, 4)) {
|
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, wsDay, 4)) {
|
||||||
# endif
|
# endif
|
||||||
bool ok;
|
bool ok;
|
||||||
int wfd = QString::fromWCharArray(wsDay).toInt(&ok) + 1;
|
int wfd = QString::fromWCharArray(wsDay).toInt(&ok) + 1;
|
||||||
if (ok) {
|
if (ok) {
|
||||||
firstDay = (Qt::DayOfWeek)(unsigned char)wfd;
|
firstDay = (Qt::DayOfWeek)(unsigned char)wfd;
|
||||||
}
|
}
|
||||||
@ -34,6 +36,7 @@ Qt::DayOfWeek firstDayOfWeekFromLocale()
|
|||||||
#elif defined(__GLIBC__)
|
#elif defined(__GLIBC__)
|
||||||
firstDay = (Qt::DayOfWeek)(unsigned char)((*nl_langinfo(_NL_TIME_FIRST_WEEKDAY) + 5) % 7 + 1);
|
firstDay = (Qt::DayOfWeek)(unsigned char)((*nl_langinfo(_NL_TIME_FIRST_WEEKDAY) + 5) % 7 + 1);
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
|
// Unsure if this will work.. Most Mac users use 4.8 anyway, so won't see this code..
|
||||||
NSCalendar *cal = [NSCalendar currentCalendar];
|
NSCalendar *cal = [NSCalendar currentCalendar];
|
||||||
int day = ([cal firstWeekday] + 5) % 7 + 1;
|
int day = ([cal firstWeekday] + 5) % 7 + 1;
|
||||||
|
|
||||||
@ -44,6 +47,7 @@ Qt::DayOfWeek firstDayOfWeekFromLocale()
|
|||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
// Qt 4.8 makes this a whole lot easier
|
||||||
Qt::DayOfWeek firstDayOfWeekFromLocale()
|
Qt::DayOfWeek firstDayOfWeekFromLocale()
|
||||||
{
|
{
|
||||||
return QLocale::system().firstDayOfWeek();
|
return QLocale::system().firstDayOfWeek();
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
#ifndef COMMON_GUI_H
|
#ifndef COMMON_GUI_H
|
||||||
#define COMMON_GUI_H
|
#define COMMON_GUI_H
|
||||||
|
|
||||||
//#if QT_VERSION
|
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
Qt::DayOfWeek firstDayOfWeekFromLocale();
|
Qt::DayOfWeek firstDayOfWeekFromLocale();
|
||||||
//#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user