mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-27 13:38:49 +03:00
Basic running app on qt6
This commit is contained in:
parent
8c66945be9
commit
7303275793
27 changed files with 152 additions and 260 deletions
|
@ -196,14 +196,15 @@ endif()
|
||||||
#
|
#
|
||||||
# Discover Qt dependencies.
|
# Discover Qt dependencies.
|
||||||
#
|
#
|
||||||
find_package(Qt5 5.15 COMPONENTS Core Widgets LinguistTools Concurrent Svg Multimedia Qml QuickControls2 QuickWidgets REQUIRED)
|
find_package(Qt6 6.2 COMPONENTS Core Widgets LinguistTools Svg Multimedia Qml QuickControls2 REQUIRED)
|
||||||
find_package(Qt5QuickCompiler)
|
#find_package(Qt5QuickCompiler)
|
||||||
find_package(Qt5DBus)
|
find_package(Qt6DBus)
|
||||||
|
|
||||||
if (USE_BUNDLED_QTKEYCHAIN)
|
if (USE_BUNDLED_QTKEYCHAIN)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
set(BUILD_WITH_QT6 ON)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
qt5keychain
|
qt6keychain
|
||||||
GIT_REPOSITORY https://github.com/frankosterfeld/qtkeychain.git
|
GIT_REPOSITORY https://github.com/frankosterfeld/qtkeychain.git
|
||||||
GIT_TAG v0.13.1
|
GIT_TAG v0.13.1
|
||||||
)
|
)
|
||||||
|
@ -213,13 +214,13 @@ if (USE_BUNDLED_QTKEYCHAIN)
|
||||||
set(QTKEYCHAIN_STATIC ON CACHE INTERNAL "")
|
set(QTKEYCHAIN_STATIC ON CACHE INTERNAL "")
|
||||||
endif()
|
endif()
|
||||||
set(BUILD_TEST_APPLICATION OFF CACHE INTERNAL "")
|
set(BUILD_TEST_APPLICATION OFF CACHE INTERNAL "")
|
||||||
FetchContent_MakeAvailable(qt5keychain)
|
FetchContent_MakeAvailable(qt6keychain)
|
||||||
else()
|
else()
|
||||||
find_package(Qt5Keychain REQUIRED)
|
find_package(Qt6Keychain REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
find_package(Qt5MacExtras REQUIRED)
|
find_package(Qt6MacExtras REQUIRED)
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
if (Qt5Widgets_FOUND)
|
if (Qt5Widgets_FOUND)
|
||||||
|
@ -505,7 +506,7 @@ if (NOT APPLE AND NOT WIN32)
|
||||||
add_compile_definitions(NHEKO_DBUS_SYS)
|
add_compile_definitions(NHEKO_DBUS_SYS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt5_wrap_cpp(MOC_HEADERS
|
qt_wrap_cpp(MOC_HEADERS
|
||||||
# Dialogs
|
# Dialogs
|
||||||
src/dialogs/FallbackAuth.h
|
src/dialogs/FallbackAuth.h
|
||||||
src/dialogs/ReCaptcha.h
|
src/dialogs/ReCaptcha.h
|
||||||
|
@ -645,7 +646,7 @@ elseif(WIN32)
|
||||||
target_compile_options(nheko PUBLIC "/Zc:__cplusplus")
|
target_compile_options(nheko PUBLIC "/Zc:__cplusplus")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
target_link_libraries (nheko PRIVATE Qt5::DBus)
|
target_link_libraries (nheko PRIVATE Qt::DBus)
|
||||||
if (FLATPAK)
|
if (FLATPAK)
|
||||||
target_compile_definitions(nheko PRIVATE NHEKO_FLATPAK)
|
target_compile_definitions(nheko PRIVATE NHEKO_FLATPAK)
|
||||||
endif()
|
endif()
|
||||||
|
@ -654,21 +655,19 @@ target_include_directories(nheko PRIVATE src includes third_party/blurhash third
|
||||||
|
|
||||||
# Fixup bundled keychain include dirs
|
# Fixup bundled keychain include dirs
|
||||||
if (USE_BUNDLED_QTKEYCHAIN)
|
if (USE_BUNDLED_QTKEYCHAIN)
|
||||||
target_include_directories(nheko PRIVATE ${qt5keychain_SOURCE_DIR} ${qt5keychain_BINARY_DIR})
|
target_include_directories(nheko PRIVATE ${qt6keychain_SOURCE_DIR} ${qt6keychain_BINARY_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(nheko PRIVATE
|
target_link_libraries(nheko PRIVATE
|
||||||
MatrixClient::MatrixClient
|
MatrixClient::MatrixClient
|
||||||
cmark::cmark
|
cmark::cmark
|
||||||
spdlog::spdlog
|
spdlog::spdlog
|
||||||
Qt5::Widgets
|
Qt::Widgets
|
||||||
Qt5::Svg
|
Qt::Svg
|
||||||
Qt5::Concurrent
|
Qt::Multimedia
|
||||||
Qt5::Multimedia
|
Qt::Qml
|
||||||
Qt5::Qml
|
Qt::QuickControls2
|
||||||
Qt5::QuickControls2
|
qt6keychain
|
||||||
Qt5::QuickWidgets
|
|
||||||
qt5keychain
|
|
||||||
nlohmann_json::nlohmann_json
|
nlohmann_json::nlohmann_json
|
||||||
lmdbxx::lmdbxx
|
lmdbxx::lmdbxx
|
||||||
liblmdb::lmdb
|
liblmdb::lmdb
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
file(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
|
file(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
|
||||||
|
|
||||||
qt5_add_translation(QM_SRC ${LANG_TS_SRC})
|
qt_add_translation(QM_SRC ${LANG_TS_SRC})
|
||||||
qt5_create_translation(${QM_SRC})
|
qt_create_translation(${QM_SRC})
|
||||||
add_custom_target(LANG_QRC ALL DEPENDS ${QM_SRC})
|
add_custom_target(LANG_QRC ALL DEPENDS ${QM_SRC})
|
||||||
|
set_target_properties(LANG_QRC PROPERTIES QT_RESOURCE_PREFIX /)
|
||||||
|
|
||||||
# Generate a qrc file for the translations
|
# Generate a qrc file for the translations
|
||||||
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||||
|
@ -20,9 +21,9 @@ if(NOT EXISTS ${_qrc})
|
||||||
file(APPEND ${_qrc} " </qresource>\n</RCC>\n")
|
file(APPEND ${_qrc} " </qresource>\n</RCC>\n")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt5_add_resources(LANG_QRC ${_qrc})
|
qt_add_resources(LANG_QRC ${_qrc})
|
||||||
if(Qt5QuickCompiler_FOUND AND COMPILE_QML)
|
if(Qt5QuickCompiler_FOUND AND COMPILE_QML)
|
||||||
qtquick_compiler_add_resources(QRC resources/res.qrc)
|
qtquick_compiler_add_resources(QRC resources/res.qrc)
|
||||||
else()
|
else()
|
||||||
qt5_add_resources(QRC resources/res.qrc)
|
qt_add_resources(QRC resources/res.qrc)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtGraphicalEffects 1.0
|
//import QtGraphicalEffects 1.0
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
import im.nheko 1.0
|
import im.nheko 1.0
|
||||||
|
@ -120,13 +120,13 @@ Item {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
FastBlur {
|
//FastBlur {
|
||||||
id: blur
|
// id: blur
|
||||||
|
|
||||||
anchors.fill: parent
|
// anchors.fill: parent
|
||||||
source: timelineRoot
|
// source: timelineRoot
|
||||||
radius: 50
|
// radius: 50
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,26 @@ import im.nheko.EmojiModel 1.0
|
||||||
Pane {
|
Pane {
|
||||||
id: timelineRoot
|
id: timelineRoot
|
||||||
|
|
||||||
palette: Nheko.colors
|
palette {
|
||||||
|
windowText: "#caccd1"
|
||||||
|
button: "white"
|
||||||
|
light: "#caccd1"
|
||||||
|
dark: "#3c464d"
|
||||||
|
mid: "#202228"
|
||||||
|
text: "#caccd1"
|
||||||
|
brightText: "#f4f5f8"
|
||||||
|
base: "#202228"
|
||||||
|
window: "#2d3139"
|
||||||
|
|
||||||
|
alternateBase: "#2d3139"
|
||||||
|
highlight: "#38a3d8"
|
||||||
|
highlightedText: "#f4f5f8"
|
||||||
|
toolTipBase: base
|
||||||
|
toolTipText: text
|
||||||
|
link: "#38a3d8"
|
||||||
|
buttonText: "#828284"
|
||||||
|
|
||||||
|
}
|
||||||
background: null
|
background: null
|
||||||
padding: 0
|
padding: 0
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtGraphicalEffects 1.12
|
//import QtGraphicalEffects 1.12
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.5
|
import QtQuick.Controls 2.5
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
|
@ -19,16 +19,16 @@ Button {
|
||||||
|
|
||||||
property string iconImage: ""
|
property string iconImage: ""
|
||||||
|
|
||||||
DropShadow {
|
//DropShadow {
|
||||||
anchors.fill: control.background
|
// anchors.fill: control.background
|
||||||
horizontalOffset: 3
|
// horizontalOffset: 3
|
||||||
verticalOffset: 3
|
// verticalOffset: 3
|
||||||
radius: 8
|
// radius: 8
|
||||||
samples: 17
|
// samples: 17
|
||||||
cached: true
|
// cached: true
|
||||||
color: "#80000000"
|
// color: "#80000000"
|
||||||
source: control.background
|
// source: control.background
|
||||||
}
|
//}
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
import "../ui/media"
|
import "../ui/media"
|
||||||
import QtMultimedia 5.15
|
import QtMultimedia
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
@ -36,13 +36,13 @@ Item {
|
||||||
MxcMedia {
|
MxcMedia {
|
||||||
id: mxcmedia
|
id: mxcmedia
|
||||||
|
|
||||||
// TODO: Show error in overlay or so?
|
|
||||||
onError: console.log(error)
|
|
||||||
roomm: room
|
roomm: room
|
||||||
// desiredVolume is a float from 0.0 -> 1.0, MediaPlayer volume is an int from 0 to 100
|
|
||||||
// this value automatically gets clamped for us between these two values.
|
audioOutput: AudioOutput {
|
||||||
volume: mediaControls.desiredVolume * 100
|
muted: mediaControls.muted
|
||||||
muted: mediaControls.muted
|
volume: mediaControls.desiredVolume
|
||||||
|
}
|
||||||
|
videoOutput: videoOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -69,8 +69,7 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: VideoOutput.PreserveAspectFit
|
fillMode: VideoOutput.PreserveAspectFit
|
||||||
source: mxcmedia
|
//flushMode: VideoOutput.FirstFrame
|
||||||
flushMode: VideoOutput.FirstFrame
|
|
||||||
orientation: mxcmedia.orientation
|
orientation: mxcmedia.orientation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
import QtGraphicalEffects 1.0
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "../"
|
import "../"
|
||||||
import QtGraphicalEffects 1.0
|
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtGraphicalEffects 1.0
|
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import "./animations"
|
import "./animations"
|
||||||
import QtGraphicalEffects 1.12
|
//import QtGraphicalEffects 1.12
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -140,17 +140,17 @@ Item {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Glow {
|
//Glow {
|
||||||
anchors.fill: row
|
// anchors.fill: row
|
||||||
radius: 14
|
// radius: 14
|
||||||
samples: 17
|
// samples: 17
|
||||||
color: spinner.foreground
|
// color: spinner.foreground
|
||||||
source: row
|
// source: row
|
||||||
|
|
||||||
transform: Matrix4x4 {
|
// transform: Matrix4x4 {
|
||||||
matrix: Qt.matrix4x4(Math.cos(spinner.a), -Math.sin(spinner.a), 0, 0, 0, Math.cos(spinner.a), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
|
// matrix: Qt.matrix4x4(Math.cos(spinner.a), -Math.sin(spinner.a), 0, 0, 0, Math.cos(spinner.a), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtGraphicalEffects 1.12
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
|
|
|
@ -4040,7 +4040,8 @@ Cache::displayName(const QString &room_id, const QString &user_id)
|
||||||
static bool
|
static bool
|
||||||
isDisplaynameSafe(const std::string &s)
|
isDisplaynameSafe(const std::string &s)
|
||||||
{
|
{
|
||||||
for (QChar c : QString::fromStdString(s).toStdU32String()) {
|
for (uint32_t cc : QString::fromStdString(s).toStdU32String()) {
|
||||||
|
auto c = QChar(cc);
|
||||||
if (c.isPrint() && !c.isSpace())
|
if (c.isPrint() && !c.isSpace())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model,
|
||||||
finder.toNextBoundary();
|
finder.toNextBoundary();
|
||||||
auto end = finder.position();
|
auto end = finder.position();
|
||||||
|
|
||||||
auto ref = str.midRef(start, end - start).trimmed();
|
auto ref = QStringView(str).mid(start, end - start).trimmed();
|
||||||
if (!ref.isEmpty())
|
if (!ref.isEmpty())
|
||||||
trie_.insert(ref.toUcs4(), i);
|
trie_.insert(ref.toUcs4(), i);
|
||||||
} while (finder.position() < str.size());
|
} while (finder.position() < str.size());
|
||||||
|
|
|
@ -78,11 +78,12 @@ public slots:
|
||||||
if (queryStart != -1) {
|
if (queryStart != -1) {
|
||||||
id_ = id.left(queryStart);
|
id_ = id.left(queryStart);
|
||||||
auto query = id.mid(queryStart + 1);
|
auto query = id.mid(queryStart + 1);
|
||||||
auto queryBits = query.splitRef('&');
|
auto queryBits = QStringView(query).split('&');
|
||||||
|
|
||||||
for (const auto &b : queryBits) {
|
for (const auto &b : queryBits) {
|
||||||
if (b.startsWith(QStringView(u"radius="))) {
|
if (b.startsWith(QStringView(u"radius="))) {
|
||||||
radius = b.mid(7).toDouble();
|
radius = b.mid(7).toDouble();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1373,7 +1373,6 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
l.push_back(QString::fromStdString(d));
|
l.push_back(QString::fromStdString(d));
|
||||||
return l;
|
return l;
|
||||||
};
|
};
|
||||||
static QFontDatabase fontDb;
|
|
||||||
|
|
||||||
switch (index.row()) {
|
switch (index.row()) {
|
||||||
case Theme:
|
case Theme:
|
||||||
|
@ -1393,9 +1392,9 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
i->camera().toStdString(), i->cameraResolution().toStdString()));
|
i->camera().toStdString(), i->cameraResolution().toStdString()));
|
||||||
|
|
||||||
case Font:
|
case Font:
|
||||||
return fontDb.families();
|
return QFontDatabase::families();
|
||||||
case EmojiFont:
|
case EmojiFont:
|
||||||
return fontDb.families(QFontDatabase::WritingSystem::Symbol);
|
return QFontDatabase::families(QFontDatabase::WritingSystem::Symbol);
|
||||||
case Ringtone:
|
case Ringtone:
|
||||||
QStringList l{
|
QStringList l{
|
||||||
QStringLiteral("Mute"),
|
QStringLiteral("Mute"),
|
||||||
|
@ -1438,8 +1437,6 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
bool
|
bool
|
||||||
UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
static QFontDatabase fontDb;
|
|
||||||
|
|
||||||
auto i = UserSettings::instance();
|
auto i = UserSettings::instance();
|
||||||
if (role == Value) {
|
if (role == Value) {
|
||||||
switch (index.row()) {
|
switch (index.row()) {
|
||||||
|
@ -1464,7 +1461,7 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case ScaleFactor: {
|
case ScaleFactor: {
|
||||||
if (value.canConvert(QMetaType::Double)) {
|
if (value.canConvert(QMetaType::fromType<double>())) {
|
||||||
utils::setScaleFactor(static_cast<float>(value.toDouble()));
|
utils::setScaleFactor(static_cast<float>(value.toDouble()));
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
|
@ -1548,7 +1545,7 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case TimelineMaxWidth: {
|
case TimelineMaxWidth: {
|
||||||
if (value.canConvert(QMetaType::Int)) {
|
if (value.canConvert(QMetaType::fromType<int>())) {
|
||||||
i->setTimelineMaxWidth(value.toInt());
|
i->setTimelineMaxWidth(value.toInt());
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
|
@ -1619,7 +1616,7 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case PrivacyScreenTimeout: {
|
case PrivacyScreenTimeout: {
|
||||||
if (value.canConvert(QMetaType::Int)) {
|
if (value.canConvert(QMetaType::fromType<int>())) {
|
||||||
i->setPrivacyScreenTimeout(value.toInt());
|
i->setPrivacyScreenTimeout(value.toInt());
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
|
@ -1633,7 +1630,7 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case FontSize: {
|
case FontSize: {
|
||||||
if (value.canConvert(QMetaType::Double)) {
|
if (value.canConvert(QMetaType::fromType<double>())) {
|
||||||
i->setFontSize(value.toDouble());
|
i->setFontSize(value.toDouble());
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
|
@ -1641,7 +1638,7 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
}
|
}
|
||||||
case Font: {
|
case Font: {
|
||||||
if (value.userType() == QMetaType::Int) {
|
if (value.userType() == QMetaType::Int) {
|
||||||
i->setFontFamily(fontDb.families().at(value.toInt()));
|
i->setFontFamily(QFontDatabase::families().at(value.toInt()));
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
@ -1649,7 +1646,7 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
case EmojiFont: {
|
case EmojiFont: {
|
||||||
if (value.userType() == QMetaType::Int) {
|
if (value.userType() == QMetaType::Int) {
|
||||||
i->setEmojiFontFamily(
|
i->setEmojiFontFamily(
|
||||||
fontDb.families(QFontDatabase::WritingSystem::Symbol).at(value.toInt()));
|
QFontDatabase::families(QFontDatabase::WritingSystem::Symbol).at(value.toInt()));
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -268,7 +268,8 @@ utils::firstChar(const QString &input)
|
||||||
return QString::fromUcs4(&c, 1).toUpper();
|
return QString::fromUcs4(&c, 1).toUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString::fromUcs4(&input.toUcs4().at(0), 1).toUpper();
|
auto c = static_cast<char32_t>(input.toUcs4().at(0));
|
||||||
|
return QString::fromUcs4(&c, 1).toUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
|
|
14
src/main.cpp
14
src/main.cpp
|
@ -152,8 +152,6 @@ main(int argc, char *argv[])
|
||||||
QCoreApplication::setApplicationVersion(nheko::version);
|
QCoreApplication::setApplicationVersion(nheko::version);
|
||||||
QCoreApplication::setOrganizationName(QStringLiteral("nheko"));
|
QCoreApplication::setOrganizationName(QStringLiteral("nheko"));
|
||||||
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
||||||
|
|
||||||
// this needs to be after setting the application name. Or how would we find our settings
|
// this needs to be after setting the application name. Or how would we find our settings
|
||||||
// file then?
|
// file then?
|
||||||
|
@ -287,16 +285,16 @@ main(int argc, char *argv[])
|
||||||
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
|
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
|
||||||
|
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
qtTranslator.load(QLocale(),
|
if(qtTranslator.load(QLocale(),
|
||||||
QStringLiteral("qt"),
|
QStringLiteral("qt"),
|
||||||
QStringLiteral("_"),
|
QStringLiteral("_"),
|
||||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
|
||||||
app.installTranslator(&qtTranslator);
|
app.installTranslator(&qtTranslator);
|
||||||
|
|
||||||
QTranslator appTranslator;
|
QTranslator appTranslator;
|
||||||
appTranslator.load(
|
if(appTranslator.load(
|
||||||
QLocale(), QStringLiteral("nheko"), QStringLiteral("_"), QStringLiteral(":/translations"));
|
QLocale(), QStringLiteral("nheko"), QStringLiteral("_"), QStringLiteral(":/translations")))
|
||||||
app.installTranslator(&appTranslator);
|
app.installTranslator(&appTranslator);
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
// QQuickView w;
|
// QQuickView w;
|
||||||
|
|
|
@ -78,13 +78,13 @@ DelegateChooser::appendChoice(QQmlListProperty<DelegateChoice> *p, DelegateChoic
|
||||||
dc->choices_.append(c);
|
dc->choices_.append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
qsizetype
|
||||||
DelegateChooser::choiceCount(QQmlListProperty<DelegateChoice> *p)
|
DelegateChooser::choiceCount(QQmlListProperty<DelegateChoice> *p)
|
||||||
{
|
{
|
||||||
return static_cast<DelegateChooser *>(p->object)->choices_.count();
|
return static_cast<DelegateChooser *>(p->object)->choices_.count();
|
||||||
}
|
}
|
||||||
DelegateChoice *
|
DelegateChoice *
|
||||||
DelegateChooser::choice(QQmlListProperty<DelegateChoice> *p, int index)
|
DelegateChooser::choice(QQmlListProperty<DelegateChoice> *p, qsizetype index)
|
||||||
{
|
{
|
||||||
return static_cast<DelegateChooser *>(p->object)->choices_.at(index);
|
return static_cast<DelegateChooser *>(p->object)->choices_.at(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
DelegateIncubator incubator{*this};
|
DelegateIncubator incubator{*this};
|
||||||
|
|
||||||
static void appendChoice(QQmlListProperty<DelegateChoice> *, DelegateChoice *);
|
static void appendChoice(QQmlListProperty<DelegateChoice> *, DelegateChoice *);
|
||||||
static int choiceCount(QQmlListProperty<DelegateChoice> *);
|
static qsizetype choiceCount(QQmlListProperty<DelegateChoice> *);
|
||||||
static DelegateChoice *choice(QQmlListProperty<DelegateChoice> *, int index);
|
static DelegateChoice *choice(QQmlListProperty<DelegateChoice> *, qsizetype index);
|
||||||
static void clearChoices(QQmlListProperty<DelegateChoice> *);
|
static void clearChoices(QQmlListProperty<DelegateChoice> *);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,12 +5,14 @@
|
||||||
|
|
||||||
#include "InputBar.h"
|
#include "InputBar.h"
|
||||||
|
|
||||||
|
#include <QVideoSink>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QInputMethod>
|
#include <QInputMethod>
|
||||||
|
#include <QVideoFrame>
|
||||||
#include <QMediaMetaData>
|
#include <QMediaMetaData>
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
@ -52,55 +54,6 @@ MediaUpload::thumbnailDataUrl() const
|
||||||
return QString("data:image/png;base64,") + base64;
|
return QString("data:image/png;base64,") + base64;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
InputVideoSurface::present(const QVideoFrame &frame)
|
|
||||||
{
|
|
||||||
QImage::Format format = QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat());
|
|
||||||
|
|
||||||
if (format == QImage::Format_Invalid) {
|
|
||||||
emit newImage({});
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
QVideoFrame frametodraw(frame);
|
|
||||||
|
|
||||||
if (!frametodraw.map(QAbstractVideoBuffer::ReadOnly)) {
|
|
||||||
emit newImage({});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is a shallow operation. it just refer the frame buffer
|
|
||||||
QImage image(qAsConst(frametodraw).bits(),
|
|
||||||
frametodraw.width(),
|
|
||||||
frametodraw.height(),
|
|
||||||
frametodraw.bytesPerLine(),
|
|
||||||
format);
|
|
||||||
image.detach();
|
|
||||||
|
|
||||||
frametodraw.unmap();
|
|
||||||
|
|
||||||
emit newImage(std::move(image));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QVideoFrame::PixelFormat>
|
|
||||||
InputVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const
|
|
||||||
{
|
|
||||||
if (type == QAbstractVideoBuffer::NoHandle) {
|
|
||||||
return {
|
|
||||||
QVideoFrame::Format_ARGB32,
|
|
||||||
QVideoFrame::Format_ARGB32_Premultiplied,
|
|
||||||
QVideoFrame::Format_RGB24,
|
|
||||||
QVideoFrame::Format_BGR24,
|
|
||||||
QVideoFrame::Format_RGB32,
|
|
||||||
QVideoFrame::Format_RGB565,
|
|
||||||
QVideoFrame::Format_RGB555,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InputBar::paste(bool fromMouse)
|
InputBar::paste(bool fromMouse)
|
||||||
{
|
{
|
||||||
|
@ -371,7 +324,7 @@ InputBar::message(const QString &msg, MarkdownOverride useMarkdown, bool rainbow
|
||||||
|
|
||||||
QString body;
|
QString body;
|
||||||
bool firstLine = true;
|
bool firstLine = true;
|
||||||
auto lines = related.quoted_body.splitRef(u'\n');
|
auto lines = QStringView(related.quoted_body).split(u'\n');
|
||||||
for (auto line : qAsConst(lines)) {
|
for (auto line : qAsConst(lines)) {
|
||||||
if (firstLine) {
|
if (firstLine) {
|
||||||
firstLine = false;
|
firstLine = false;
|
||||||
|
@ -799,21 +752,22 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
blurhash_ =
|
blurhash_ =
|
||||||
QString::fromStdString(blurhash::encode(data_.data(), img.width(), img.height(), 4, 3));
|
QString::fromStdString(blurhash::encode(data_.data(), img.width(), img.height(), 4, 3));
|
||||||
} else if (mimeClass_ == u"video" || mimeClass_ == u"audio") {
|
} else if (mimeClass_ == u"video" || mimeClass_ == u"audio") {
|
||||||
auto mediaPlayer = new QMediaPlayer(
|
auto mediaPlayer = new QMediaPlayer(this);
|
||||||
this,
|
|
||||||
mimeClass_ == u"video" ? QFlags{QMediaPlayer::VideoSurface} : QMediaPlayer::Flags{});
|
mediaPlayer->setAudioOutput(nullptr);
|
||||||
mediaPlayer->setMuted(true);
|
|
||||||
|
|
||||||
if (mimeClass_ == u"video") {
|
if (mimeClass_ == u"video") {
|
||||||
auto newSurface = new InputVideoSurface(this);
|
auto newSurface = new QVideoSink(this);
|
||||||
connect(
|
connect(
|
||||||
newSurface, &InputVideoSurface::newImage, this, [this, mediaPlayer](QImage img) {
|
newSurface, &QVideoSink::videoFrameChanged, this, [this, mediaPlayer](const QVideoFrame& frame) {
|
||||||
|
QImage img = frame.toImage();
|
||||||
|
|
||||||
if (img.size().isEmpty())
|
if (img.size().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mediaPlayer->stop();
|
mediaPlayer->stop();
|
||||||
|
|
||||||
auto orientation = mediaPlayer->metaData(QMediaMetaData::Orientation).toInt();
|
auto orientation = mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt();
|
||||||
if (orientation == 90 || orientation == 270 || orientation == 180) {
|
if (orientation == 90 || orientation == 270 || orientation == 180) {
|
||||||
img =
|
img =
|
||||||
img.transformed(QTransform().rotate(orientation), Qt::SmoothTransformation);
|
img.transformed(QTransform().rotate(orientation), Qt::SmoothTransformation);
|
||||||
|
@ -844,11 +798,11 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(mediaPlayer,
|
connect(mediaPlayer,
|
||||||
qOverload<QMediaPlayer::Error>(&QMediaPlayer::error),
|
&QMediaPlayer::error,
|
||||||
this,
|
this,
|
||||||
[mediaPlayer](QMediaPlayer::Error error) {
|
[mediaPlayer]() {
|
||||||
nhlog::ui()->debug("Media player error {} and errorStr {}",
|
nhlog::ui()->debug("Media player error {} and errorStr {}",
|
||||||
error,
|
mediaPlayer->error(),
|
||||||
mediaPlayer->errorString().toStdString());
|
mediaPlayer->errorString().toStdString());
|
||||||
});
|
});
|
||||||
connect(mediaPlayer,
|
connect(mediaPlayer,
|
||||||
|
@ -858,18 +812,18 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
"Media player status {} and error {}", status, mediaPlayer->error());
|
"Media player status {} and error {}", status, mediaPlayer->error());
|
||||||
});
|
});
|
||||||
connect(mediaPlayer,
|
connect(mediaPlayer,
|
||||||
qOverload<const QString &, const QVariant &>(&QMediaPlayer::metaDataChanged),
|
&QMediaPlayer::metaDataChanged,
|
||||||
[this, mediaPlayer](QString t, QVariant) {
|
[this, mediaPlayer]() {
|
||||||
nhlog::ui()->debug("Got metadata {}", t.toStdString());
|
nhlog::ui()->debug("Got metadata");
|
||||||
|
|
||||||
if (mediaPlayer->duration() > 0)
|
if (mediaPlayer->duration() > 0)
|
||||||
this->duration_ = mediaPlayer->duration();
|
this->duration_ = mediaPlayer->duration();
|
||||||
|
|
||||||
auto dimensions = mediaPlayer->metaData(QMediaMetaData::Resolution).toSize();
|
auto dimensions = mediaPlayer->metaData().value(QMediaMetaData::Resolution).toSize();
|
||||||
if (!dimensions.isEmpty()) {
|
if (!dimensions.isEmpty()) {
|
||||||
dimensions_ = dimensions;
|
dimensions_ = dimensions;
|
||||||
auto orientation =
|
auto orientation =
|
||||||
mediaPlayer->metaData(QMediaMetaData::Orientation).toInt();
|
mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt();
|
||||||
if (orientation == 90 || orientation == 270) {
|
if (orientation == 90 || orientation == 270) {
|
||||||
dimensions_.transpose();
|
dimensions_.transpose();
|
||||||
}
|
}
|
||||||
|
@ -886,8 +840,8 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
|
|
||||||
auto originalFile = qobject_cast<QFile *>(source.get());
|
auto originalFile = qobject_cast<QFile *>(source.get());
|
||||||
|
|
||||||
mediaPlayer->setMedia(
|
mediaPlayer->setSourceDevice(
|
||||||
QMediaContent(originalFile ? originalFile->fileName() : originalFilename_), source.get());
|
source.get(), QUrl(originalFile ? originalFile->fileName() : originalFilename_) );
|
||||||
|
|
||||||
mediaPlayer->play();
|
mediaPlayer->play();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAbstractVideoSurface>
|
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -32,24 +31,6 @@ enum class MarkdownOverride
|
||||||
OFF,
|
OFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputVideoSurface : public QAbstractVideoSurface
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
InputVideoSurface(QObject *parent)
|
|
||||||
: QAbstractVideoSurface(parent)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool present(const QVideoFrame &frame) override;
|
|
||||||
|
|
||||||
QList<QVideoFrame::PixelFormat>
|
|
||||||
supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const override;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void newImage(QImage img);
|
|
||||||
};
|
|
||||||
|
|
||||||
class MediaUpload : public QObject
|
class MediaUpload : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -272,7 +272,7 @@ TimelineViewManager::saveMedia(QString mxcUrl)
|
||||||
{
|
{
|
||||||
const QString downloadsFolder =
|
const QString downloadsFolder =
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||||
const QString openLocation = downloadsFolder + "/" + mxcUrl.splitRef(u'/').constLast();
|
const QString openLocation = downloadsFolder + "/" + mxcUrl.split(u'/').constLast();
|
||||||
|
|
||||||
const QString filename = QFileDialog::getSaveFileName(nullptr, {}, openLocation);
|
const QString filename = QFileDialog::getSaveFileName(nullptr, {}, openLocation);
|
||||||
|
|
||||||
|
|
|
@ -148,9 +148,9 @@ MxcAnimatedImage::startDownload()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MxcAnimatedImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
|
MxcAnimatedImage::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
|
||||||
{
|
{
|
||||||
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
QQuickItem::geometryChange(newGeometry, oldGeometry);
|
||||||
|
|
||||||
if (newGeometry.size() != oldGeometry.size()) {
|
if (newGeometry.size() != oldGeometry.size()) {
|
||||||
if (height() != 0 && width() != 0)
|
if (height() != 0 && width() != 0)
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
|
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
|
||||||
QSGNode *updatePaintNode(QSGNode *oldNode,
|
QSGNode *updatePaintNode(QSGNode *oldNode,
|
||||||
QQuickItem::UpdatePaintNodeData *updatePaintNodeData) override;
|
QQuickItem::UpdatePaintNodeData *updatePaintNodeData) override;
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,11 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMediaMetaData>
|
#include <QMediaMetaData>
|
||||||
#include <QMediaObject>
|
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#if defined(Q_OS_MACOS)
|
|
||||||
// TODO (red_sky): Remove for Qt6. See other ifdef below
|
|
||||||
#include <QTemporaryFile>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "EventAccessors.h"
|
#include "EventAccessors.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
@ -31,44 +25,27 @@ MxcMediaProxy::MxcMediaProxy(QObject *parent)
|
||||||
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
|
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
|
||||||
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
|
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
|
||||||
connect(this,
|
connect(this,
|
||||||
qOverload<QMediaPlayer::Error>(&MxcMediaProxy::error),
|
&MxcMediaProxy::error,
|
||||||
[this](QMediaPlayer::Error error) {
|
[this]() {
|
||||||
nhlog::ui()->info("Media player error {} and errorStr {}",
|
nhlog::ui()->info("Media player error {} and errorStr {}",
|
||||||
error,
|
error(),
|
||||||
this->errorString().toStdString());
|
this->errorString().toStdString());
|
||||||
});
|
});
|
||||||
connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) {
|
connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) {
|
||||||
nhlog::ui()->info("Media player status {} and error {}", status, this->error());
|
nhlog::ui()->info("Media player status {} and error {}", status, this->error());
|
||||||
});
|
});
|
||||||
connect(this,
|
connect(this,
|
||||||
qOverload<const QString &, const QVariant &>(&MxcMediaProxy::metaDataChanged),
|
&MxcMediaProxy::metaDataChanged,
|
||||||
[this](QString t, QVariant) {
|
[this]() {
|
||||||
if (t == QMediaMetaData::Orientation)
|
emit orientationChanged();
|
||||||
emit orientationChanged();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void
|
|
||||||
MxcMediaProxy::setVideoSurface(QAbstractVideoSurface *surface)
|
|
||||||
{
|
|
||||||
if (surface != m_surface) {
|
|
||||||
qDebug() << "Changing surface";
|
|
||||||
m_surface = surface;
|
|
||||||
setVideoOutput(m_surface);
|
|
||||||
emit videoSurfaceChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractVideoSurface *
|
|
||||||
MxcMediaProxy::getVideoSurface()
|
|
||||||
{
|
|
||||||
return m_surface;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
MxcMediaProxy::orientation() const
|
MxcMediaProxy::orientation() const
|
||||||
{
|
{
|
||||||
nhlog::ui()->debug("metadata: {}", availableMetaData().join(QStringLiteral(",")).toStdString());
|
//nhlog::ui()->debug("metadata: {}", metaData().
|
||||||
auto orientation = metaData(QMediaMetaData::Orientation).toInt();
|
auto orientation = metaData().value(QMediaMetaData::Orientation).toInt();
|
||||||
nhlog::ui()->debug("Video orientation: {}", orientation);
|
nhlog::ui()->debug("Video orientation: {}", orientation);
|
||||||
return orientation;
|
return orientation;
|
||||||
}
|
}
|
||||||
|
@ -129,34 +106,10 @@ MxcMediaProxy::startDownload()
|
||||||
buffer.open(QIODevice::ReadOnly);
|
buffer.open(QIODevice::ReadOnly);
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
|
|
||||||
QTimer::singleShot(0, this, [this, filename, suffix, encryptionInfo] {
|
QTimer::singleShot(0, this, [this, filename] {
|
||||||
#if defined(Q_OS_MACOS)
|
|
||||||
if (encryptionInfo) {
|
|
||||||
// macOS has issues reading from a buffer in setMedia for whatever reason.
|
|
||||||
// Instead, write the buffer to a temporary file and read from that.
|
|
||||||
// This should be fixed in Qt6, so update this when we do that!
|
|
||||||
// TODO: REMOVE IN QT6
|
|
||||||
QTemporaryFile tempFile;
|
|
||||||
tempFile.setFileTemplate(tempFile.fileTemplate() + QLatin1Char('.') + suffix);
|
|
||||||
tempFile.open();
|
|
||||||
tempFile.write(buffer.data());
|
|
||||||
tempFile.close();
|
|
||||||
nhlog::ui()->debug("Playing media from temp buffer file: {}. Remove in QT6!",
|
|
||||||
filename.filePath().toStdString());
|
|
||||||
this->setMedia(QUrl::fromLocalFile(tempFile.fileName()));
|
|
||||||
} else {
|
|
||||||
nhlog::ui()->info(
|
|
||||||
"Playing buffer with size: {}, {}", buffer.bytesAvailable(), buffer.isOpen());
|
|
||||||
this->setMedia(QUrl::fromLocalFile(filename.filePath()));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
Q_UNUSED(suffix)
|
|
||||||
Q_UNUSED(encryptionInfo)
|
|
||||||
|
|
||||||
nhlog::ui()->info(
|
nhlog::ui()->info(
|
||||||
"Playing buffer with size: {}, {}", buffer.bytesAvailable(), buffer.isOpen());
|
"Playing buffer with size: {}, {}", buffer.bytesAvailable(), buffer.isOpen());
|
||||||
this->setMedia(QMediaContent(filename.fileName()), &buffer);
|
this->setSourceDevice( &buffer, QUrl(filename.fileName()));
|
||||||
#endif
|
|
||||||
emit loadedChanged();
|
emit loadedChanged();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAbstractVideoSurface>
|
#include <QVideoSink>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QMediaContent>
|
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include "timeline/TimelineModel.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
|
||||||
class TimelineModel;
|
class TimelineModel;
|
||||||
|
@ -24,8 +24,6 @@ class MxcMediaProxy : public QMediaPlayer
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(TimelineModel *roomm READ room WRITE setRoom NOTIFY roomChanged REQUIRED)
|
Q_PROPERTY(TimelineModel *roomm READ room WRITE setRoom NOTIFY roomChanged REQUIRED)
|
||||||
Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged)
|
Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged)
|
||||||
Q_PROPERTY(QAbstractVideoSurface *videoSurface READ getVideoSurface WRITE setVideoSurface NOTIFY
|
|
||||||
videoSurfaceChanged)
|
|
||||||
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
|
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
|
||||||
Q_PROPERTY(int orientation READ orientation NOTIFY orientationChanged)
|
Q_PROPERTY(int orientation READ orientation NOTIFY orientationChanged)
|
||||||
|
|
||||||
|
@ -45,8 +43,6 @@ public:
|
||||||
room_ = room;
|
room_ = room;
|
||||||
emit roomChanged();
|
emit roomChanged();
|
||||||
}
|
}
|
||||||
void setVideoSurface(QAbstractVideoSurface *surface);
|
|
||||||
QAbstractVideoSurface *getVideoSurface();
|
|
||||||
|
|
||||||
int orientation() const;
|
int orientation() const;
|
||||||
|
|
||||||
|
@ -54,10 +50,9 @@ signals:
|
||||||
void roomChanged();
|
void roomChanged();
|
||||||
void eventIdChanged();
|
void eventIdChanged();
|
||||||
void loadedChanged();
|
void loadedChanged();
|
||||||
void newBuffer(QMediaContent, QIODevice *buf);
|
void newBuffer(QUrl, QIODevice *buf);
|
||||||
|
|
||||||
void orientationChanged();
|
void orientationChanged();
|
||||||
void videoSurfaceChanged();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startDownload();
|
void startDownload();
|
||||||
|
@ -67,5 +62,5 @@ private:
|
||||||
QString eventId_;
|
QString eventId_;
|
||||||
QString filename_;
|
QString filename_;
|
||||||
QBuffer buffer;
|
QBuffer buffer;
|
||||||
QAbstractVideoSurface *m_surface = nullptr;
|
QObject *m_surface = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <QMediaPlaylist>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
|
@ -144,11 +143,11 @@ CallManager::CallManager(QObject *parent)
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(&player_,
|
connect(&player_,
|
||||||
QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error),
|
&QMediaPlayer::error,
|
||||||
this,
|
this,
|
||||||
[this](QMediaPlayer::Error error) {
|
[this]() {
|
||||||
stopRingtone();
|
stopRingtone();
|
||||||
switch (error) {
|
switch (player_.error()) {
|
||||||
case QMediaPlayer::FormatError:
|
case QMediaPlayer::FormatError:
|
||||||
case QMediaPlayer::ResourceError:
|
case QMediaPlayer::ResourceError:
|
||||||
nhlog::ui()->error("WebRTC: valid ringtone file not found");
|
nhlog::ui()->error("WebRTC: valid ringtone file not found");
|
||||||
|
@ -497,19 +496,17 @@ CallManager::retrieveTurnServer()
|
||||||
void
|
void
|
||||||
CallManager::playRingtone(const QUrl &ringtone, bool repeat)
|
CallManager::playRingtone(const QUrl &ringtone, bool repeat)
|
||||||
{
|
{
|
||||||
static QMediaPlaylist playlist;
|
player_.setLoops(repeat ? QMediaPlayer::Infinite :
|
||||||
playlist.clear();
|
1);
|
||||||
playlist.setPlaybackMode(repeat ? QMediaPlaylist::CurrentItemInLoop
|
player_.setSource(ringtone);
|
||||||
: QMediaPlaylist::CurrentItemOnce);
|
//player_.audioOutput()->setVolume(100);
|
||||||
playlist.addMedia(ringtone);
|
player_.play();
|
||||||
player_.setVolume(100);
|
|
||||||
player_.setPlaylist(&playlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CallManager::stopRingtone()
|
CallManager::stopRingtone()
|
||||||
{
|
{
|
||||||
player_.setPlaylist(nullptr);
|
player_.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
|
|
Loading…
Reference in a new issue