Don't use deprecated QDesktopWidget
Summary: QApplication::desktop() is deprecated. It is advised to use QGuiApplication::screens() instead. Reviewers: #kwin, apol Reviewed By: apol Subscribers: apol, davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D22379
This commit is contained in:
parent
28a4337ad5
commit
09f2d95a9c
4 changed files with 33 additions and 6 deletions
|
@ -119,7 +119,7 @@ KFocusConfig::KFocusConfig(bool _standAlone, KConfig *_config, QWidget * parent)
|
||||||
|
|
||||||
void KFocusConfig::updateMultiScreen()
|
void KFocusConfig::updateMultiScreen()
|
||||||
{
|
{
|
||||||
m_ui->multiscreenBox->setVisible(QApplication::desktop()->screenCount() > 1);
|
m_ui->multiscreenBox->setVisible(QApplication::screens().count() > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,20 +26,45 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsSceneEvent>
|
#include <QGraphicsSceneEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static QWindow *windowFromWidget(const QWidget *widget)
|
||||||
|
{
|
||||||
|
QWindow *windowHandle = widget->windowHandle();
|
||||||
|
if (windowHandle) {
|
||||||
|
return windowHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QWidget *nativeParent = widget->nativeParentWidget();
|
||||||
|
if (nativeParent) {
|
||||||
|
return nativeParent->windowHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QScreen *screenFromWidget(const QWidget *widget)
|
||||||
|
{
|
||||||
|
const QWindow *windowHandle = windowFromWidget(widget);
|
||||||
|
if (windowHandle && windowHandle->screen()) {
|
||||||
|
return windowHandle->screen();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QGuiApplication::primaryScreen();
|
||||||
|
}
|
||||||
|
|
||||||
Monitor::Monitor(QWidget* parent)
|
Monitor::Monitor(QWidget* parent)
|
||||||
: ScreenPreviewWidget(parent)
|
: ScreenPreviewWidget(parent)
|
||||||
{
|
{
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
QRect avail = screenFromWidget(this)->geometry();
|
||||||
QRect avail = desktop->availableGeometry(desktop->screenNumber(this));
|
|
||||||
setRatio((qreal)avail.width() / (qreal)avail.height());
|
setRatio((qreal)avail.width() / (qreal)avail.height());
|
||||||
for (int i = 0;
|
for (int i = 0;
|
||||||
i < 8;
|
i < 8;
|
||||||
|
|
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
#include <QScreen>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KDesktopFile>
|
#include <KDesktopFile>
|
||||||
|
@ -243,7 +244,8 @@ void SwitcherItem::setCurrentIndex(int index)
|
||||||
|
|
||||||
QRect SwitcherItem::screenGeometry() const
|
QRect SwitcherItem::screenGeometry() const
|
||||||
{
|
{
|
||||||
return qApp->desktop()->screenGeometry(qApp->desktop()->primaryScreen());
|
const QScreen *primaryScreen = qApp->primaryScreen();
|
||||||
|
return primaryScreen->geometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwitcherItem::incrementIndex()
|
void SwitcherItem::incrementIndex()
|
||||||
|
|
|
@ -145,7 +145,7 @@ KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args)
|
||||||
connect(ui[i]->otherActivities, SIGNAL(clicked(bool)), SLOT(changed()));
|
connect(ui[i]->otherActivities, SIGNAL(clicked(bool)), SLOT(changed()));
|
||||||
|
|
||||||
connect(ui[i]->filterScreens, SIGNAL(clicked(bool)), SLOT(changed()));
|
connect(ui[i]->filterScreens, SIGNAL(clicked(bool)), SLOT(changed()));
|
||||||
if (QApplication::desktop()->screenCount() < 2) {
|
if (QApplication::screens().count() < 2) {
|
||||||
ui[i]->filterScreens->hide();
|
ui[i]->filterScreens->hide();
|
||||||
ui[i]->screenFilter->hide();
|
ui[i]->screenFilter->hide();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue