Initial commit

This commit is contained in:
Dark Steveneq
2025-10-10 21:19:26 +02:00
commit a4dfc5b9bc
19 changed files with 495 additions and 0 deletions

1
.gitignore vendored Executable file
View File

@@ -0,0 +1 @@
.direnv

3
.vscode/settings.json vendored Executable file
View File

@@ -0,0 +1,3 @@
{
"cmake.sourceDirectory": "/home/dark/qyouradio/qyouradio"
}

41
build.nix Executable file
View File

@@ -0,0 +1,41 @@
{ stdenv
, lib
, clang
, qtbase
, qtdeclarative
, qtmultimedia
, qtlocation
, qtwebview
, qtwayland
, libglvnd
, cmake
, wrapQtAppsHook
}:
stdenv.mkDerivation {
pname = "qyouradio";
version = "1.0";
src = ./qyouradio;
buildInputs = [
qtbase
qtdeclarative
qtlocation
qtmultimedia
qtwebview
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
qtwayland
libglvnd
];
nativeBuildInputs = [
clang
cmake
wrapQtAppsHook
];
installPhase = ''
mkdir -p $out/bin
cp qyouradio $out/bin/
'';
}

60
flake.lock generated Executable file
View File

@@ -0,0 +1,60 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1759362264,
"narHash": "sha256-wfG0S7pltlYyZTM+qqlhJ7GMw2fTF4mLKCIVhLii/4M=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "758cf7296bee11f1706a574c77d072b8a7baa881",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1760036653,
"narHash": "sha256-FJOwW7YMxtnMi3R+MxwiVsUsrOtm3ubIBo8Jdc1nH6w=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b6bae5b8d26ef00d8df42206ac24d0665640286b",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1754788789,
"narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "a73b9c743612e4244d865a2fdee11865283c04e6",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

33
flake.nix Executable file
View File

@@ -0,0 +1,33 @@
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:nixos/nixpkgs";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "aarch64-linux" "x86_64-linux" ];
perSystem = { config, pkgs, ... }: {
packages.default = pkgs.qt6Packages.callPackage ./build.nix { };
devShells.default = pkgs.mkShell {
inputsFrom = [ config.packages.default ];
buildInputs = with pkgs; [
gdb
qtcreator
qt6.qttools
# this is for the shellhook portion
qt6.wrapQtAppsHook
makeWrapper
bashInteractive
];
# set the environment variables that unpatched Qt apps expect
shellHook = ''
bashdir=$(mktemp -d)
makeWrapper "$(type -p bash)" "$bashdir/bash" "''${qtWrapperArgs[@]}"
exec "$bashdir/bash"
'';
};
};
};
}

82
qyouradio/.gitignore vendored Executable file
View File

@@ -0,0 +1,82 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
*.qbs.user*
CMakeLists.txt.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
# Directories with generated files
.moc/
.obj/
.pch/
.rcc/
.uic/
/build*/

84
qyouradio/CMakeLists.txt Executable file
View File

@@ -0,0 +1,84 @@
cmake_minimum_required(VERSION 3.16)
project(qyouradio VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
FUNCTION(PREPEND var )
SET(listVar "")
FOREACH(f ${${var}})
LIST(APPEND listVar "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
ENDFOREACH(f)
SET(${var} "${listVar}" PARENT_SCOPE)
ENDFUNCTION()
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick LinguistTools)
add_subdirectory(locale/)
add_subdirectory(src/)
set(PROJECT_SOURCES
${CXX_FILES}
${QML_FILES}
${TS_FILES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(qyouradio
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET qyouradio APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR}/locale ${TS_FILES})
else()
if(ANDROID)
add_library(qyouradio SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(qyouradio
${PROJECT_SOURCES}
)
endif()
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR}/locale ${TS_FILES})
endif()
target_link_libraries(qyouradio
PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER xyz.nonmesoft.qyouradio)
endif()
set_target_properties(qyouradio PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
include(GNUInstallDirs)
install(TARGETS qyouradio
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_import_qml_plugins(qyouradio)
qt_finalize_executable(qyouradio)
endif()

View File

@@ -0,0 +1,7 @@
set(TS_FILES
qyouradio_en_US.ts
qyouradio_pl_PL.ts
)
PREPEND(TS_FILES)
set(TS_FILES ${TS_FILES} PARENT_SCOPE)

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US"></TS>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="pl_PL"></TS>

View File

@@ -0,0 +1,8 @@
add_subdirectory(qml)
set(QML_FILES ${QML_FILES} PARENT_SCOPE)
set(CXX_FILES
main.cpp
)
PREPEND(CXX_FILES)
set(CXX_FILES ${CXX_FILES} PARENT_SCOPE)

34
qyouradio/src/main.cpp Executable file
View File

@@ -0,0 +1,34 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QLocale>
#include <QTranslator>
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "qyouradio_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
app.installTranslator(&translator);
break;
}
}
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
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();
}

View File

@@ -0,0 +1,9 @@
set(QML_FILES
qml.qrc
# main.qml
components/qml.qrc
# components/Button.qml
)
PREPEND(QML_FILES)
set(QML_FILES ${QML_FILES} PARENT_SCOPE)

View File

@@ -0,0 +1,18 @@
import QtQuick 2.15
import QtQuick.Controls 2.15 as QC
QC.Button {
highlighted: true
background: Rectangle {
color: hovered ? "#0056b3" : "#007bff"
radius: 5
}
implicitHeight: 36
Component.onCompleted: {
contentItem.color = "#f4f4f4";
font.family = "Arial";
font.pointSize = 12;
}
}

View File

@@ -0,0 +1,13 @@
import QtQuick 2.15
import QtQuick.Controls 2.155 as QC
QC.CheckBox {
implicitWidth: 14
implicitHeight: 14
contentItem: Rectangle {
radius: 2
color: parent.checked ? (parent.hovered ? "#0056b3" : "#007bff") : "#ffffff"
border.color: parent.checked ? (parent.hovered ? "#0056b3" : "#007bff") : "#ffffff"
border.width: 1
}
}

View File

@@ -0,0 +1,62 @@
import QtQuick 2.15
import QtQuick.Controls 2.15 as QC
QC.Slider {
from: 0.0
value: 0.5
stepSize: 0.1
to: 1.1
snapMode: Slider.SnapAlways
implicitWidth: 130
implicitHeight: 20
background: Rectangle {
color: "#555"
radius: 5
// OpacityAnimator on opacity {
// from: 0.7
// to: 1
// duration: 200
// target: parent
// running: parent.hovered
// }
// OpacityAnimator on opacity {
// from: 1
// to: 0.7
// duration: 200
// target: parent
// running: !parent.parent.hovered
// }
}
handle: Rectangle {
x: parent.leftPadding + parent.visualPosition * (parent.availableWidth - width)
y: parent.topPadding + parent.availableHeight / 2 - height / 2
width: 20
height: 20
radius: 10
color: "#007bff"
OpacityAnimator on opacity{
from: 0.7
to: 1
duration: 200
target: parent
running: parent.hovered
}
OpacityAnimator on opacity{
from: 1
to: 0.7
duration: 200
target: parent
running: !parent.hovered
}
}
onMoved: function() {
value = Math.max(value, 0.1);
}
}

View File

@@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/components">
<file>Button.qml</file>
<file>CheckBox.qml</file>
<file>Slider.qml</file>
</qresource>
</RCC>

22
qyouradio/src/qml/main.qml Executable file
View File

@@ -0,0 +1,22 @@
import QtQuick 2.15
import QtQuick.Window 2.15
import "components/"
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Button {
text: qsTr("Play")
}
CheckBox {
}
Slider {
}
}

5
qyouradio/src/qml/qml.qrc Executable file
View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>