From c2751b1d664748cfbd05d2e397f95f2cc0bec13f Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Mon, 21 Aug 2017 13:23:48 +0200 Subject: Active Qt Examples: Brush up to C++ 11 Use nullptr, member initialization, new connect syntax, QStringLiteral, etc. Change-Id: Ia79473ca302216f91eec6a32f670cf606761ed0d Reviewed-by: Michael Winkelmann Reviewed-by: Friedemann Kleint --- examples/activeqt/menus/main.cpp | 11 ++++---- examples/activeqt/menus/menus.cpp | 54 +++++++++++++++++++-------------------- examples/activeqt/menus/menus.h | 4 +-- 3 files changed, 35 insertions(+), 34 deletions(-) (limited to 'examples/activeqt/menus') diff --git a/examples/activeqt/menus/main.cpp b/examples/activeqt/menus/main.cpp index 0a4867c..12342cf 100644 --- a/examples/activeqt/menus/main.cpp +++ b/examples/activeqt/menus/main.cpp @@ -41,6 +41,7 @@ #include "menus.h" #include #include +#include QAXFACTORY_BEGIN( "{ce947ee3-0403-4fdc-895a-4fe779394b46}", // type library ID @@ -48,13 +49,13 @@ QAXFACTORY_BEGIN( QAXCLASS(QMenus) QAXFACTORY_END() -int main( int argc, char **argv ) +int main(int argc, char *argv[]) { - QApplication a( argc, argv ); + QApplication a(argc, argv); + QScopedPointer window; - QWidget *window = 0; - if ( !QAxFactory::isServer() ) { - window = new QMenus(); + if (!QAxFactory::isServer()) { + window.reset(new QMenus()); window->show(); } diff --git a/examples/activeqt/menus/menus.cpp b/examples/activeqt/menus/menus.cpp index 638bcd2..cde6291 100644 --- a/examples/activeqt/menus/menus.cpp +++ b/examples/activeqt/menus/menus.cpp @@ -56,52 +56,52 @@ QMenus::QMenus(QWidget *parent) QMenu *file = new QMenu(this); - action = new QAction(QPixmap((const char**)fileopen), "&Open", this); + action = new QAction(QPixmap((const char**)fileopen), tr("&Open"), this); action->setShortcut(tr("CTRL+O")); connect(action, &QAction::triggered, this, &QMenus::fileOpen); file->addAction(action); - action = new QAction(QPixmap((const char**)filesave),"&Save", this); + action = new QAction(QPixmap((const char**)filesave), tr("&Save"), this); action->setShortcut(tr("CTRL+S")); connect(action, &QAction::triggered, this, &QMenus::fileSave); file->addAction(action); QMenu *edit = new QMenu(this); - action = new QAction("&Normal", this); + action = new QAction(tr("&Normal"), this); action->setShortcut(tr("CTRL+N")); - action->setToolTip("Normal"); - action->setStatusTip("Toggles Normal"); + action->setToolTip(tr("Normal")); + action->setStatusTip(tr("Toggles Normal")); action->setCheckable(true); connect(action, &QAction::triggered, this, &QMenus::editNormal); edit->addAction(action); - action = new QAction("&Bold", this); + action = new QAction(tr("&Bold"), this); action->setShortcut(tr("CTRL+B")); action->setCheckable(true); connect(action, &QAction::triggered, this, &QMenus::editBold); edit->addAction(action); - action = new QAction("&Underline", this); + action = new QAction(tr("&Underline"), this); action->setShortcut(tr("CTRL+U")); action->setCheckable(true); connect(action, &QAction::triggered, this, &QMenus::editUnderline); edit->addAction(action); QMenu *advanced = new QMenu(this); - action = new QAction("&Font...", this); + action = new QAction(tr("&Font..."), this); connect(action, &QAction::triggered, this, &QMenus::editAdvancedFont); advanced->addAction(action); - action = new QAction("&Style...", this); + action = new QAction(tr("&Style..."), this); connect(action, &QAction::triggered, this, &QMenus::editAdvancedStyle); advanced->addAction(action); - edit->addMenu(advanced)->setText("&Advanced"); + edit->addMenu(advanced)->setText(tr("&Advanced")); edit->addSeparator(); - action = new QAction("Una&vailable", this); + action = new QAction(tr("Una&vailable"), this); action->setShortcut(tr("CTRL+V")); action->setCheckable(true); action->setEnabled(false); @@ -110,65 +110,65 @@ QMenus::QMenus(QWidget *parent) QMenu *help = new QMenu(this); - action = new QAction("&About...", this); + action = new QAction(tr("&About..."), this); action->setShortcut(tr("F1")); connect(action, &QAction::triggered, this, &QMenus::helpAbout); help->addAction(action); - action = new QAction("&About Qt...", this); + action = new QAction(tr("&About Qt..."), this); connect(action, &QAction::triggered, this, &QMenus::helpAboutQt); help->addAction(action); if (!QAxFactory::isServer()) - menuBar()->addMenu(file)->setText("&File"); - menuBar()->addMenu(edit)->setText("&Edit"); - menuBar()->addMenu(help)->setText("&Help"); + menuBar()->addMenu(file)->setText(tr("&File")); + menuBar()->addMenu(edit)->setText(tr("&Edit")); + menuBar()->addMenu(help)->setText(tr("&Help")); - editor = new QTextEdit(this); - setCentralWidget(editor); + m_editor = new QTextEdit(this); + setCentralWidget(m_editor); statusBar(); } void QMenus::fileOpen() { - editor->append("File Open selected."); + m_editor->append(tr("File Open selected.")); } void QMenus::fileSave() { - editor->append("File Save selected."); + m_editor->append(tr("File Save selected.")); } void QMenus::editNormal() { - editor->append("Edit Normal selected."); + m_editor->append(tr("Edit Normal selected.")); } void QMenus::editBold() { - editor->append("Edit Bold selected."); + m_editor->append(tr("Edit Bold selected.")); } void QMenus::editUnderline() { - editor->append("Edit Underline selected."); + m_editor->append(tr("Edit Underline selected.")); } void QMenus::editAdvancedFont() { - editor->append("Edit Advanced Font selected."); + m_editor->append(tr("Edit Advanced Font selected.")); } void QMenus::editAdvancedStyle() { - editor->append("Edit Advanced Style selected."); + m_editor->append(tr("Edit Advanced Style selected.")); } void QMenus::helpAbout() { - QMessageBox::about(this, "About QMenus", - "This example implements an in-place ActiveX control with menus and status messages."); + QMessageBox::about(this, tr("About QMenus"), + tr("This example implements an in-place ActiveX control with menus and status messages.")); } void QMenus::helpAboutQt() diff --git a/examples/activeqt/menus/menus.h b/examples/activeqt/menus/menus.h index 480a367..dc45b86 100644 --- a/examples/activeqt/menus/menus.h +++ b/examples/activeqt/menus/menus.h @@ -55,7 +55,7 @@ class QMenus : public QMainWindow Q_CLASSINFO("EventsID", "{13eca64b-ee2a-4f3c-aa04-5d9d975979a7}") public: - QMenus(QWidget *parent = 0); + explicit QMenus(QWidget *parent = nullptr); public slots: void fileOpen(); @@ -72,7 +72,7 @@ public slots: void helpAboutQt(); private: - QTextEdit *editor; + QTextEdit *m_editor; }; #endif // MENUS_H -- cgit v1.2.1 From a07f521f9bfa535ad18cbdd93e228276133ff4d9 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 28 Sep 2017 13:26:23 +0200 Subject: Fix outdated BSD license header Use new version with commercial exception. Change-Id: I20b377176e99b80db47f41596d20192ae7d5564f Reviewed-by: Friedemann Kleint --- .../menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc | 12 +++++++++++- examples/activeqt/menus/main.cpp | 12 +++++++++++- examples/activeqt/menus/menus.cpp | 12 +++++++++++- examples/activeqt/menus/menus.h | 12 +++++++++++- 4 files changed, 44 insertions(+), 4 deletions(-) (limited to 'examples/activeqt/menus') diff --git a/examples/activeqt/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc b/examples/activeqt/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc index cca4d85..c0535a6 100644 --- a/examples/activeqt/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc +++ b/examples/activeqt/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc @@ -6,7 +6,17 @@ ** This file is part of the documentation of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/activeqt/menus/main.cpp b/examples/activeqt/menus/main.cpp index 12342cf..8d70e4d 100644 --- a/examples/activeqt/menus/main.cpp +++ b/examples/activeqt/menus/main.cpp @@ -6,7 +6,17 @@ ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/activeqt/menus/menus.cpp b/examples/activeqt/menus/menus.cpp index cde6291..feb3540 100644 --- a/examples/activeqt/menus/menus.cpp +++ b/examples/activeqt/menus/menus.cpp @@ -6,7 +6,17 @@ ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/activeqt/menus/menus.h b/examples/activeqt/menus/menus.h index dc45b86..efc6cca 100644 --- a/examples/activeqt/menus/menus.h +++ b/examples/activeqt/menus/menus.h @@ -6,7 +6,17 @@ ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are -- cgit v1.2.1