Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit 58af796

Browse files
authored
Merge pull request #231 from redhatrises/remove_qt_escape
Remove deprecated or obsolete QT4 code
2 parents b3f41b4 + 0ef261c commit 58af796

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

src/APIHelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ QString oscapItemGetReadableTitle(struct xccdf_item* item, struct xccdf_policy*
4444
oscap_text_iterator_free(title_it);
4545
if (!unresolved)
4646
return "";
47-
char* resolved = xccdf_policy_substitute(Qt::escape(QString::fromUtf8(unresolved)).toUtf8().constData(), policy);
47+
char* resolved = xccdf_policy_substitute(QString::fromUtf8(unresolved).toHtmlEscaped().toUtf8().constData(), policy);
4848
free(unresolved);
4949
const QString ret = QString::fromUtf8(resolved);
5050
free(resolved);

src/DiagnosticsDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void DiagnosticsDialog::pushMessage(MessageSeverity severity, const QString& ful
142142
QString outputMessage = fullMessage;
143143
if (format & MF_XML)
144144
{
145-
outputMessage = Qt::escape(outputMessage);
145+
outputMessage = outputMessage.toHtmlEscaped();
146146
}
147147

148148
if (format & MF_PREFORMATTED)

src/MainWindow.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <QFileSystemWatcher>
4444
#include <QDesktopWidget>
4545
#include <QMenu>
46+
#include <QScreen>
4647

4748
#include <cassert>
4849
#include <set>
@@ -257,8 +258,22 @@ MainWindow::MainWindow(QWidget* parent):
257258

258259
closeFile();
259260

260-
// start centered
261-
move(QApplication::desktop()->screen()->rect().center() - rect().center());
261+
/* start centered
262+
263+
As of https://codereview.qt.nokia.com/c/qt/qtbase/+/268417,
264+
QWidget *QDesktopWidget::screen(int) or Application::desktop()->screen() has been
265+
deprecated with no replacement. A replacement might be provided in QT6 which
266+
the following 4 lines of code should be re-evaluated if a replacement is provided.
267+
268+
The solution of the following 4 lines of code was indirectly provided by
269+
Riccardo Fagiolo in "window_main.cpp" at
270+
https://stackoverflow.com/questions/46300065/dynamically-resizing-two-qlabel-implementations
271+
*/
272+
QSize size = QGuiApplication::screens().at(0)->availableSize();
273+
int x = size.width() / 2 - width() / 2;
274+
int y = size.height() / 2 - height() / 2;
275+
move(x, y);
276+
// End stackoverflow provided code by Riccardo Fagiolo
262277

263278
QAction* genBashRemediation = new QAction("&bash", this);
264279
QObject::connect(
@@ -909,7 +924,7 @@ void MainWindow::refreshProfiles()
909924
mUI.profileComboBox->addItem(profileTitle, QVariant(it->first));
910925
}
911926

912-
if (previouslySelected != QString::Null())
927+
if (!previouslySelected.isNull())
913928
{
914929
const int indexCandidate = mUI.profileComboBox->findData(QVariant(previouslySelected));
915930
if (indexCandidate != -1)

src/OscapScannerBase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ bool OscapScannerBase::tryToReadStdOutChar(QProcess& process)
333333
{
334334
// When fetching remote content, openscap will inform scap-workbench about
335335
// resources being downloaded. Keep any colon found in URL of file being downloaded.
336-
mReadBuffer.append(QChar::fromAscii(readChar));
336+
mReadBuffer.append(QChar::fromLatin1(readChar));
337337
}
338338
break;
339339

@@ -405,7 +405,7 @@ bool OscapScannerBase::tryToReadStdOutChar(QProcess& process)
405405
{
406406
// we know for sure that buffer[0] can only contain ASCII characters
407407
// (IDs and special keywords regarding rule status)
408-
mReadBuffer.append(QChar::fromAscii(readChar));
408+
mReadBuffer.append(QChar::fromLatin1(readChar));
409409
}
410410

411411
return true;

src/TailoringWindow.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <QTimer>
3737
#include <QDateTime>
3838
#include <QStack>
39+
#include <QScreen>
3940

4041
#include <algorithm>
4142
#include <cassert>
@@ -162,7 +163,7 @@ TailoringWindow::TailoringWindow(struct xccdf_policy* policy, struct xccdf_bench
162163
createTreeItem(mBenchmarkItem, xccdf_benchmark_to_item(mBenchmark));
163164
synchronizeTreeItem();
164165

165-
mUI.itemsTree->header()->setResizeMode(0, QHeaderView::ResizeToContents);
166+
mUI.itemsTree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
166167
mUI.itemsTree->header()->setStretchLastSection(false);
167168

168169
deserializeCollapsedItems();
@@ -230,8 +231,22 @@ TailoringWindow::TailoringWindow(struct xccdf_policy* policy, struct xccdf_bench
230231
this, SLOT(searchNext())
231232
);
232233

233-
// start centered
234-
move(QApplication::desktop()->screen()->rect().center() - rect().center());
234+
/* start centered
235+
236+
As of https://codereview.qt.nokia.com/c/qt/qtbase/+/268417,
237+
QWidget *QDesktopWidget::screen(int) or Application::desktop()->screen() has been
238+
deprecated with no replacement. A replacement might be provided in QT6 which
239+
the following 4 lines of code should be re-evaluated if a replacement is provided.
240+
241+
The solution of the following 4 lines of code was indirectly provided by
242+
Riccardo Fagiolo in "window_main.cpp" at
243+
https://stackoverflow.com/questions/46300065/dynamically-resizing-two-qlabel-implementations
244+
*/
245+
QSize size = QGuiApplication::screens().at(0)->availableSize();
246+
int x = size.width() / 2 - width() / 2;
247+
int y = size.height() / 2 - height() / 2;
248+
move(x, y);
249+
// End stackoverflow provided code by Riccardo Fagiolo
235250
show();
236251
}
237252

0 commit comments

Comments
 (0)