mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
Add inlineMedia parameter to OSC 1337 File= to support audio files
This commit is contained in:
committed by
Kurt Hindenburg
parent
3f3bfa7114
commit
752a8b2f81
@@ -67,6 +67,7 @@ ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX KONSOLEPRIVATE
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED
|
||||
Core
|
||||
DBus
|
||||
Multimedia
|
||||
PrintSupport
|
||||
Widgets
|
||||
)
|
||||
|
||||
@@ -62,6 +62,7 @@ qt_add_dbus_adaptor(
|
||||
|
||||
set(konsole_LIBS
|
||||
KF5::XmlGui
|
||||
Qt::Multimedia
|
||||
Qt::PrintSupport
|
||||
Qt::Xml
|
||||
KF5::Notifications
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// Qt
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTimer>
|
||||
#include <QtEndian>
|
||||
|
||||
@@ -68,6 +69,7 @@ Vt102Emulation::Vt102Emulation()
|
||||
, _pendingSessionAttributesUpdates(QHash<int, QString>())
|
||||
, _sessionAttributesUpdateTimer(new QTimer(this))
|
||||
, _reportFocusEvents(false)
|
||||
, player(nullptr)
|
||||
{
|
||||
_sessionAttributesUpdateTimer->setSingleShot(true);
|
||||
QObject::connect(_sessionAttributesUpdateTimer, &QTimer::timeout, this, &Konsole::Vt102Emulation::updateSessionAttributes);
|
||||
@@ -1151,6 +1153,7 @@ void Vt102Emulation::processSessionAttributeRequest(const int tokenSize, const u
|
||||
|
||||
if (attribute == Image) {
|
||||
bool inlineImage = false;
|
||||
bool inlineMedia = false;
|
||||
if (value.startsWith(QLatin1String("ReportCellSize"))) {
|
||||
iTermReportCellSize();
|
||||
return;
|
||||
@@ -1172,6 +1175,9 @@ void Vt102Emulation::processSessionAttributeRequest(const int tokenSize, const u
|
||||
if (var == QLatin1String("inline")) {
|
||||
inlineImage = val == QLatin1String("1");
|
||||
}
|
||||
if (var == QLatin1String("inlineMedia")) {
|
||||
inlineMedia = val == QLatin1String("1");
|
||||
}
|
||||
if (var == QLatin1String("preserveAspectRatio")) {
|
||||
keepAspect = val == QLatin1String("0");
|
||||
}
|
||||
@@ -1202,7 +1208,21 @@ void Vt102Emulation::processSessionAttributeRequest(const int tokenSize, const u
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inlineMedia) {
|
||||
QTemporaryFile file;
|
||||
file.open();
|
||||
file.write(tokenData);
|
||||
if (player == nullptr) {
|
||||
player = new QMediaPlayer(this);
|
||||
connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(deletePlayer(QMediaPlayer::MediaStatus)));
|
||||
}
|
||||
player->setMedia(QUrl::fromLocalFile(file.fileName()));
|
||||
player->play();
|
||||
return;
|
||||
}
|
||||
if (!inlineImage) {
|
||||
return;
|
||||
}
|
||||
QPixmap pixmap;
|
||||
pixmap.loadFromData(tokenData);
|
||||
tokenData.clear();
|
||||
@@ -1225,6 +1245,14 @@ void Vt102Emulation::processSessionAttributeRequest(const int tokenSize, const u
|
||||
_sessionAttributesUpdateTimer->start(20);
|
||||
}
|
||||
|
||||
void Vt102Emulation::deletePlayer(QMediaPlayer::MediaStatus mediaStatus)
|
||||
{
|
||||
if (mediaStatus == QMediaPlayer::EndOfMedia || mediaStatus == QMediaPlayer::InvalidMedia) {
|
||||
player->deleteLater();
|
||||
player = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Vt102Emulation::updateSessionAttributes()
|
||||
{
|
||||
QListIterator<int> iter(_pendingSessionAttributesUpdates.keys());
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
// Qt
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QMediaPlayer>
|
||||
#include <QPair>
|
||||
#include <QVector>
|
||||
|
||||
@@ -97,6 +98,7 @@ private Q_SLOTS:
|
||||
// pair in _pendingSessionAttributesUpdates.
|
||||
// Used to buffer multiple attribute updates in the current session
|
||||
void updateSessionAttributes();
|
||||
void deletePlayer(QMediaPlayer::MediaStatus);
|
||||
|
||||
private:
|
||||
unsigned int applyCharset(uint c);
|
||||
@@ -310,6 +312,8 @@ private:
|
||||
QHash<int, QPixmap> _graphicsImages;
|
||||
// For kitty graphics protocol - image cache
|
||||
int getFreeGraphicsImageId();
|
||||
|
||||
QMediaPlayer *player;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user