From 89984a8a61a7e33a4ff62db98083a0e3c0c7b4b1 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 5 Jul 2019 15:35:34 +0200 Subject: Fix the systray example to only show an icon when requested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "None" and "Custom icon" cases where using the same value for icon type, which resulted in both options showing the application icon. Use -1 to indicate the custom option, and treat all other options the same. Task-number: QTBUG-76916 Change-Id: Ib715f5d328175bd6e221b3f507087954fa542838 Reviewed-by: Tor Arne Vestbø --- examples/widgets/desktop/systray/window.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp index 05944c92a7..28287dc02b 100644 --- a/examples/widgets/desktop/systray/window.cpp +++ b/examples/widgets/desktop/systray/window.cpp @@ -160,9 +160,10 @@ void Window::iconActivated(QSystemTrayIcon::ActivationReason reason) void Window::showMessage() { showIconCheckBox->setChecked(true); - QSystemTrayIcon::MessageIcon msgIcon = QSystemTrayIcon::MessageIcon( - typeComboBox->itemData(typeComboBox->currentIndex()).toInt()); - if (msgIcon == QSystemTrayIcon::NoIcon) { + int selectedIcon = typeComboBox->itemData(typeComboBox->currentIndex()).toInt(); + QSystemTrayIcon::MessageIcon msgIcon = QSystemTrayIcon::MessageIcon(selectedIcon); + + if (selectedIcon == -1) { // custom icon QIcon icon(iconComboBox->itemIcon(iconComboBox->currentIndex())); trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), icon, durationSpinBox->value() * 1000); @@ -222,7 +223,7 @@ void Window::createMessageGroupBox() QStyle::SP_MessageBoxCritical), tr("Critical"), QSystemTrayIcon::Critical); typeComboBox->addItem(QIcon(), tr("Custom icon"), - QSystemTrayIcon::NoIcon); + -1); typeComboBox->setCurrentIndex(1); durationLabel = new QLabel(tr("Duration:")); -- cgit v1.2.3 From 2f33e030b8c80b4665cc2c120df7833469c05145 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 10 Jul 2019 17:04:42 +0200 Subject: Remove usages of deprecated APIs of qtbase/gui - Replaced the usages of deprecated APIs by corresponding alternatives in the library code and documentation. - Modified the tests to make them build when deprecated APIs disabled: * Made the the parts of the tests testing the deprecated APIs to be compiled conditionally, only when the corresponding methods are enabled. * If the test-case tests only the deprecated API, but not the corresponding replacement, added tests for the replacement. Change-Id: Ic38245015377fc0c8127eb5458c184ffd4b450f1 Reviewed-by: Volker Hilsheimer --- examples/opengl/legacy/hellogl/glwidget.cpp | 4 ++-- examples/opengl/legacy/overpainting/glwidget.cpp | 4 ++-- examples/widgets/painting/shared/arthurstyle.cpp | 4 ++-- examples/widgets/painting/shared/arthurwidgets.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/opengl/legacy/hellogl/glwidget.cpp b/examples/opengl/legacy/hellogl/glwidget.cpp index 22934136e5..059a9bb96d 100644 --- a/examples/opengl/legacy/hellogl/glwidget.cpp +++ b/examples/opengl/legacy/hellogl/glwidget.cpp @@ -140,10 +140,10 @@ void GLWidget::initializeGL() { initializeOpenGLFunctions(); - qglClearColor(qtPurple.dark()); + qglClearColor(qtPurple.darker()); logo = new QtLogo(this, 64); - logo->setColor(qtGreen.dark()); + logo->setColor(qtGreen.darker()); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); diff --git a/examples/opengl/legacy/overpainting/glwidget.cpp b/examples/opengl/legacy/overpainting/glwidget.cpp index 0094f8ead7..c4558ce785 100644 --- a/examples/opengl/legacy/overpainting/glwidget.cpp +++ b/examples/opengl/legacy/overpainting/glwidget.cpp @@ -130,7 +130,7 @@ void GLWidget::initializeGL() glEnable(GL_MULTISAMPLE); logo = new QtLogo(this); - logo->setColor(qtGreen.dark()); + logo->setColor(qtGreen.darker()); } //! [2] @@ -163,7 +163,7 @@ void GLWidget::paintEvent(QPaintEvent *event) //! [4] //! [6] - qglClearColor(qtPurple.dark()); + qglClearColor(qtPurple.darker()); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); diff --git a/examples/widgets/painting/shared/arthurstyle.cpp b/examples/widgets/painting/shared/arthurstyle.cpp index 3fc461bbd2..31be899357 100644 --- a/examples/widgets/painting/shared/arthurstyle.cpp +++ b/examples/widgets/painting/shared/arthurstyle.cpp @@ -457,7 +457,7 @@ void ArthurStyle::polish(QWidget *widget) QPalette pal = widget->palette(); if (widget->isWindow()) { - pal.setColor(QPalette::Background, QColor(241, 241, 241)); + pal.setColor(QPalette::Window, QColor(241, 241, 241)); widget->setPalette(pal); } @@ -474,7 +474,7 @@ void ArthurStyle::unpolish(QWidget *widget) void ArthurStyle::polish(QPalette &palette) { - palette.setColor(QPalette::Background, QColor(241, 241, 241)); + palette.setColor(QPalette::Window, QColor(241, 241, 241)); } QRect ArthurStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp index bdac5de13c..285be99d20 100644 --- a/examples/widgets/painting/shared/arthurwidgets.cpp +++ b/examples/widgets/painting/shared/arthurwidgets.cpp @@ -153,7 +153,7 @@ void ArthurFrame::paintEvent(QPaintEvent *e) int o = 10; - QBrush bg = palette().brush(QPalette::Background); + QBrush bg = palette().brush(QPalette::Window); painter.fillRect(0, 0, o, o, bg); painter.fillRect(width() - o, 0, o, o, bg); painter.fillRect(0, height() - o, o, o, bg); -- cgit v1.2.3 From 082f10c9eb12972efb7f194e49eb2b11928e1337 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 14 May 2019 20:42:01 +0200 Subject: QOpenGLWindow example: use std::unique_ptr instead of QScopedPointer QScopedPointer is scheduled for deprecation, and can't decide whether it wants to be a scoped, or a unique pointer. The use of a unique_ptr members requires that the destructor be out-of-line, since the payload classes are only forward-declared in the header file. Change-Id: Id0dcdde52cb3adc30d3051d2eed1d24c76154921 Reviewed-by: Edward Welbourne --- examples/opengl/qopenglwindow/background_renderer.cpp | 11 +++++++---- examples/opengl/qopenglwindow/background_renderer.h | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/opengl/qopenglwindow/background_renderer.cpp b/examples/opengl/qopenglwindow/background_renderer.cpp index 9da1b9bf99..acbbe74841 100644 --- a/examples/opengl/qopenglwindow/background_renderer.cpp +++ b/examples/opengl/qopenglwindow/background_renderer.cpp @@ -91,6 +91,9 @@ FragmentToy::FragmentToy(const QString &fragmentSource, QObject *parent) } } +FragmentToy::~FragmentToy() + = default; + void FragmentToy::draw(const QSize &windowSize) { if (!m_program) @@ -120,7 +123,7 @@ void FragmentToy::draw(const QSize &windowSize) if (!m_vertex_shader->compileSourceCode(vertex_shader)) { qWarning() << "Failed to compile the vertex shader:" << m_vertex_shader->log(); } - if (!m_program->addShader(m_vertex_shader.data())) { + if (!m_program->addShader(m_vertex_shader.get())) { qWarning() << "Failed to add vertex shader to program:" << m_program->log(); } } @@ -153,7 +156,7 @@ void FragmentToy::draw(const QSize &windowSize) } if (m_fragment_shader) { - if (!m_program->addShader(m_fragment_shader.data())) { + if (!m_program->addShader(m_fragment_shader.get())) { qWarning() << "Failed to add fragment shader to program:" << m_program->log(); } } @@ -197,14 +200,14 @@ void FragmentToy::fileChanged(const QString &path) m_fragment_file_last_modified = fragment_source.lastModified(); m_recompile_shaders = true; if (m_program) { - m_program->removeShader(m_fragment_shader.data()); + m_program->removeShader(m_fragment_shader.get()); m_fragment_shader.reset(nullptr); } } } else { m_recompile_shaders = true; if (m_program) { - m_program->removeShader(m_fragment_shader.data()); + m_program->removeShader(m_fragment_shader.get()); m_fragment_shader.reset(nullptr); } } diff --git a/examples/opengl/qopenglwindow/background_renderer.h b/examples/opengl/qopenglwindow/background_renderer.h index d99b7ddbeb..0e3caf5981 100644 --- a/examples/opengl/qopenglwindow/background_renderer.h +++ b/examples/opengl/qopenglwindow/background_renderer.h @@ -62,11 +62,14 @@ #include #include +#include + class FragmentToy : public QObject, protected QOpenGLFunctions { Q_OBJECT public: - FragmentToy(const QString &fragmentSource, QObject *parent = 0); + explicit FragmentToy(const QString &fragmentSource, QObject *parent = nullptr); + ~FragmentToy(); void draw(const QSize &windowSize); @@ -79,9 +82,9 @@ private: QString m_fragment_file; QDateTime m_fragment_file_last_modified; - QScopedPointer m_program; - QScopedPointer m_vertex_shader; - QScopedPointer m_fragment_shader; + std::unique_ptr m_program; + std::unique_ptr m_vertex_shader; + std::unique_ptr m_fragment_shader; QOpenGLVertexArrayObject m_vao; QOpenGLBuffer m_vertex_buffer; GLuint m_vertex_coord_pos; -- cgit v1.2.3 From d914a5ba4e2f0c208473d5e76adb7d16e2e8e706 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 30 Jul 2019 17:16:50 +0200 Subject: Remove the remaining usages of deprecated APIs of qtbase This change removes the leftovers form other cleanup commits. Task-number: QTBUG-76491 Change-Id: I61440f87c5a280f9666b78e19aac4d8ac603767e Reviewed-by: Volker Hilsheimer Reviewed-by: Alex Blasche --- examples/widgets/statemachine/trafficlight/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/widgets/statemachine/trafficlight/main.cpp b/examples/widgets/statemachine/trafficlight/main.cpp index 1a7050c28d..a12d2f10d1 100644 --- a/examples/widgets/statemachine/trafficlight/main.cpp +++ b/examples/widgets/statemachine/trafficlight/main.cpp @@ -105,7 +105,7 @@ public: m_green = new LightWidget(Qt::green); vbox->addWidget(m_green); QPalette pal = palette(); - pal.setColor(QPalette::Background, Qt::black); + pal.setColor(QPalette::Window, Qt::black); setPalette(pal); setAutoFillBackground(true); } -- cgit v1.2.3 From 376715f1a57209cbb19502954a37939e2d6d88c6 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 23 Jul 2019 15:26:19 +0200 Subject: Remove usages of deprecated APIs of qtbase/widgets - Replace the usages of deprecated APIs by corresponding alternatives in the library code and documentation. - Build docs for deprecated APIs conditionally, based on deprecation version. Remove the docs of methods deprecated since 5.0.0, these methods are not compiled anymore. - Modify the tests to make them build when deprecated APIs disabled: * Make the the parts of the tests testing the deprecated APIs to be compiled conditionally, only when the corresponding methods are enabled. * If the test-case tests only the deprecated API, but not the corresponding replacement, add tests for the replacement Task-number: QTBUG-76491 Task-number: QTBUG-76540 Task-number: QTBUG-76541 Change-Id: I6aaf0a1369c479fb880369a38f2b8e1e86b46934 Reviewed-by: Volker Hilsheimer --- examples/widgets/dialogs/standarddialogs/dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/widgets/dialogs/standarddialogs/dialog.cpp b/examples/widgets/dialogs/standarddialogs/dialog.cpp index c91a594490..df77d03567 100644 --- a/examples/widgets/dialogs/standarddialogs/dialog.cpp +++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp @@ -317,7 +317,7 @@ void Dialog::setInteger() { //! [0] bool ok; - int i = QInputDialog::getInt(this, tr("QInputDialog::getInteger()"), + int i = QInputDialog::getInt(this, tr("QInputDialog::getInt()"), tr("Percentage:"), 25, 0, 100, 1, &ok); if (ok) integerLabel->setText(tr("%1%").arg(i)); -- cgit v1.2.3