remove dbus stuff
This commit is contained in:
parent
ccbef3b3e8
commit
6879a69ca1
@ -18,10 +18,6 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QtWebSockets/QWebSocket>
|
#include <QtWebSockets/QWebSocket>
|
||||||
#include <QDBusInterface>
|
|
||||||
#include <QDBusConnection>
|
|
||||||
#include <QDBusReply>
|
|
||||||
#include <QDBusMessage>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "autoapp/UI/MainWindow.hpp"
|
#include "autoapp/UI/MainWindow.hpp"
|
||||||
@ -89,75 +85,6 @@ namespace autoapp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoapp::ui::MainWindow::updateBtNowPlaying()
|
|
||||||
{
|
|
||||||
QDBusInterface manager(
|
|
||||||
"org.bluez",
|
|
||||||
"/",
|
|
||||||
"org.freedesktop.DBus.ObjectManager",
|
|
||||||
QDBusConnection::systemBus());
|
|
||||||
|
|
||||||
if (!manager.isValid())
|
|
||||||
{
|
|
||||||
qDebug() << "Failed to connect to BlueZ D-Bus";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDBusReply<QVariantMap> reply = manager.call("GetManagedObjects");
|
|
||||||
|
|
||||||
if (!reply.isValid())
|
|
||||||
{
|
|
||||||
qDebug() << "D-Bus call failed:" << reply.error().message();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap allObjects = reply.value();
|
|
||||||
|
|
||||||
for (auto it = allObjects.begin(); it != allObjects.end(); ++it)
|
|
||||||
{
|
|
||||||
QString path = it.key();
|
|
||||||
QVariantMap interfaces = it.value().toMap();
|
|
||||||
|
|
||||||
if (interfaces.contains("org.bluez.MediaPlayer1"))
|
|
||||||
{
|
|
||||||
qDebug() << "Found MediaPlayer at:" << path;
|
|
||||||
|
|
||||||
QDBusInterface mediaPlayer(
|
|
||||||
"org.bluez",
|
|
||||||
path,
|
|
||||||
"org.freedesktop.DBus.Properties",
|
|
||||||
QDBusConnection::systemBus());
|
|
||||||
|
|
||||||
QDBusReply<QVariant> trackReply = mediaPlayer.call("Get", "org.bluez.MediaPlayer1", "Track");
|
|
||||||
if (trackReply.isValid())
|
|
||||||
{
|
|
||||||
QVariantMap track = trackReply.value().toMap();
|
|
||||||
QString artist = track["Artist"].toString();
|
|
||||||
QString title = track["Title"].toString();
|
|
||||||
QString album = track["Album"].toString();
|
|
||||||
|
|
||||||
QString status = statusReply.value().toString();
|
|
||||||
|
|
||||||
qDebug() << "Now playing:" << artist << "-" << title << "from" << album;
|
|
||||||
qDebug() << "Status:" << status;
|
|
||||||
|
|
||||||
if (status == "Playing")
|
|
||||||
{
|
|
||||||
//ui_->stackedWidget->setCurrentIndex(0);
|
|
||||||
//ui_->btSongName->setText(title);
|
|
||||||
//ui_->btArtistName->setText(artist);
|
|
||||||
//ui_->btAlbumName->setText(album);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//ui_->stackedWidget->setCurrentIndex(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void autoapp::ui::MainWindow::connectWebSocket()
|
void autoapp::ui::MainWindow::connectWebSocket()
|
||||||
{
|
{
|
||||||
QUrl url(QStringLiteral("ws://127.0.0.1:5000")); // Change to your real server
|
QUrl url(QStringLiteral("ws://127.0.0.1:5000")); // Change to your real server
|
||||||
@ -169,4 +96,4 @@ void autoapp::ui::MainWindow::handleIncomingMessage(const QString &message)
|
|||||||
{
|
{
|
||||||
// Your custom message processing logic here
|
// Your custom message processing logic here
|
||||||
qDebug() << "[Handler] Processing message:" << message;
|
qDebug() << "[Handler] Processing message:" << message;
|
||||||
}
|
}
|
@ -439,7 +439,7 @@ color: rgb(238, 238, 236);</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButtonExit">
|
<widget class="QPushButton" name="pushButtonExit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Exit</string>
|
<string>1. Exit</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -449,7 +449,7 @@ color: rgb(238, 238, 236);</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButtonSettings">
|
<widget class="QPushButton" name="pushButtonSettings">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Settings</string>
|
<string>2. Settings</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -462,7 +462,7 @@ color: rgb(238, 238, 236);</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButtonWirelessConnection">
|
<widget class="QPushButton" name="pushButtonWirelessConnection">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Wireless connection</string>
|
<string>3. Wireless connection</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -475,7 +475,7 @@ color: rgb(238, 238, 236);</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButtonToggleCursor">
|
<widget class="QPushButton" name="pushButtonToggleCursor">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Toggle cursor</string>
|
<string>4. Toggle cursor</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
@ -48,7 +48,6 @@ namespace autoapp
|
|||||||
private slots:
|
private slots:
|
||||||
void connectWebSocket();
|
void connectWebSocket();
|
||||||
void handleIncomingMessage(const QString &message);
|
void handleIncomingMessage(const QString &message);
|
||||||
void updateBtNowPlaying();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui_;
|
Ui::MainWindow *ui_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user