diff options
-rw-r--r-- | examples/systeminfo/qml-deviceinfo/qml-deviceinfo.qml | 23 | ||||
-rw-r--r-- | src/imports/systeminfo/qsysteminfo.cpp | 2 | ||||
-rw-r--r-- | src/imports/systeminfo/systeminfo.pro | 2 | ||||
-rw-r--r-- | src/systeminfo/linux/qdisplayinfo_linux.cpp | 111 | ||||
-rw-r--r-- | src/systeminfo/linux/qdisplayinfo_linux_p.h | 78 | ||||
-rw-r--r-- | src/systeminfo/mac/qdisplayinfo_mac.mm | 215 | ||||
-rw-r--r-- | src/systeminfo/mac/qdisplayinfo_mac_p.h | 88 | ||||
-rw-r--r-- | src/systeminfo/qdisplayinfo.cpp | 217 | ||||
-rw-r--r-- | src/systeminfo/qdisplayinfo.h | 90 | ||||
-rw-r--r-- | src/systeminfo/simulator/qsysteminfodata_simulator.cpp | 23 | ||||
-rw-r--r-- | src/systeminfo/simulator/qsysteminfodata_simulator_p.h | 11 | ||||
-rw-r--r-- | src/systeminfo/systeminfo.pro | 14 | ||||
-rw-r--r-- | tests/auto/cmake/test_modules/main.cpp | 4 | ||||
-rw-r--r-- | tests/auto/systeminfo/qdisplayinfo/qdisplayinfo.pro | 6 | ||||
-rw-r--r-- | tests/auto/systeminfo/qdisplayinfo/tst_qdisplayinfo.cpp | 120 | ||||
-rw-r--r-- | tests/auto/systeminfo/systeminfo.pro | 1 |
16 files changed, 4 insertions, 1001 deletions
diff --git a/examples/systeminfo/qml-deviceinfo/qml-deviceinfo.qml b/examples/systeminfo/qml-deviceinfo/qml-deviceinfo.qml index 336202eb..f27065ad 100644 --- a/examples/systeminfo/qml-deviceinfo/qml-deviceinfo.qml +++ b/examples/systeminfo/qml-deviceinfo/qml-deviceinfo.qml @@ -90,25 +90,6 @@ Rectangle { font.bold: true } Text { - text: "backlight state: " + displayInfo.backlightState(0); - } - Text { - text: "brightness: " + displayInfo.brightness(0); - } - Text { - text: "contrast: " + displayInfo.contrast(0); - } - Text { - text: "colorDepth: " + displayInfo.colorDepth(0); - } - Text { - text: "pitch: " + displayInfo.dpiX(0) + " x " + displayInfo.dpiY(0) + " DPI; " + - parseFloat(25.4 / displayInfo.dpiX(0)).toFixed(4) + " x " + parseFloat(25.4 / displayInfo.dpiY(0)).toFixed(4) + "mm" - } - Text { - text: "physical size: " + displayInfo.physicalWidth(0) + " x " + displayInfo.physicalHeight(0); - } - Text { text: "resolution: " + Screen.width + " x " + Screen.height; } Text { @@ -148,8 +129,4 @@ Rectangle { DeviceInfo { id: devinfo; } - - DisplayInfo { - id: displayInfo - } } diff --git a/src/imports/systeminfo/qsysteminfo.cpp b/src/imports/systeminfo/qsysteminfo.cpp index 8866c147..072902d1 100644 --- a/src/imports/systeminfo/qsysteminfo.cpp +++ b/src/imports/systeminfo/qsysteminfo.cpp @@ -45,7 +45,6 @@ #include "qdeclarativebatteryinfo_p.h" #include "qdeclarativedeviceinfo_p.h" #include "qdeclarativedeviceprofile_p.h" -#include "qdeclarativedisplayinfo_p.h" #include "qdeclarativenetworkinfo_p.h" #include <qscreensaver.h> #include "qdeclarativestorageinfo_p.h" @@ -67,7 +66,6 @@ public: qmlRegisterType<QDeclarativeBatteryInfo>(uri, major, minor, "BatteryInfo"); qmlRegisterType<QDeclarativeDeviceInfo>(uri, major, minor, "DeviceInfo"); qmlRegisterType<QDeclarativeDeviceProfile>(uri, major, minor, "DeviceProfile"); - qmlRegisterType<QDeclarativeDisplayInfo>(uri, major, minor, "DisplayInfo"); qmlRegisterType<QDeclarativeNetworkInfo>(uri, major, minor, "NetworkInfo"); qmlRegisterType<QScreenSaver>(uri, major, minor, "ScreenSaver"); qmlRegisterType<QDeclarativeStorageInfo>(uri, major, minor, "StorageInfo"); diff --git a/src/imports/systeminfo/systeminfo.pro b/src/imports/systeminfo/systeminfo.pro index 0cfd159e..e2d9a535 100644 --- a/src/imports/systeminfo/systeminfo.pro +++ b/src/imports/systeminfo/systeminfo.pro @@ -4,7 +4,6 @@ QT -= gui HEADERS += \ qdeclarativebatteryinfo_p.h \ qdeclarativedeviceinfo_p.h \ - qdeclarativedisplayinfo_p.h \ qdeclarativenetworkinfo_p.h \ qdeclarativestorageinfo_p.h \ qdeclarativedeviceprofile_p.h @@ -12,7 +11,6 @@ HEADERS += \ SOURCES += \ qdeclarativebatteryinfo.cpp \ qdeclarativedeviceinfo.cpp \ - qdeclarativedisplayinfo.cpp \ qdeclarativenetworkinfo.cpp \ qdeclarativestorageinfo.cpp \ qdeclarativedeviceprofile.cpp \ diff --git a/src/systeminfo/linux/qdisplayinfo_linux.cpp b/src/systeminfo/linux/qdisplayinfo_linux.cpp deleted file mode 100644 index 234f7f20..00000000 --- a/src/systeminfo/linux/qdisplayinfo_linux.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSystems module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdisplayinfo_linux_p.h" - -#include <QtCore/qdir.h> -#include <QtCore/qmap.h> -#include <QtCore/qmetaobject.h> - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC_WITH_ARGS(const QString, BACKLIGHT_SYSFS_PATH, (QLatin1String("/sys/class/backlight/"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, GRAPHICS_SYSFS_PATH, (QLatin1String("/sys/class/graphics/"))) - -QDisplayInfoPrivate::QDisplayInfoPrivate(QDisplayInfo *parent) - : q_ptr(parent) -{ -} - -int QDisplayInfoPrivate::brightness(int screen) -{ - QMap<QString, QStringList> brightnessMap; - brightnessMap.insert(*BACKLIGHT_SYSFS_PATH(), QStringList() << QStringLiteral("/max_brightness") << QStringLiteral("/actual_brightness")); - brightnessMap.insert(*GRAPHICS_SYSFS_PATH(), QStringList() << QStringLiteral("/backlight_max") << QStringLiteral("/backlight")); - - QStringList sysfsPaths = brightnessMap.keys(); - foreach (const QString &sysfsPath, sysfsPaths) { - const QStringList dirs = QDir(sysfsPath).entryList(QDir::Dirs | QDir::NoDotAndDotDot); - if (dirs.size() <= screen) - continue; - bool ok = false; - int max = 0; - int actual = 0; - QFile brightness(sysfsPath + dirs.at(screen) + brightnessMap.value(sysfsPath).at(0)); - if (brightness.open(QIODevice::ReadOnly)) { - max = brightness.readAll().simplified().toInt(&ok); - if (!ok || max == 0) - continue; - brightness.close(); - - brightness.setFileName(sysfsPath + dirs.at(screen) + brightnessMap.value(sysfsPath).at(1)); - if (brightness.open(QIODevice::ReadOnly)) { - actual = brightness.readAll().simplified().toInt(&ok); - if (!ok) - continue; - - return actual * 100 / max; - } - } - } - - return -1; -} - -int QDisplayInfoPrivate::contrast(int screen) -{ - Q_UNUSED(screen) - return -1; -} - -QDisplayInfo::BacklightState QDisplayInfoPrivate::backlightState(int screen) -{ - int actualBrightness = brightness(screen); - - if (actualBrightness > 0) - return QDisplayInfo::BacklightOn; - else if (actualBrightness == 0) - return QDisplayInfo::BacklightOff; - else - return QDisplayInfo::BacklightUnknown; -} - -QT_END_NAMESPACE diff --git a/src/systeminfo/linux/qdisplayinfo_linux_p.h b/src/systeminfo/linux/qdisplayinfo_linux_p.h deleted file mode 100644 index 3eb4ffcc..00000000 --- a/src/systeminfo/linux/qdisplayinfo_linux_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSystems module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QDISPLAYINFO_LINUX_P_H -#define QDISPLAYINFO_LINUX_P_H - -#include <qdisplayinfo.h> - -QT_BEGIN_NAMESPACE - -class QDisplayInfoPrivate : public QObject -{ - Q_OBJECT - -public: - QDisplayInfoPrivate(QDisplayInfo *parent); - - int brightness(int screen); - int contrast(int screen); - QDisplayInfo::BacklightState backlightState(int screen); - -private: - QDisplayInfo * const q_ptr; - Q_DECLARE_PUBLIC(QDisplayInfo) -}; - -QT_END_NAMESPACE - -#endif // QDISPLAYINFO_LINUX_P_H diff --git a/src/systeminfo/mac/qdisplayinfo_mac.mm b/src/systeminfo/mac/qdisplayinfo_mac.mm deleted file mode 100644 index a9a6777d..00000000 --- a/src/systeminfo/mac/qdisplayinfo_mac.mm +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSystems module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdisplayinfo_mac_p.h" -#include <QtCore/private/qcore_mac_p.h> - -#include <QtCore/QDir> -#include <QtCore/QSettings> - -#include <IOKit/graphics/IOGraphicsLib.h> -#include <CoreFoundation/CoreFoundation.h> -#include <ApplicationServices/ApplicationServices.h> - -#include <CoreServices/CoreServices.h> -#include <QDebug> - -CGDirectDisplayID getCGId(int screen) -{ - CGDirectDisplayID displayId[16]; - CGDisplayCount count; - CGDisplayErr error = CGGetOnlineDisplayList(16,displayId, & count); - if (error == kCGErrorSuccess) { - return displayId[screen]; - } - return CGMainDisplayID(); -} - -static int GetIntFromDictionaryForKey(CFDictionaryRef desc, CFStringRef key) -{ - CFNumberRef value; - int resultNumber = 0; - if ((value = (const __CFNumber*)CFDictionaryGetValue(desc,key)) == NULL - || CFGetTypeID(value) != CFNumberGetTypeID()) - return 0; - CFNumberGetValue(value, kCFNumberIntType, &resultNumber); - return resultNumber; -} - -CGDisplayErr GetDisplayDPI(CFDictionaryRef displayModeDict,CGDirectDisplayID displayID, - double *horizontalDPI, double *verticalDPI) -{ - CGDisplayErr displayError = kCGErrorFailure; - io_connect_t ioPort; - CFDictionaryRef displayDict; - - ioPort = CGDisplayIOServicePort(displayID); - if (ioPort != MACH_PORT_NULL) { - displayDict = IOCreateDisplayInfoDictionary(ioPort, 0); - if (displayDict != NULL) { - const double mmPerInch = 25.4; - double horizontalSizeInInches = (double)GetIntFromDictionaryForKey(displayDict, CFSTR(kDisplayHorizontalImageSize)) / mmPerInch; - double verticalSizeInInches = (double)GetIntFromDictionaryForKey(displayDict, CFSTR(kDisplayVerticalImageSize)) / mmPerInch; - - CFRelease(displayDict); - - *horizontalDPI = (double)GetIntFromDictionaryForKey(displayModeDict, kCGDisplayWidth) / horizontalSizeInInches; - *verticalDPI = (double)GetIntFromDictionaryForKey(displayModeDict, kCGDisplayHeight) / verticalSizeInInches; - displayError = CGDisplayNoErr; - } - } - return displayError; -} - -QT_BEGIN_NAMESPACE - -QDisplayInfoPrivate::QDisplayInfoPrivate(QDisplayInfo *parent) - : q_ptr(parent) -{ - qDebug() << __FUNCTION__; - -} - -int QDisplayInfoPrivate::brightness(int screen) -{ - CGDisplayErr dErr; - io_service_t service; - CFStringRef key = CFSTR(kIODisplayBrightnessKey); - - float brightness = 0.0; - int displayBrightness = -1; - service = CGDisplayIOServicePort(getCGId(screen)); - dErr = IODisplayGetFloatParameter(service, kNilOptions, key, &brightness); - displayBrightness = (int)(brightness * 100); - return displayBrightness; -} - -int QDisplayInfoPrivate::contrast(int screen) -{ - Q_UNUSED(screen); - QString accessplist = QDir::homePath() + "/Library/Preferences/com.apple.universalaccess.plist"; - QSettings accessSettings(accessplist, QSettings::NativeFormat); - accessSettings.value("contrast").toFloat(); - return accessSettings.value("contrast").toFloat(); -} - -QDisplayInfo::BacklightState QDisplayInfoPrivate::backlightState(int screen) -{ - int bright = brightness(screen); - if (bright == 0) { - return QDisplayInfo::BacklightOff; - } else if (bright > 1 && bright < 99) { - return QDisplayInfo::BacklightOff; - } else { - return QDisplayInfo::BacklightOn; - } - return QDisplayInfo::BacklightUnknown; -} - -int QDisplayInfoPrivate::colorDepth(int screen) const -{ - qDebug() << __FUNCTION__; - long bitsPerPixel = 0; -#ifndef MAC_SDK_10_5 - CGDisplayModeRef mode = CGDisplayCopyDisplayMode(getCGId(screen)); - bitsPerPixel = QCFString::toQString(CGDisplayModeCopyPixelEncoding(mode)).toLong(); -#else - bitsPerPixel = CGDisplayBitsPerPixel(getCGId(screen)); -#endif - return (int)bitsPerPixel; -} - -int QDisplayInfoPrivate::dpiX(int screen) const -{ - int dpi=0; - if (screen < 16 && screen > -1) { - double horizontalDPI, verticalDPI; - - // TODO CGDisplayCopyDisplayMode depreciated - - CGDisplayErr displayError = GetDisplayDPI(CGDisplayCurrentMode(kCGDirectMainDisplay), kCGDirectMainDisplay, &horizontalDPI, &verticalDPI); - if (displayError == CGDisplayNoErr) { - dpi = horizontalDPI; - } - } - return dpi; -} - -int QDisplayInfoPrivate::dpiY(int screen) const -{ - int dpi=0; - if (screen < 16 && screen > -1) { - double horizontalDPI, verticalDPI; - - CGDisplayErr displayError = GetDisplayDPI(CGDisplayCurrentMode(kCGDirectMainDisplay), kCGDirectMainDisplay, &horizontalDPI, &verticalDPI); - if (displayError == CGDisplayNoErr) { - dpi = verticalDPI; - } - } - return dpi; - -} - -int QDisplayInfoPrivate::physicalHeight(int screen) const -{ - int height=0; - if (screen < 16 && screen > -1) { - CGSize size = CGDisplayScreenSize(getCGId(screen)); - height = size.height; - } - return height; - -} - -int QDisplayInfoPrivate::physicalWidth(int screen) const -{ - int width=0; - if (screen < 16 && screen > -1) { - CGSize size = CGDisplayScreenSize(getCGId(screen)); - width = size.width; - } - return width; - -} - - -QT_END_NAMESPACE - diff --git a/src/systeminfo/mac/qdisplayinfo_mac_p.h b/src/systeminfo/mac/qdisplayinfo_mac_p.h deleted file mode 100644 index 99437352..00000000 --- a/src/systeminfo/mac/qdisplayinfo_mac_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSystems module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QDISPLAYINFO_MAC_P_H -#define QDISPLAYINFO_MAC_P_H - -#include <qdisplayinfo.h> - -QT_BEGIN_NAMESPACE - -class QDisplayInfoPrivate : public QObject -{ - Q_OBJECT - -public: - QDisplayInfoPrivate(QDisplayInfo *parent); - - int brightness(int screen); - int contrast(int screen); - QDisplayInfo::BacklightState backlightState(int screen); - - int colorDepth(int screen) const; - int dpiX(int screen) const; - int dpiY(int screen) const; - int physicalHeight(int screen) const; - int physicalWidth(int screen) const; - -Q_SIGNALS: - void backlightStateChanged(int screen, QDisplayInfo::BacklightState state); - -private: - QDisplayInfo * const q_ptr; - Q_DECLARE_PUBLIC(QDisplayInfo) - -}; - -QT_END_NAMESPACE - -#endif // QDISPLAYINFO_MAC_P_H diff --git a/src/systeminfo/qdisplayinfo.cpp b/src/systeminfo/qdisplayinfo.cpp deleted file mode 100644 index f68abac5..00000000 --- a/src/systeminfo/qdisplayinfo.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSystems module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdisplayinfo.h" - -#include <QtCore/qmetaobject.h> -#include <QtGui/qguiapplication.h> -#include <QtGui/qscreen.h> - -#if defined(Q_OS_LINUX) -# include "linux/qdisplayinfo_linux_p.h" -//#elif defined(Q_OS_WIN) -//# include "qdisplayinfo_win_p.h" -#elif defined(Q_OS_MAC) -# include "mac/qdisplayinfo_mac_p.h" -#else -QT_BEGIN_NAMESPACE -class QDisplayInfoPrivate -{ -public: - QDisplayInfoPrivate(QDisplayInfo *) {} - - int brightness(int) { return -1; } - int contrast(int) const { return -1; } - QDisplayInfo::BacklightState backlightState(int) { return QDisplayInfo::BacklightUnknown; } -}; -QT_END_NAMESPACE -#endif - -QT_BEGIN_NAMESPACE - -/*! - \class QDisplayInfo - \inmodule QtSystemInfo - \brief The QDisplayInfo class provides various information about the display. - \ingroup systeminfo -*/ - -/*! - \enum QDisplayInfo::BacklightState - This enum describes the state of the backlight. - - \value BacklightUnknown The state of the backlight is unknown. - \value BacklightOff Backlight is turned off. - \value BacklightDimmed Backlight has been dimmed. - \value BacklightOn Backlight is on. -*/ - -/*! - \fn void QDisplayInfo::backlightStateChanged(int screen, QDisplayInfo::BacklightState state) - - This signal is emitted when the backlight state for \a screen has changed to \a state. -*/ - -/*! - Constructs a QDisplayInfo object with the given \a parent. -*/ -QDisplayInfo::QDisplayInfo(QObject *parent) - : QObject(parent) - , d_ptr(new QDisplayInfoPrivate(this)) -{ -} - -/*! - Destroys the object -*/ -QDisplayInfo::~QDisplayInfo() -{ - delete d_ptr; -} - -/*! - Returns the display brightness of the given \a screen, in 0 - 100 scale. In case of error or - the information is not available, -1 is returned. -*/ -int QDisplayInfo::brightness(int screen) const -{ - if (screen < 0 || screen >= QGuiApplication::screens().size()) - return -1; - return d_ptr->brightness(screen); -} - -/*! - Returns the contrast of the given \a screen, in 0 - 100 scale. -1 is returned if not available - or on error. -*/ -int QDisplayInfo::contrast(int screen) const -{ - if (screen < 0 || screen >= QGuiApplication::screens().size()) - return -1; - return d_ptr->contrast(screen); -} - -/*! - Returns the backlight state of the given \a screen. -*/ -QDisplayInfo::BacklightState QDisplayInfo::backlightState(int screen) const -{ - if (screen < 0 || screen >= QGuiApplication::screens().size()) - return QDisplayInfo::BacklightUnknown; - return d_ptr->backlightState(screen); -} - -// the following are merely wrapper of the QScreen API, and will be remove - -static inline const QScreen *screenAt(int number) -{ - const QList<QScreen *> screens = QGuiApplication::screens(); - if (number >= 0 && number < screens.size()) - return screens.at(number); - return 0; -} - -/*! - Returns the color depth of the given \a screen, in bits per pixel. -1 is returned if not - available or on error. - - Please use QScreen::depth() instead. -*/ -int QDisplayInfo::colorDepth(int screen) const -{ - if (const QScreen *qScreen = screenAt(screen)) - return qScreen->depth(); - return -1; -} - -/*! - Returns the horizontal resolution of the given \a screen in terms of the number of dots per inch. - -1 is returned if not available or on error. - - Please use QScreen::logicalDotsPerInchX() instead. -*/ -int QDisplayInfo::dpiX(int screen) const -{ - if (const QScreen *qScreen = screenAt(screen)) - return qRound(qScreen->logicalDotsPerInchX()); - return -1; -} - -/*! - Returns the vertical resolution of the given \a screen in terms of the number of dots per inch. - -1 is returned if not available or on error. - - Please use QScreen::logicalDotsPerInchY() instead. -*/ -int QDisplayInfo::dpiY(int screen) const -{ - if (const QScreen *qScreen = screenAt(screen)) - return qRound(qScreen->logicalDotsPerInchY()); - return -1; -} - -/*! - Returns the physical height of the \a screen in millimeters. -1 is returned if not available - or on error. - - Please use QScreen::physicalSize().height() instead. -*/ -int QDisplayInfo::physicalHeight(int screen) const -{ - if (const QScreen *qScreen = screenAt(screen)) - return qRound(qScreen->physicalSize().height()); - return -1; -} - -/*! - Returns the physical width of \a screen in millimeters. -1 is returned if not available or - on error. - - Please use QScreen::physicalSize().width() instead. -*/ -int QDisplayInfo::physicalWidth(int screen) const -{ - if (const QScreen *qScreen = screenAt(screen)) - return qRound(qScreen->physicalSize().width()); - return -1; -} - -QT_END_NAMESPACE diff --git a/src/systeminfo/qdisplayinfo.h b/src/systeminfo/qdisplayinfo.h deleted file mode 100644 index b59dd81a..00000000 --- a/src/systeminfo/qdisplayinfo.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSystems module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDISPLAYINFO_H -#define QDISPLAYINFO_H - -#include <QtSystemInfo/qsysteminfoglobal.h> -#include <QtCore/qobject.h> - -QT_BEGIN_NAMESPACE - -class QDisplayInfoPrivate; - -class Q_SYSTEMINFO_EXPORT QDisplayInfo : public QObject -{ - Q_OBJECT - - Q_ENUMS(BacklightState) - -public: - enum BacklightState { - BacklightUnknown = 0, - BacklightOff, - BacklightDimmed, - BacklightOn - }; - - QDisplayInfo(QObject *parent = 0); - virtual ~QDisplayInfo(); - - int brightness(int screen) const; - int contrast(int screen) const; - BacklightState backlightState(int screen) const; - - int colorDepth(int screen) const; - int dpiX(int screen) const; - int dpiY(int screen) const; - int physicalHeight(int screen) const; - int physicalWidth(int screen) const; - -Q_SIGNALS: - void backlightStateChanged(int screen, QDisplayInfo::BacklightState state); - -private: - Q_DISABLE_COPY(QDisplayInfo) - QDisplayInfoPrivate * const d_ptr; - Q_DECLARE_PRIVATE(QDisplayInfo) -}; - -QT_END_NAMESPACE - -#endif // QDISPLAYINFO_H diff --git a/src/systeminfo/simulator/qsysteminfodata_simulator.cpp b/src/systeminfo/simulator/qsysteminfodata_simulator.cpp index fe5c880f..7cebd4dd 100644 --- a/src/systeminfo/simulator/qsysteminfodata_simulator.cpp +++ b/src/systeminfo/simulator/qsysteminfodata_simulator.cpp @@ -54,7 +54,6 @@ void qt_registerSystemInfoTypes() qRegisterMetaTypeStreamOperators<QNetworkInfoData::BluetoothInfo>("QNetworkInfoData::BluetoothInfo"); qRegisterMetaTypeStreamOperators<QDeviceInfoData>("QDeviceInfoData"); qRegisterMetaTypeStreamOperators<QBatteryInfoData>("QBatteryInfoData"); - qRegisterMetaTypeStreamOperators<QDisplayInfoData>("QDisplayInfoData"); qRegisterMetaTypeStreamOperators<QStorageInfoData>("QStorageInfoData"); qRegisterMetaTypeStreamOperators<QStorageInfoData::DriveInfo>("QStorageInfoData::DriveInfo"); qRegisterMetaTypeStreamOperators<QScreenSaverData>("QScreenSaverData"); @@ -260,28 +259,6 @@ QDataStream &operator>>(QDataStream &in, QBatteryInfoData &s) return in; } -QDataStream &operator<<(QDataStream &out, const QDisplayInfoData &s) -{ - out << static_cast<qint32>(s.brightness) << static_cast<qint32>(s.contrast); - out << static_cast<qint32>(s.backlightStatus); - - return out; -} - -QDataStream &operator>>(QDataStream &in, QDisplayInfoData &s) -{ - qint32 brightness, contrast; - in >> brightness >> contrast; - - s.brightness = brightness; - s.contrast = contrast; - qint32 backlightStatus; - in >> backlightStatus; - s.backlightStatus = static_cast<QDisplayInfo::BacklightState>(backlightStatus); - - return in; -} - QDataStream &operator<<(QDataStream &out, const QStorageInfoData &s) { out << s.drives; diff --git a/src/systeminfo/simulator/qsysteminfodata_simulator_p.h b/src/systeminfo/simulator/qsysteminfodata_simulator_p.h index 9a59ffca..f624de1e 100644 --- a/src/systeminfo/simulator/qsysteminfodata_simulator_p.h +++ b/src/systeminfo/simulator/qsysteminfodata_simulator_p.h @@ -57,7 +57,6 @@ #include <qnetworkinfo.h> #include <qdeviceinfo.h> #include <qbatteryinfo.h> -#include <qdisplayinfo.h> #include <qstorageinfo.h> #include <qscreensaver.h> #include <qdeviceprofile.h> @@ -145,13 +144,6 @@ struct QDeviceInfoData QMap<QDeviceInfo::Version, QString> versionList; }; -struct QDisplayInfoData -{ - int brightness; - int contrast; - QDisplayInfo::BacklightState backlightStatus; -}; - struct QStorageInfoData { struct DriveInfo @@ -180,7 +172,6 @@ struct QDeviceProfileData Q_DECLARE_METATYPE(QNetworkInfoData) Q_DECLARE_METATYPE(QDeviceInfoData) Q_DECLARE_METATYPE(QBatteryInfoData) -Q_DECLARE_METATYPE(QDisplayInfoData) Q_DECLARE_METATYPE(QStorageInfoData) Q_DECLARE_METATYPE(QScreenSaverData) Q_DECLARE_METATYPE(QDeviceProfileData) @@ -207,8 +198,6 @@ QDataStream &operator<<(QDataStream &out, const QDeviceInfo::Version s); QDataStream &operator>>(QDataStream &in, QDeviceInfo::Version &s); QDataStream &operator<<(QDataStream &out, const QBatteryInfoData &s); QDataStream &operator>>(QDataStream &in, QBatteryInfoData &s); -QDataStream &operator<<(QDataStream &out, const QDisplayInfoData &s); -QDataStream &operator>>(QDataStream &in, QDisplayInfoData &s); QDataStream &operator<<(QDataStream &out, const QStorageInfoData &s); QDataStream &operator>>(QDataStream &in, QStorageInfoData &s); QDataStream &operator<<(QDataStream &out, const QStorageInfoData::DriveInfo &s); diff --git a/src/systeminfo/systeminfo.pro b/src/systeminfo/systeminfo.pro index a3031fee..29da3049 100644 --- a/src/systeminfo/systeminfo.pro +++ b/src/systeminfo/systeminfo.pro @@ -17,12 +17,6 @@ SOURCES += qdeviceinfo.cpp \ qnetworkinfo.cpp \ qdeviceprofile.cpp -qtHaveModule(gui) { - QT += gui - PUBLIC_HEADERS += qdisplayinfo.h - SOURCES += qdisplayinfo.cpp -} - win32: !simulator: { contains(CONFIG, release) { CONFIG -= console @@ -68,14 +62,12 @@ win32: !simulator: { linux-*: !simulator: { PRIVATE_HEADERS += linux/qdeviceinfo_linux_p.h \ - linux/qdisplayinfo_linux_p.h \ linux/qstorageinfo_linux_p.h \ linux/qbatteryinfo_linux_p.h \ linux/qnetworkinfo_linux_p.h \ linux/qscreensaver_linux_p.h SOURCES += linux/qdeviceinfo_linux.cpp \ - linux/qdisplayinfo_linux.cpp \ linux/qstorageinfo_linux.cpp \ linux/qbatteryinfo_linux.cpp \ linux/qnetworkinfo_linux.cpp \ @@ -129,14 +121,12 @@ macx:!simulator { QT += core-private OBJECTIVE_SOURCES += mac/qbatteryinfo_mac.mm \ mac/qdeviceinfo_mac.mm \ - mac/qdisplayinfo_mac.mm \ mac/qnetworkinfo_mac.mm \ mac/qscreensaver_mac.mm \ mac/qstorageinfo_mac.mm PRIVATE_HEADERS += mac/qbatteryinfo_mac_p.h \ mac/qdeviceinfo_mac_p.h \ - mac/qdisplayinfo_mac_p.h \ mac/qnetworkinfo_mac_p.h \ mac/qscreensaver_mac_p.h \ mac/qstorageinfo_mac_p.h @@ -171,12 +161,12 @@ simulator { linux-*: { - PRIVATE_HEADERS += linux/qdisplayinfo_linux_p.h \ + PRIVATE_HEADERS += \ linux/qscreensaver_linux_p.h \ linux/qdeviceprofile_linux_p.h \ linux/qstorageinfo_linux_p.h - SOURCES += linux/qdisplayinfo_linux.cpp \ + SOURCES += \ linux/qscreensaver_linux.cpp \ linux/qstorageinfo_linux.cpp diff --git a/tests/auto/cmake/test_modules/main.cpp b/tests/auto/cmake/test_modules/main.cpp index 408366ae..1ae370eb 100644 --- a/tests/auto/cmake/test_modules/main.cpp +++ b/tests/auto/cmake/test_modules/main.cpp @@ -41,7 +41,7 @@ #include <QValueSpaceSubscriber> #include <QServiceInterfaceDescriptor> -#include <QDisplayInfo> +#include <QStorageInfo> int main(int argc, char **argv) { @@ -49,7 +49,7 @@ int main(int argc, char **argv) QServiceInterfaceDescriptor serviceInterfaceDescriptor; - QDisplayInfo displayInfo; + QStorageInfo storageInfo; return 0; } diff --git a/tests/auto/systeminfo/qdisplayinfo/qdisplayinfo.pro b/tests/auto/systeminfo/qdisplayinfo/qdisplayinfo.pro deleted file mode 100644 index 2097b874..00000000 --- a/tests/auto/systeminfo/qdisplayinfo/qdisplayinfo.pro +++ /dev/null @@ -1,6 +0,0 @@ -include(../auto.pri) - -QT += systeminfo - -SOURCES += tst_qdisplayinfo.cpp -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/systeminfo/qdisplayinfo/tst_qdisplayinfo.cpp b/tests/auto/systeminfo/qdisplayinfo/tst_qdisplayinfo.cpp deleted file mode 100644 index 9d7ed877..00000000 --- a/tests/auto/systeminfo/qdisplayinfo/tst_qdisplayinfo.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSystems module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui/qguiapplication.h> -#include <QtTest/QtTest> - -#include "qdisplayinfo.h" - -QT_USE_NAMESPACE - -class tst_QDisplayInfo : public QObject -{ - Q_OBJECT - -private slots: - void tst_colorDepth(); - void tst_contrast(); - void tst_brightness(); - void tst_dpiX(); - void tst_dpiY(); - void tst_physicalHeight(); - void tst_physicalWidth(); -}; - -void tst_QDisplayInfo::tst_brightness() -{ - QDisplayInfo displayInfo; - - QVERIFY(-1 == displayInfo.brightness(-1)); - QVERIFY(-1 == displayInfo.brightness(QGuiApplication::screens().size())); -} - -void tst_QDisplayInfo::tst_contrast() -{ - QDisplayInfo displayInfo; - - QVERIFY(-1 == displayInfo.contrast(-1)); - QVERIFY(-1 == displayInfo.contrast(QGuiApplication::screens().size())); -} - -void tst_QDisplayInfo::tst_colorDepth() -{ - QDisplayInfo displayInfo; - - QVERIFY(-1 == displayInfo.colorDepth(-1)); - QVERIFY(-1 == displayInfo.colorDepth(QGuiApplication::screens().size())); -} - -void tst_QDisplayInfo::tst_dpiX() -{ - QDisplayInfo displayInfo; - - QVERIFY(-1 == displayInfo.dpiX(-1)); - QVERIFY(-1 == displayInfo.dpiX(QGuiApplication::screens().size())); -} - -void tst_QDisplayInfo::tst_dpiY() -{ - QDisplayInfo displayInfo; - - QVERIFY(-1 == displayInfo.dpiY(-1)); - QVERIFY(-1 == displayInfo.dpiY(QGuiApplication::screens().size())); -} - -void tst_QDisplayInfo::tst_physicalHeight() -{ - QDisplayInfo displayInfo; - - QVERIFY(-1 == displayInfo.physicalHeight(-1)); - QVERIFY(-1 == displayInfo.physicalHeight(QGuiApplication::screens().size())); -} - -void tst_QDisplayInfo::tst_physicalWidth() -{ - QDisplayInfo displayInfo; - - QVERIFY(-1 == displayInfo.physicalWidth(-1)); - QVERIFY(-1 == displayInfo.physicalWidth(QGuiApplication::screens().size())); -} - -QTEST_MAIN(tst_QDisplayInfo) -#include "tst_qdisplayinfo.moc" diff --git a/tests/auto/systeminfo/systeminfo.pro b/tests/auto/systeminfo/systeminfo.pro index 7fb176ca..6c0b5102 100644 --- a/tests/auto/systeminfo/systeminfo.pro +++ b/tests/auto/systeminfo/systeminfo.pro @@ -2,7 +2,6 @@ TEMPLATE = subdirs SUBDIRS = \ qdeviceinfo \ -# qdisplayinfo \ qstorageinfo \ qscreensaver \ qbatteryinfo |