Warning, file /system/qtcurve/qt4/style/utils.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  *   Copyright 2007 - 2010 Craig Drummond <craig.p.drummond@gmail.com>       *
0003  *   Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com>                     *
0004  *                                                                           *
0005  *   This program is free software; you can redistribute it and/or modify    *
0006  *   it under the terms of the GNU Lesser General Public License as          *
0007  *   published by the Free Software Foundation; either version 2.1 of the    *
0008  *   License, or (at your option) version 3, or any later version accepted   *
0009  *   by the membership of KDE e.V. (or its successor approved by the         *
0010  *   membership of KDE e.V.), which shall act as a proxy defined in          *
0011  *   Section 6 of version 3 of the license.                                  *
0012  *                                                                           *
0013  *   This program is distributed in the hope that it will be useful,         *
0014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0016  *   Lesser General Public License for more details.                         *
0017  *                                                                           *
0018  *   You should have received a copy of the GNU Lesser General Public        *
0019  *   License along with this library. If not,                                *
0020  *   see <http://www.gnu.org/licenses/>.                                     *
0021  *****************************************************************************/
0022 
0023 #include "config.h"
0024 #include <qtcurve-utils/x11utils.h>
0025 #include <qtcurve-utils/log.h>
0026 
0027 #include "utils.h"
0028 #include <QDir>
0029 
0030 #ifdef Q_WS_X11
0031 #  include <QX11Info>
0032 #endif
0033 
0034 #ifndef QTC_QT4_ENABLE_KDE
0035 #  undef KDE_IS_VERSION
0036 #  define KDE_IS_VERSION(A, B, C) 0
0037 #else
0038 #  include <kdeversion.h>
0039 #  include <KDE/KWindowSystem>
0040 #endif
0041 
0042 namespace QtCurve {
0043 namespace Utils {
0044 
0045 bool
0046 compositingActive()
0047 {
0048 #if !defined QTC_QT4_ENABLE_KDE || !KDE_IS_VERSION(4, 4, 0)
0049     return qtcX11CompositingActive();
0050 #else // QTC_QT4_ENABLE_KDE
0051     return KWindowSystem::compositingActive();
0052 #endif // QTC_QT4_ENABLE_KDE
0053 }
0054 
0055 bool
0056 hasAlphaChannel(const QWidget *widget)
0057 {
0058     QTC_RET_IF_FAIL(widget, false);
0059 #ifdef Q_WS_X11
0060     return widget->x11Info().depth() == 32;
0061 #else
0062     return compositingActive();
0063 #endif
0064 }
0065 
0066 QString kdeHome()
0067 {
0068     static QString kdeHomePath;
0069     if (kdeHomePath.isEmpty()) {
0070         kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
0071         if (kdeHomePath.isEmpty()) {
0072             const QString homePath = QDir::homePath();
0073             const QDir homeDir = QDir(homePath);
0074             if (homeDir.exists(QLatin1String(".kde4"))) {
0075                 kdeHomePath = homePath + "/.kde4";
0076             } else {
0077                 kdeHomePath = homePath + "/.kde";
0078             }
0079         }
0080     }
0081     return kdeHomePath;
0082 }
0083 
0084 }
0085 }