summaryrefslogtreecommitdiffstats
path: root/examples/activeqt
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2023-04-03 09:37:36 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-06 08:50:32 +0000
commitb02f5b4aaff5147c177cacfc8324cf7a1c5c7381 (patch)
tree59cf843c1f4adc92c716254e4ad0c3001881af17 /examples/activeqt
parent8e9f9c27ac6fc194829ba364ebf9ae2989cba476 (diff)
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 <volker.hilsheimer@qt.io> (cherry picked from commit 4fa7ebcf6390ed415ffd8d6bdc4987b789dad309) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/activeqt')
-rw-r--r--examples/activeqt/CMakeLists.txt3
-rw-r--r--examples/activeqt/activeqt.pro4
-rw-r--r--examples/activeqt/mediaplayer/CMakeLists.txt42
-rw-r--r--examples/activeqt/mediaplayer/doc/images/activeqt-mediaplayer-example.jpgbin48753 -> 0 bytes
-rw-r--r--examples/activeqt/mediaplayer/doc/src/mediaplayer.qdoc63
-rw-r--r--examples/activeqt/mediaplayer/main.cpp145
-rw-r--r--examples/activeqt/mediaplayer/mainwindow.ui147
-rw-r--r--examples/activeqt/mediaplayer/mediaaxwidget.h29
-rw-r--r--examples/activeqt/mediaplayer/mediaplayer.pro11
9 files changed, 0 insertions, 444 deletions
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
--- a/examples/activeqt/mediaplayer/doc/images/activeqt-mediaplayer-example.jpg
+++ /dev/null
Binary files 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 <QApplication>
-#include <QMessageBox>
-#include <QMainWindow>
-#include <QScreen>
-#include <QVariant>
-#include <QSettings>
-#include <QFileDialog>
-#include <QCommandLineParser>
-
-#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<int, const char *> 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 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>794</width>
- <height>599</height>
- </rect>
- </property>
- <property name="acceptDrops">
- <bool>true</bool>
- </property>
- <property name="windowTitle">
- <string>Qt Media Player</string>
- </property>
- <widget class="QWidget" name="centralWidget">
- <layout class="QHBoxLayout" name="unnamed">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QFrame" name="Frame">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- <layout class="QVBoxLayout" name="unnamed">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="leftMargin">
- <number>1</number>
- </property>
- <property name="topMargin">
- <number>1</number>
- </property>
- <property name="rightMargin">
- <number>1</number>
- </property>
- <property name="bottomMargin">
- <number>1</number>
- </property>
- <item>
- <widget class="MediaAxWidget" name="mediaPlayer">
- <property name="control" stdset="0">
- <string>{6bf52a52-394a-11d3-b153-00c04f79faa6}</string>
- </property>
- <property name="sizePolicy" stdset="0">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>794</width>
- <height>21</height>
- </rect>
- </property>
- <widget class="QMenu" name="PopupMenu">
- <property name="title">
- <string>&amp;File</string>
- </property>
- <addaction name="actionOpen"/>
- <addaction name="actionExit"/>
- </widget>
- <widget class="QMenu" name="menuHelp">
- <property name="title">
- <string>&amp;Help</string>
- </property>
- <addaction name="actionAbout"/>
- <addaction name="actionAboutQt"/>
- </widget>
- <addaction name="PopupMenu"/>
- <addaction name="menuHelp"/>
- </widget>
- <action name="actionOpen">
- <property name="text">
- <string>&amp;Open</string>
- </property>
- </action>
- <action name="actionExit">
- <property name="text">
- <string>E&amp;xit</string>
- </property>
- </action>
- <action name="actionAbout">
- <property name="text">
- <string>&amp;About</string>
- </property>
- </action>
- <action name="actionAboutQt">
- <property name="text">
- <string>About &amp;Qt</string>
- </property>
- </action>
- <actiongroup name="FileNewGroup"/>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>QAxWidget</class>
- <extends>QWidget</extends>
- <header>qaxwidget.h</header>
- </customwidget>
- <customwidget>
- <class>MediaAxWidget</class>
- <extends>QAxWidget</extends>
- <header>mediaaxwidget.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
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 <QtAxContainer/QAxWidget>
-#include <qt_windows.h>
-
-// 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