UBGlobals.h 2.15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 */

16 17 18
#ifndef UBGLOBALS_H
#define UBGLOBALS_H

19 20 21
#include <QString>
#include <QFile>

22 23 24 25 26
#define DELETEPTR(ptr) if(NULL != ptr){ \
    delete ptr; \
    ptr = NULL; \
    }

27 28 29 30 31 32 33 34 35
#define SET_STYLE_SHEET() {\
    setAttribute(Qt::WA_StyledBackground, true);\
    QString style;\
    QFile f(":style.qss");\
    if(f.exists() && f.open(QIODevice::ReadOnly))\
            style = QString(f.readAll());\
     setStyleSheet(style);\
}

36 37 38 39 40 41 42 43
#ifdef Q_WS_WIN

#define WARNINGS_DISABLE __pragma(warning(push, 0));
#define WARNINGS_ENABLE __pragma(warning(pop));

#ifdef NO_THIRD_PARTY_WARNINGS
// disabling warning level to 0 and save old state
#define THIRD_PARTY_WARNINGS_DISABLE WARNINGS_DISABLE
44
#else
45 46 47 48 49 50 51 52 53
// just save old state (needs for not empty define)
#define THIRD_PARTY_WARNINGS_DISABLE __pragma(warning(push));
#endif //#ifdef NO_THIRD_PARTY_WARNINGS

#else //#ifdef Q_WS_WIN

#define WARNINGS_DISABLE _Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wunused-parameter\""); \
_Pragma("GCC diagnostic ignored \"-Wunused-variable\""); \
54
_Pragma("GCC diagnostic ignored \"-Wsign-compare\"");
55

56
#define WARNINGS_ENABLE _Pragma("GCC diagnostic pop");
57 58 59 60 61 62

#ifdef NO_THIRD_PARTY_WARNINGS
//disabling some warnings
#define THIRD_PARTY_WARNINGS_DISABLE WARNINGS_DISABLE
#else
// just save old state (needs for not empty define)
63
#define THIRD_PARTY_WARNINGS_DISABLE _Pragma("GCC diagnostic push");
64 65 66 67 68

#endif //#ifdef NO_THIRD_PARTY_WARNINGS

#endif //#ifdef Q_WS_WIN

69 70 71
// anyway on any OS
#define THIRD_PARTY_WARNINGS_ENABLE WARNINGS_ENABLE

72
#endif // UBGLOBALS_H
73