chore: drop windows-specific code

This commit is contained in:
dela
2026-06-10 16:33:50 +08:00
parent 012d165b81
commit 4c783ab9ea
20 changed files with 24 additions and 588 deletions
+1 -16
View File
@@ -637,22 +637,7 @@ bool DownloadManager::openContainingFolder(const QString& recordId) const
<< "| filePath:" << fileInfo.absoluteFilePath()
<< "| directory:" << directory;
#if defined(Q_OS_WIN)
if (fileInfo.exists() && fileInfo.isFile()) {
const bool started = QProcess::startDetached(
QStringLiteral("explorer.exe"),
{QStringLiteral("/select,"),
QDir::toNativeSeparators(fileInfo.absoluteFilePath())});
if (started) {
return true;
}
qWarning() << "[DownloadManager] Failed to launch Explorer with"
" file selection"
<< "| recordId:" << recordId
<< "| filePath:" << fileInfo.absoluteFilePath();
}
#elif defined(Q_OS_MACOS)
#if defined(Q_OS_MACOS)
if (fileInfo.exists() && fileInfo.isFile()) {
const bool started = QProcess::startDetached(
QStringLiteral("open"),
@@ -2,16 +2,10 @@
#include <config/config_keys.h>
#include <config/configstore.h>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QSet>
#include <QStandardPaths>
#ifdef Q_OS_WIN
#include <QSettings>
#endif
QList<DetectedPlayer> ExternalPlayerDetector::detect() {
QList<DetectedPlayer> result;
@@ -27,110 +21,7 @@ QList<DetectedPlayer> ExternalPlayerDetector::detect() {
}
};
#ifdef Q_OS_WIN
auto tryRegistry = [&](const QString &name, const QString &regKey,
const QString &valueName,
const QString &exeName = {}) {
QSettings reg(regKey, QSettings::NativeFormat);
QString val = reg.value(valueName).toString();
if (val.isEmpty())
return;
QString fullPath = val;
if (!exeName.isEmpty() && QFileInfo(val).isDir()) {
fullPath = val + "/" + exeName;
}
if (QFile::exists(fullPath)) {
result.append({name, QDir::toNativeSeparators(fullPath)});
}
};
tryRegistry(
"PotPlayer",
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App "
"Paths\\PotPlayerMini64.exe",
".", "");
if (result.isEmpty() || result.last().name != "PotPlayer") {
tryRegistry("PotPlayer",
"HKEY_LOCAL_MACHINE\\SOFTWARE\\DAUM\\PotPlayer64",
"ProgramFolder", "PotPlayerMini64.exe");
}
tryRegistry("VLC", "HKEY_LOCAL_MACHINE\\SOFTWARE\\VideoLAN\\VLC",
"InstallDir", "vlc.exe");
tryRegistry(
"MPC-HC",
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App "
"Paths\\mpc-hc64.exe",
".", "");
if (result.isEmpty() || result.last().name != "MPC-HC") {
tryRegistry("MPC-HC",
"HKEY_LOCAL_"
"MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App "
"Paths\\mpc-hc.exe",
".", "");
}
tryRegistry(
"MPC-BE",
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App "
"Paths\\mpc-be64.exe",
".", "");
if (result.isEmpty() || result.last().name != "MPC-BE") {
tryRegistry("MPC-BE",
"HKEY_LOCAL_"
"MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App "
"Paths\\mpc-be.exe",
".", "");
}
if (result.isEmpty() || result.last().name != "MPC-BE") {
QStringList beDirs;
for (const auto &drive : QDir::drives()) {
QString d = drive.absolutePath();
beDirs << d + "Program Files/MPC-BE x64" << d + "Program Files/MPC-BE"
<< d + "Program Files (x86)/MPC-BE";
}
tryDetect("MPC-BE", {"mpc-be64.exe", "mpc-be.exe"}, beDirs);
}
{
QString pathMpv = QStandardPaths::findExecutable("mpv.exe");
if (!pathMpv.isEmpty()) {
result.append({"MPV", QDir::toNativeSeparators(pathMpv)});
}
QSet<QString> foundPaths;
if (!pathMpv.isEmpty())
foundPaths.insert(QDir::toNativeSeparators(pathMpv));
for (const auto &drive : QDir::drives()) {
QString d = drive.absolutePath();
QStringList searchRoots = {d + "Program Files",
d + "Program Files (x86)"};
for (const auto &root : searchRoots) {
QDir rootDir(root);
if (!rootDir.exists())
continue;
QStringList mpvDirs = rootDir.entryList({"mpv*"}, QDir::Dirs);
for (const auto &sub : mpvDirs) {
QString exePath = root + "/" + sub + "/mpv.exe";
if (QFile::exists(exePath)) {
QString native = QDir::toNativeSeparators(exePath);
if (!foundPaths.contains(native)) {
foundPaths.insert(native);
QString label = QString("MPV (%1)").arg(sub);
result.append({label, native});
}
}
}
}
}
}
#elif defined(Q_OS_MAC)
#if defined(Q_OS_MAC)
tryDetect("MPV", {"mpv"});
tryDetect("VLC", {"vlc"}, {"/Applications/VLC.app/Contents/MacOS"});
tryDetect("IINA", {"iina"}, {"/Applications/IINA.app/Contents/MacOS"});
+1 -137
View File
@@ -24,13 +24,7 @@ ExternalPlayerIPC* ExternalPlayerIPC::create(PlayerType type, const QString& ipc
return new MpvIPC(ipcEndpoint, parent);
case PlayerType::VLC:
#ifdef Q_OS_WIN
case PlayerType::MPC_HC:
return new MpcSlaveIPC(parent);
#endif
case PlayerType::MPC_BE:
return new EstimationIPC(parent);
default:
return new EstimationIPC(parent);
@@ -293,136 +287,6 @@ void VlcRcIPC::onReadyRead()
}
#ifdef Q_OS_WIN
#include <Windows.h>
namespace MpcCmd {
constexpr DWORD CMD_CURRENTPOSITION = 0x50000007;
constexpr DWORD CMD_NOWPLAYING = 0x50000003;
constexpr DWORD CMD_PLAYMODE = 0x50000004;
constexpr DWORD CMD_NOTIFYSEEK = 0x50000008;
constexpr DWORD CMD_NOTIFYENDSTREAM = 0x50000009;
constexpr DWORD CMD_GETCURRENTPOSITION = 0xA0003004;
}
MpcSlaveWindow::MpcSlaveWindow(QWidget* parent)
: QWidget(parent)
{
setFixedSize(1, 1);
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
setAttribute(Qt::WA_ShowWithoutActivating);
winId();
}
bool MpcSlaveWindow::nativeEvent(const QByteArray& eventType, void* message, qintptr* result)
{
if (eventType == "windows_generic_MSG") {
MSG* msg = static_cast<MSG*>(message);
if (msg->message == WM_COPYDATA) {
COPYDATASTRUCT* cds = reinterpret_cast<COPYDATASTRUCT*>(msg->lParam);
if (!cds) return false;
QString data = QString::fromWCharArray(
reinterpret_cast<const wchar_t*>(cds->lpData),
cds->cbData / sizeof(wchar_t));
if (data.endsWith(QChar('\0')))
data.chop(1);
switch (cds->dwData) {
case MpcCmd::CMD_CURRENTPOSITION:
case MpcCmd::CMD_NOTIFYSEEK: {
bool ok;
double seconds = data.toDouble(&ok);
if (!ok) {
QStringList parts = data.split(':');
if (parts.size() == 3) {
seconds = parts[0].toDouble() * 3600 + parts[1].toDouble() * 60 + parts[2].toDouble();
ok = true;
}
}
if (ok && seconds >= 0.0) {
long long posMs = static_cast<long long>(seconds * 1000);
Q_EMIT positionReceived(posMs);
}
if (result) *result = 1;
return true;
}
case MpcCmd::CMD_NOTIFYENDSTREAM:
Q_EMIT playbackEnded();
if (result) *result = 1;
return true;
default:
break;
}
}
}
return QWidget::nativeEvent(eventType, message, result);
}
MpcSlaveIPC::MpcSlaveIPC(QObject* parent)
: ExternalPlayerIPC(parent)
{
}
MpcSlaveIPC::~MpcSlaveIPC()
{
stop();
}
void MpcSlaveIPC::start(long long startPositionTicks)
{
m_lastPositionTicks = startPositionTicks;
m_window = new MpcSlaveWindow();
connect(m_window, &MpcSlaveWindow::positionReceived, this, [this](long long posMs) {
m_lastPositionTicks = posMs * 10000LL;
Q_EMIT positionUpdated(m_lastPositionTicks);
});
}
void MpcSlaveIPC::stop()
{
if (m_window) {
m_window->deleteLater();
m_window = nullptr;
}
}
long long MpcSlaveIPC::currentPositionTicks() const
{
return m_lastPositionTicks;
}
QString MpcSlaveIPC::hwndString() const
{
if (m_window)
return QString::number(static_cast<quintptr>(m_window->winId()));
return {};
}
#endif
EstimationIPC::EstimationIPC(QObject* parent)
: ExternalPlayerIPC(parent)
{
-47
View File
@@ -15,9 +15,6 @@ enum class PlayerType {
MPV,
IINA,
VLC,
PotPlayer,
MPC_HC,
MPC_BE,
MPC_Qt,
Unknown
};
@@ -120,50 +117,6 @@ private:
#ifdef Q_OS_WIN
#include <QWidget>
class MpcSlaveWindow : public QWidget
{
Q_OBJECT
public:
explicit MpcSlaveWindow(QWidget* parent = nullptr);
signals:
void positionReceived(long long positionMs);
void playbackEnded();
protected:
bool nativeEvent(const QByteArray& eventType, void* message, qintptr* result) override;
};
class MpcSlaveIPC : public ExternalPlayerIPC
{
Q_OBJECT
public:
explicit MpcSlaveIPC(QObject* parent = nullptr);
~MpcSlaveIPC() override;
void start(long long startPositionTicks) override;
void stop() override;
long long currentPositionTicks() const override;
bool isPrecise() const override { return true; }
QString hwndString() const;
private:
MpcSlaveWindow* m_window = nullptr;
long long m_lastPositionTicks = 0;
};
#endif
class EstimationIPC : public ExternalPlayerIPC
{
Q_OBJECT
-43
View File
@@ -151,14 +151,8 @@ PlayerType PlaybackManager::identifyPlayerType(const QString& playerPath)
{
QString baseName = QFileInfo(playerPath).baseName().toLower();
if (baseName.contains("potplayer"))
return PlayerType::PotPlayer;
if (baseName == "vlc")
return PlayerType::VLC;
if (baseName.contains("mpc-hc") || baseName == "mpc-hc64")
return PlayerType::MPC_HC;
if (baseName.contains("mpc-be") || baseName == "mpc-be64")
return PlayerType::MPC_BE;
if (baseName == "mpv")
return PlayerType::MPV;
if (baseName == "iina")
@@ -217,11 +211,7 @@ QString PlaybackManager::generateIpcEndpoint(PlayerType type)
switch (type) {
case PlayerType::MPV:
case PlayerType::IINA:
#ifdef Q_OS_WIN
return QString("\\\\.\\pipe\\qemby-mpv-%1").arg(pid);
#else
return QString("/tmp/qemby-mpv-%1.sock").arg(pid);
#endif
case PlayerType::VLC: {
int port = 42900 + static_cast<int>(pid % 1000);
@@ -282,12 +272,6 @@ QStringList PlaybackManager::buildPlayerArgs(PlayerType type,
args << "--mpv-sid=no";
break;
case PlayerType::PotPlayer:
if (startPositionTicks > 0)
args << QString("/seek=%1").arg(timeStr);
break;
case PlayerType::VLC:
if (startPositionTicks > 0)
args << QString("--start-time=%1").arg(static_cast<int>(seconds));
@@ -297,16 +281,6 @@ QStringList PlaybackManager::buildPlayerArgs(PlayerType type,
args << QString("--sub-track=%1").arg(relSub);
break;
case PlayerType::MPC_HC:
if (startPositionTicks > 0)
args << "/startpos" << timeStr;
break;
case PlayerType::MPC_BE:
if (startPositionTicks > 0)
args << "/startpos" << timeStr;
break;
default:
break;
}
@@ -543,9 +517,6 @@ void PlaybackManager::launchExternalPlayer(const QString& mediaId, const QString
if (isLocalPath) {
qDebug() << "[PlaybackManager] Detected local path, adapting format...";
#ifdef Q_OS_WIN
actualStreamUrl.replace('/', '\\');
#endif
switch (playerType) {
case PlayerType::MPV:
case PlayerType::IINA:
@@ -570,20 +541,6 @@ void PlaybackManager::launchExternalPlayer(const QString& mediaId, const QString
m_currentMediaId = mediaId;
m_currentMediaSourceId = mediaSourceId;
#ifdef Q_OS_WIN
if (playerType == PlayerType::MPC_HC) {
auto* mpcIpc = new MpcSlaveIPC(this);
mpcIpc->start(startPositionTicks);
QString hwnd = mpcIpc->hwndString();
if (!hwnd.isEmpty()) {
args.insert(args.size() - 1, "/slave");
args.insert(args.size() - 1, hwnd);
}
m_ipc = mpcIpc;
} else
#endif
{
m_ipc = ExternalPlayerIPC::create(playerType, ipcEndpoint, this);
m_ipc->start(startPositionTicks);
-8
View File
@@ -12,7 +12,6 @@
#include <QPalette>
#include <QPixmap>
#include <QPainter>
#include <QSettings>
#include <QProcess>
#include <QRegularExpression>
#include "config/configstore.h"
@@ -162,13 +161,6 @@ ThemeManager::Theme ThemeManager::detectSystemTheme()
auto scheme = QGuiApplication::styleHints()->colorScheme();
return (scheme == Qt::ColorScheme::Light) ? Light : Dark;
#elif defined(Q_OS_WIN)
QSettings reg("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
QSettings::NativeFormat);
QVariant val = reg.value("AppsUseLightTheme", 0);
return val.toInt() == 1 ? Light : Dark;
#elif defined(Q_OS_MACOS)