Commit b482efe7 authored by Jonathan Marten's avatar Jonathan Marten
Browse files

Port deprecated QList::toSet(), QDesktopWidget::screenGeometry()

apps/kmix.cpp: In member function 'void KMixWindow::loadBaseConfig()':
apps/kmix.cpp:498: warning: 'QSet<T> QList<T>::toSet() const [with T = QString]' is deprecated, use 'QSet<T>(list.begin(), list.end()) instead.'
gui/dialogstatesaver.cpp:104: warning: 'const QRect QDesktopWidget::screenGeometry(int) const' is deprecated, use 'QGuiApplication::screens()'
/usr/include/qt5/QtWidgets/qdesktopwidget.h:79: note: declared here
gui/dialogstatesaver.cpp: In static member function 'static void DialogStateSaver::saveWindowState(QWidget*, KConfigGroup&)':
gui/dialogstatesaver.cpp:142: warning: 'const QRect QDesktopWidget::screenGeometry(int) const' is deprecated, use 'QGuiApplication::screens()'
/usr/include/qt5/QtWidgets/qdesktopwidget.h:79: note: declared here
parent 068aec9d
......@@ -491,11 +491,9 @@ void KMixWindow::loadBaseConfig()
{
KConfigGroup config(KSharedConfig::openConfig(), "Global");
GlobalConfigData& gcd = GlobalConfig::instance().data;
QList<QString> preferredMixersInSoundMenu;
preferredMixersInSoundMenu = config.readEntry("Soundmenu.Mixers", preferredMixersInSoundMenu);
GlobalConfig::instance().setMixersForSoundmenu(preferredMixersInSoundMenu.toSet());
const QStringList preferredMixers = config.readEntry("Soundmenu.Mixers", QStringList());
const QSet<QString> preferredMixersSet(preferredMixers.begin(), preferredMixers.end());
GlobalConfig::instance().setMixersForSoundmenu(preferredMixersSet);
m_startVisible = config.readEntry("Visible", false);
m_multiDriverMode = config.readEntry("MultiDriver", false);
......@@ -523,14 +521,11 @@ void KMixWindow::loadBaseConfig()
// The following log is very helpful in bug reports. Please keep it.
m_backendFilter = config.readEntry<>("Backends", QList<QString>());
qCDebug(KMIX_LOG)
<< "Backends: " << m_backendFilter;
qCDebug(KMIX_LOG) << "Backends: " << m_backendFilter;
// show/hide menu bar
bool showMenubar = config.readEntry("Menubar", true);
if (_actionShowMenubar)
_actionShowMenubar->setChecked(showMenubar);
if (_actionShowMenubar!=nullptr) _actionShowMenubar->setChecked(showMenubar);
}
/**
......
......@@ -26,6 +26,8 @@
#include <qapplication.h>
#include <qabstractbutton.h>
#include <qdebug.h>
#include <qscreen.h>
#include <qwindow.h>
#include <kconfiggroup.h>
#include <ksharedconfig.h>
......@@ -90,25 +92,27 @@ void DialogStateSaver::restoreConfig(QDialog *dialog, const KConfigGroup &grp)
}
void DialogStateSaver::restoreWindowState(QWidget *window)
void DialogStateSaver::restoreWindowState(QWidget *widget)
{
const KConfigGroup grp = configGroupFor(window);
restoreWindowState(window, grp);
const KConfigGroup grp = configGroupFor(widget);
restoreWindowState(widget, grp);
}
void DialogStateSaver::restoreWindowState(QWidget *window, const KConfigGroup &grp)
void DialogStateSaver::restoreWindowState(QWidget *widget, const KConfigGroup &grp)
{
// from KDE4 KDialog::restoreDialogSize()
int scnum = QApplication::desktop()->screenNumber(window->parentWidget());
QRect desk = QApplication::desktop()->screenGeometry(scnum);
int width = window->sizeHint().width();
int height = window->sizeHint().height();
// Ensure that the widget's window() - that is, either the widget itself
// or its nearest ancestor widget that is or could be top level - is a
// native window, so that windowHandle() below will return a valid QWindow.
const WId wid = widget->window()->winId();
const QRect desk = widget->window()->windowHandle()->screen()->geometry();
const QSize sizeDefault = widget->sizeHint();
// originally from KDE4 KDialog::restoreDialogSize()
qDebug() << "from" << grp.name() << "in" << grp.config()->name();
width = grp.readEntry(QString::fromLatin1("Width %1").arg(desk.width()), width);
height = grp.readEntry(QString::fromLatin1("Height %1").arg(desk.height()), height);
window->resize(width, height);
const int width = grp.readEntry(QString::fromLatin1("Width %1").arg(desk.width()), sizeDefault.width());
const int height = grp.readEntry(QString::fromLatin1("Height %1").arg(desk.height()), sizeDefault.height());
widget->resize(width, height);
}
......@@ -128,20 +132,20 @@ void DialogStateSaver::saveConfig(QDialog *dialog, KConfigGroup &grp) const
}
void DialogStateSaver::saveWindowState(QWidget *window)
void DialogStateSaver::saveWindowState(QWidget *widget)
{
KConfigGroup grp = configGroupFor(window);
saveWindowState(window, grp);
KConfigGroup grp = configGroupFor(widget);
saveWindowState(widget, grp);
}
void DialogStateSaver::saveWindowState(QWidget *window, KConfigGroup &grp)
void DialogStateSaver::saveWindowState(QWidget *widget, KConfigGroup &grp)
{
// from KDE4 KDialog::saveDialogSize()
const int scnum = QApplication::desktop()->screenNumber(window->parentWidget());
QRect desk = QApplication::desktop()->screenGeometry(scnum);
const QSize sizeToSave = window->size();
const WId wid = widget->window()->winId();
const QRect desk = widget->window()->windowHandle()->screen()->geometry();
const QSize sizeToSave = widget->size();
// originally from KDE4 KDialog::saveDialogSize()
qDebug() << "to" << grp.name() << "in" << grp.config()->name();
grp.writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), sizeToSave.width());
grp.writeEntry( QString::fromLatin1("Height %1").arg(desk.height()), sizeToSave.height());
......
......@@ -102,9 +102,9 @@ public:
* saving the state of any window. The state is saved to a group
* named as appropriate for the window.
*
* @param window window to save the state of
* @param widget window to save the state of
**/
static void saveWindowState(QWidget *window);
static void saveWindowState(QWidget *widget);
/**
* Save the state of a window.
......@@ -113,10 +113,10 @@ public:
* saving the state of any window. The state is saved to the
* specified group.
*
* @param window window to save the state of
* @param widget window to save the state of
* @param grp group to save the configuration to
**/
static void saveWindowState(QWidget *window, KConfigGroup &grp);
static void saveWindowState(QWidget *widget, KConfigGroup &grp);
/**
* Restore the state of a window.
......@@ -125,9 +125,9 @@ public:
* restoring the state of any window. The state is restored from
* a group named as appropriate for the window.
*
* @param window window to restore the state of
* @param widget window to restore the state of
**/
static void restoreWindowState(QWidget *window);
static void restoreWindowState(QWidget *widget);
/**
* Restore the state of a window.
......@@ -136,10 +136,10 @@ public:
* restoring the state of any window. The state is restored from
* the specified group.
*
* @param window window to restore the state of
* @param widget window to restore the state of
* @param grp group to restore the configuration from
**/
static void restoreWindowState(QWidget *window, const KConfigGroup &grp);
static void restoreWindowState(QWidget *widget, const KConfigGroup &grp);
protected:
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment