Port away from deprecated QString::sprintf
Test Plan: Compiles. Reviewers: #kwin, apol Reviewed By: apol Subscribers: apol, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D24045
This commit is contained in:
parent
5ad3c0ee13
commit
2ad37c449f
3 changed files with 17 additions and 7 deletions
|
@ -40,6 +40,13 @@ GeometryTip::~GeometryTip()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString numberWithSign(int n)
|
||||||
|
{
|
||||||
|
const QLocale locale;
|
||||||
|
const QChar sign = n >= 0 ? locale.positiveSign() : locale.negativeSign();
|
||||||
|
return sign + QString::number(std::abs(n));
|
||||||
|
}
|
||||||
|
|
||||||
void GeometryTip::setGeometry(const QRect& geom)
|
void GeometryTip::setGeometry(const QRect& geom)
|
||||||
{
|
{
|
||||||
int w = geom.width();
|
int w = geom.width();
|
||||||
|
@ -53,9 +60,11 @@ void GeometryTip::setGeometry(const QRect& geom)
|
||||||
}
|
}
|
||||||
|
|
||||||
h = qMax(h, 0); // in case of isShade() and PBaseSize
|
h = qMax(h, 0); // in case of isShade() and PBaseSize
|
||||||
QString pos;
|
const QString pos = QStringLiteral("%1,%2<br>(<b>%3 x %4</b>)")
|
||||||
pos.sprintf("%+d,%+d<br>(<b>%d x %d</b>)",
|
.arg(numberWithSign(geom.x()))
|
||||||
geom.x(), geom.y(), w, h);
|
.arg(numberWithSign(geom.y()))
|
||||||
|
.arg(w)
|
||||||
|
.arg(h);
|
||||||
setText(pos);
|
setText(pos);
|
||||||
adjustSize();
|
adjustSize();
|
||||||
move(geom.x() + ((geom.width() - width()) / 2),
|
move(geom.x() + ((geom.width() - width()) / 2),
|
||||||
|
|
|
@ -363,7 +363,6 @@ KWIN_EXPORT int kdemain(int argc, char * argv[])
|
||||||
if ((pos = display_name.lastIndexOf('.')) != -1)
|
if ((pos = display_name.lastIndexOf('.')) != -1)
|
||||||
display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s"
|
display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s"
|
||||||
|
|
||||||
QString envir;
|
|
||||||
for (int i = 0; i < number_of_screens; i++) {
|
for (int i = 0; i < number_of_screens; i++) {
|
||||||
// If execution doesn't pass by here, then kwin
|
// If execution doesn't pass by here, then kwin
|
||||||
// acts exactly as previously
|
// acts exactly as previously
|
||||||
|
@ -382,7 +381,9 @@ KWIN_EXPORT int kdemain(int argc, char * argv[])
|
||||||
}
|
}
|
||||||
// In the next statement, display_name shouldn't contain a screen
|
// In the next statement, display_name shouldn't contain a screen
|
||||||
// number. If it had it, it was removed at the "pos" check
|
// number. If it had it, it was removed at the "pos" check
|
||||||
envir.sprintf("DISPLAY=%s.%d", display_name.data(), KWin::Application::x11ScreenNumber());
|
const QString envir = QStringLiteral("DISPLAY=%1.%2")
|
||||||
|
.arg(display_name.data())
|
||||||
|
.arg(KWin::Application::x11ScreenNumber());
|
||||||
|
|
||||||
if (putenv(strdup(envir.toLatin1().constData()))) {
|
if (putenv(strdup(envir.toLatin1().constData()))) {
|
||||||
fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]);
|
fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]);
|
||||||
|
|
|
@ -698,7 +698,7 @@ void VirtualDesktopManager::load()
|
||||||
if (screen_number == 0) {
|
if (screen_number == 0) {
|
||||||
groupname = QStringLiteral("Desktops");
|
groupname = QStringLiteral("Desktops");
|
||||||
} else {
|
} else {
|
||||||
groupname.sprintf("Desktops-screen-%d", screen_number);
|
groupname = QStringLiteral("Desktops-screen-%1").arg(screen_number);
|
||||||
}
|
}
|
||||||
KConfigGroup group(m_config, groupname);
|
KConfigGroup group(m_config, groupname);
|
||||||
const int n = group.readEntry("Number", 1);
|
const int n = group.readEntry("Number", 1);
|
||||||
|
@ -752,7 +752,7 @@ void VirtualDesktopManager::save()
|
||||||
if (screen_number == 0) {
|
if (screen_number == 0) {
|
||||||
groupname = QStringLiteral("Desktops");
|
groupname = QStringLiteral("Desktops");
|
||||||
} else {
|
} else {
|
||||||
groupname.sprintf("Desktops-screen-%d", screen_number);
|
groupname = QStringLiteral("Desktops-screen-%1").arg(screen_number);
|
||||||
}
|
}
|
||||||
KConfigGroup group(m_config, groupname);
|
KConfigGroup group(m_config, groupname);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue