Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PinVolQt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
29 changes: 29 additions & 0 deletions PinVolQt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.14)
project(PinVolQt LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 REQUIRED COMPONENTS Core Quick Multimedia Widgets)

qt_standard_project_setup()

qt_add_executable(PinVolQt
src/main.cpp
src/volumemanager.cpp src/volumemanager.h
)

qt_add_qml_module(PinVolQt
URI PinVolQt
VERSION 1.0
QML_FILES
qml/main.qml
)

target_link_libraries(PinVolQt PRIVATE Qt6::Core Qt6::Quick Qt6::Multimedia Qt6::Widgets)

install(TARGETS PinVolQt
BUNDLE DESTINATION .
RUNTIME DESTINATION bin
)
26 changes: 26 additions & 0 deletions PinVolQt/qml/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import PinVolQt 1.0

ApplicationWindow {
width: 400
height: 300
visible: true
title: qsTr("PinVolQt")

Column {
anchors.centerIn: parent
spacing: 20
Slider {
id: volumeSlider
from: 0
to: 100
value: VolumeManager.volume
onValueChanged: VolumeManager.volume = value
}
Text {
text: qsTr("Volume: %1").arg(Math.round(VolumeManager.volume))
font.pointSize: 20
}
}
}
20 changes: 20 additions & 0 deletions PinVolQt/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "volumemanager.h"

int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
qmlRegisterSingletonInstance("PinVolQt", 1, 0, "VolumeManager", &VolumeManager::instance());

QQmlApplicationEngine engine;
const QUrl url(u"qrc:/qml/main.qml"_qs);
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);

return app.exec();
}
26 changes: 26 additions & 0 deletions PinVolQt/src/volumemanager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "volumemanager.h"
#include <QAudio>
#ifdef Q_OS_WIN
#include <windows.h>
#endif

VolumeManager &VolumeManager::instance()
{
static VolumeManager mgr;
return mgr;
}

VolumeManager::VolumeManager(QObject *parent)
: QObject(parent)
{
}

void VolumeManager::setVolume(int vol)
{
vol = qBound(0, vol, 100);
if (m_volume == vol)
return;
m_volume = vol;
// TODO: integrate with platform-specific volume APIs or Qt Multimedia
emit volumeChanged(m_volume);
}
24 changes: 24 additions & 0 deletions PinVolQt/src/volumemanager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef VOLUMEMANAGER_H
#define VOLUMEMANAGER_H

#include <QObject>

class VolumeManager : public QObject
{
Q_OBJECT
Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
public:
static VolumeManager &instance();

int volume() const { return m_volume; }
void setVolume(int vol);

signals:
void volumeChanged(int volume);

private:
explicit VolumeManager(QObject *parent = nullptr);
int m_volume = 50;
};

#endif // VOLUMEMANAGER_H
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,35 @@ that are useful in a pin cab environment:
title of each game it launches, which lets PinVol display the
friendly game title instead of just the filename.


## Cross-platform Qt version

The repository now contains an experimental Qt/QML port in the `PinVolQt`
subdirectory. This version aims to run on Windows, macOS and Linux.

### Build instructions

1. Install Qt 6 and CMake 3.14 or newer.
2. Create a build directory and run CMake:

```bash
cd PinVolQt
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
```
3. The resulting binary will be placed in `build` (or `build/bin` on
Windows).

### Running

Execute the `PinVolQt` binary. The application displays a simple window
with a volume slider. Background operation is provided via the system
tray when supported by the platform. On macOS and Linux you may need to
explicitly allow the application to show the tray icon.

### Background mode

To run in the background, minimize the main window. On platforms that
support a system tray, the application will remain accessible from the
tray icon. Ensure your desktop environment allows tray icons for the app
so volume hotkeys remain active.