From b02f5b4aaff5147c177cacfc8324cf7a1c5c7381 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 3 Apr 2023 09:37:36 +0200 Subject: examples: Remove media player example Embedding the media player looks really outdated so it shouldn't be promoted inside an example. In order to keep the use case's code in source, the example was moved to tests/manual. Change-Id: I54b23e1a5e4d7b0910ce238ff2fefb14da540739 Reviewed-by: Volker Hilsheimer (cherry picked from commit 4fa7ebcf6390ed415ffd8d6bdc4987b789dad309) Reviewed-by: Qt Cherry-pick Bot --- examples/activeqt/CMakeLists.txt | 3 - examples/activeqt/activeqt.pro | 4 - examples/activeqt/mediaplayer/CMakeLists.txt | 42 ------ .../doc/images/activeqt-mediaplayer-example.jpg | Bin 48753 -> 0 bytes .../activeqt/mediaplayer/doc/src/mediaplayer.qdoc | 63 --------- examples/activeqt/mediaplayer/main.cpp | 145 -------------------- examples/activeqt/mediaplayer/mainwindow.ui | 147 --------------------- examples/activeqt/mediaplayer/mediaaxwidget.h | 29 ---- examples/activeqt/mediaplayer/mediaplayer.pro | 11 -- 9 files changed, 444 deletions(-) delete mode 100644 examples/activeqt/mediaplayer/CMakeLists.txt delete mode 100644 examples/activeqt/mediaplayer/doc/images/activeqt-mediaplayer-example.jpg delete mode 100644 examples/activeqt/mediaplayer/doc/src/mediaplayer.qdoc delete mode 100644 examples/activeqt/mediaplayer/main.cpp delete mode 100644 examples/activeqt/mediaplayer/mainwindow.ui delete mode 100644 examples/activeqt/mediaplayer/mediaaxwidget.h delete mode 100644 examples/activeqt/mediaplayer/mediaplayer.pro (limited to 'examples/activeqt') diff --git a/examples/activeqt/CMakeLists.txt b/examples/activeqt/CMakeLists.txt index b64c0d0..76a9808 100644 --- a/examples/activeqt/CMakeLists.txt +++ b/examples/activeqt/CMakeLists.txt @@ -14,6 +14,3 @@ if(MSVC) qt_internal_add_example(simpleqml) endif() endif() -if(MINGW OR QT_BUILD_SHARED_LIBS) - qt_internal_add_example(mediaplayer) -endif() diff --git a/examples/activeqt/activeqt.pro b/examples/activeqt/activeqt.pro index 8dcceff..251808c 100644 --- a/examples/activeqt/activeqt.pro +++ b/examples/activeqt/activeqt.pro @@ -5,9 +5,5 @@ SUBDIRS += comapp \ simple \ wrapper -contains(QT_CONFIG, shared):SUBDIRS += mediaplayer contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2): SUBDIRS += opengl qtHaveModule(quickcontrols2):SUBDIRS += simpleqml - -# Other examples need an IDL compiler -mingw:SUBDIRS = mediaplayer diff --git a/examples/activeqt/mediaplayer/CMakeLists.txt b/examples/activeqt/mediaplayer/CMakeLists.txt deleted file mode 100644 index 018708a..0000000 --- a/examples/activeqt/mediaplayer/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(mediaplayer_activeqt LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/activeqt/mediaplayer_activeqt") - -find_package(Qt6 REQUIRED COMPONENTS AxContainer Core Gui Widgets) - -qt_add_executable(mediaplayer_activeqt - main.cpp - mainwindow.ui - mediaaxwidget.h -) - -set_target_properties(mediaplayer_activeqt PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(mediaplayer_activeqt PUBLIC - Qt::AxContainer - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS mediaplayer_activeqt - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/activeqt/mediaplayer/doc/images/activeqt-mediaplayer-example.jpg b/examples/activeqt/mediaplayer/doc/images/activeqt-mediaplayer-example.jpg deleted file mode 100644 index 4839242..0000000 Binary files a/examples/activeqt/mediaplayer/doc/images/activeqt-mediaplayer-example.jpg and /dev/null differ diff --git a/examples/activeqt/mediaplayer/doc/src/mediaplayer.qdoc b/examples/activeqt/mediaplayer/doc/src/mediaplayer.qdoc deleted file mode 100644 index 02b6977..0000000 --- a/examples/activeqt/mediaplayer/doc/src/mediaplayer.qdoc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example activeqt/mediaplayer - \title Media Player Example (ActiveQt) - - \brief The Media Player example uses the Microsoft Media Player - ActiveX control to implement a functional media player application. - - \image activeqt-mediaplayer-example.jpg - - \e {Media Player} demonstrates how a Qt application can communicate with - embedded ActiveX controls using signals, slots, and the \c dynamicCall() - function. - - \quotefromfile activeqt/mediaplayer/main.cpp - \skipto class MainWindow - \printuntil /^\}/ - - The \c MainWindow class declares a \c QMainWindow based user interface, - using the \c Ui::MainWindow class created by Qt Designer. A number - of slots are implemented to handle events from user interface elements, - including the \c mediaPlayer object, which is a QAxWidget hosting - the Microsoft Media Player ActiveX control. - - \quotefromfile activeqt/mediaplayer/main.cpp - \skipto MainWindow::MainWindow() - \printuntil /^\}/ - - The constructor initializes the user interface, restores a previously - saved window geometry, and uses the \c dynamicCall() function to invoke - the APIs implemented by the Microsoft Media Player ActiveX control, - to set initial configuration parameters. - - \quotefromfile activeqt/mediaplayer/main.cpp - \skipto MainWindow::on_mediaPlayer_PlayStateChange - \printuntil /^\}/ - - The \c on_mediaPlayer_PlayStateChange slot handles the signal emitted - by the \c mediaPlayer object when its state changes. - - \quotefromfile activeqt/mediaplayer/main.cpp - \skipto MainWindow::openMedia - \printuntil /^\}/ - - The \c openMedia() function allows a media file to be opened by using - the \c dynamicCall() function to set the URL property in the ActiveX - control, which causes the media file to be loaded and played. - - \quotefromfile activeqt/mediaplayer/main.cpp - \skipto int main - \printuntil /^\}/ - - The \c main() function starts the application using standard Qt APIs - and uses an optional command line argument as the name of a media - file to be loaded by the player. - - To build the example, you must first build the QAxContainer - library. Then run your make tool in - \c examples/activeqt/mediaplayer and run the resulting - \c mediaplayer.exe. -*/ diff --git a/examples/activeqt/mediaplayer/main.cpp b/examples/activeqt/mediaplayer/main.cpp deleted file mode 100644 index bedb97f..0000000 --- a/examples/activeqt/mediaplayer/main.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ui_mainwindow.h" - -static const char geometryKey[] = "Geometry"; - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - MainWindow(); - ~MainWindow(); - void openMedia(const QString &mediaUrl); - -public slots: - void on_mediaPlayer_PlayStateChange(int newState); - void on_actionOpen_triggered(); - void on_actionExit_triggered(); - void on_actionAbout_triggered(); - void on_actionAboutQt_triggered(); - -private: - void updateWindowTitle(const QString &state); - Ui::MainWindow m_ui; -}; - -MainWindow::MainWindow() -{ - m_ui.setupUi(this); - - QSettings settings(QSettings::IniFormat, QSettings::UserScope, - QCoreApplication::organizationName(), QCoreApplication::applicationName()); - - const QByteArray restoredGeometry = settings.value(QLatin1String(geometryKey)).toByteArray(); - if (restoredGeometry.isEmpty() || !restoreGeometry(restoredGeometry)) { - const QRect availableGeometry = screen()->availableGeometry(); - const QSize size = (availableGeometry.size() * 4) / 5; - resize(size); - move(availableGeometry.center() - QPoint(size.width(), size.height()) / 2); - } - - m_ui.mediaPlayer->dynamicCall("enableContextMenu", false); - m_ui.mediaPlayer->dynamicCall("stretchToFit", true); - updateWindowTitle(""); -} - -MainWindow::~MainWindow() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, - QCoreApplication::organizationName(), QCoreApplication::applicationName()); - settings.setValue(QLatin1String(geometryKey), saveGeometry()); -} - -void MainWindow::on_mediaPlayer_PlayStateChange(int newState) -{ - static const QHash stateMapping { - {1, "Stopped"}, - {2, "Paused"}, - {3, "Playing"}, - {4, "Scanning Forwards"}, - {5, "Scanning Backwards"}, - {6, "Buffering"}, - {7, "Waiting"}, - {8, "Media Ended"}, - {9, "Transitioning"}, - {10, "Ready"}, - {11, "Reconnecting"}, - }; - const char *stateStr = stateMapping.value(newState, ""); - updateWindowTitle(tr(stateStr)); -} - -void MainWindow::on_actionOpen_triggered() -{ - QFileDialog fileDialog(this, tr("Open File")); - fileDialog.setAcceptMode(QFileDialog::AcceptOpen); - fileDialog.setFileMode(QFileDialog::ExistingFile); - fileDialog.setMimeTypeFilters({ "application/octet-stream", "video/x-msvideo", "video/mp4", "audio/mpeg", "audio/mp4" }); - if (fileDialog.exec() == QDialog::Accepted) - openMedia(fileDialog.selectedFiles().first()); -} - -void MainWindow::on_actionExit_triggered() -{ - QCoreApplication::quit(); -} - -void MainWindow::on_actionAbout_triggered() -{ - QMessageBox::about(this, tr("About Media Player"), - tr("This Example has been created using the ActiveQt integration into Qt Designer.\n" - "It demonstrates the use of QAxWidget to embed the Windows Media Player ActiveX\n" - "control into a Qt application.")); -} - -void MainWindow::on_actionAboutQt_triggered() -{ - QMessageBox::aboutQt(this, tr("About Qt")); -} - -void MainWindow::openMedia(const QString &mediaUrl) -{ - if (!mediaUrl.isEmpty()) - m_ui.mediaPlayer->dynamicCall("URL", mediaUrl); -} - -void MainWindow::updateWindowTitle(const QString &state) -{ - QString appName = QCoreApplication::applicationName(); - QString title = state.isEmpty() ? appName : - QString("%1 (%2)").arg(appName, state); - setWindowTitle(title); -} - -#include "main.moc" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - QCoreApplication::setApplicationVersion(QT_VERSION_STR); - QCoreApplication::setApplicationName(QLatin1String("Active Qt Media Player")); - QCoreApplication::setOrganizationName(QLatin1String("QtProject")); - - MainWindow w; - QCommandLineParser parser; - parser.setApplicationDescription(QCoreApplication::applicationName()); - parser.addHelpOption(); - parser.addVersionOption(); - parser.addPositionalArgument("file", "The media file to open."); - parser.process(app); - if (!parser.positionalArguments().isEmpty()) - w.openMedia(parser.positionalArguments().constFirst()); - w.show(); - return app.exec(); -} diff --git a/examples/activeqt/mediaplayer/mainwindow.ui b/examples/activeqt/mediaplayer/mainwindow.ui deleted file mode 100644 index b83d392..0000000 --- a/examples/activeqt/mediaplayer/mainwindow.ui +++ /dev/null @@ -1,147 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 794 - 599 - - - - true - - - Qt Media Player - - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - 0 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - {6bf52a52-394a-11d3-b153-00c04f79faa6} - - - - 0 - 0 - - - - - - - - - - - - - 0 - 0 - 794 - 21 - - - - - &File - - - - - - - &Help - - - - - - - - - - &Open - - - - - E&xit - - - - - &About - - - - - About &Qt - - - - - - - - QAxWidget - QWidget -
qaxwidget.h
-
- - MediaAxWidget - QAxWidget -
mediaaxwidget.h
-
-
- - -
diff --git a/examples/activeqt/mediaplayer/mediaaxwidget.h b/examples/activeqt/mediaplayer/mediaaxwidget.h deleted file mode 100644 index 3a49b61..0000000 --- a/examples/activeqt/mediaplayer/mediaaxwidget.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef MEDIAAXWIDGET_H -#define MEDIAAXWIDGET_H - -#include -#include - -// Overrides the translateKeyEvent() function to pass keystrokes -// to the Windows Media Player ActiveX control. -class MediaAxWidget : public QAxWidget -{ -public: - MediaAxWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {}) - : QAxWidget(parent, f) - { - } - -protected: - bool translateKeyEvent(int message, int keycode) const override - { - if (message >= WM_KEYFIRST && message <= WM_KEYLAST) - return true; - return QAxWidget::translateKeyEvent(message, keycode); - } -}; - -#endif // MEDIAAXWIDGET_H diff --git a/examples/activeqt/mediaplayer/mediaplayer.pro b/examples/activeqt/mediaplayer/mediaplayer.pro deleted file mode 100644 index ad787a3..0000000 --- a/examples/activeqt/mediaplayer/mediaplayer.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app - -QT += widgets axcontainer - -HEADERS = mediaaxwidget.h -SOURCES = main.cpp -FORMS = mainwindow.ui - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/mediaplayer -INSTALLS += target -- cgit v1.2.3