Add Qt files and first form files

This commit is contained in:
fullgream 2025-02-24 15:32:40 +03:00
parent 69e0975913
commit a8eebdfe52
10 changed files with 354 additions and 0 deletions

2
.gitignore vendored
View File

@ -164,3 +164,5 @@ dist
.yarn/install-state.gz
.pnp.*
# Qt build
build-*

74
src/.gitignore vendored Normal file
View File

@ -0,0 +1,74 @@
# 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*
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

64
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.25)
project("Music Manager" VERSION 0.1 LANGUAGES CXX)
set(PROGRAM_NAME "Music Manager")
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
set(PROJECT_SOURCES
main.cpp
# Main menu
main-window.cpp main-window.h main-window.ui
# Music player
music-player.h music-player.cpp music-player.ui
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(fullgream-music-manager
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET fullgream-music-manager 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
else()
if(ANDROID)
add_library(fullgream-music-manager 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(fullgream-music-manager
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(fullgream-music-manager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
set_target_properties(fullgream-music-manager PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
install(TARGETS fullgream-music-manager
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(fullgream-music-manager)
endif()

15
src/main-window.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "main-window.h"
#include "./ui_main-window.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}

21
src/main-window.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

22
src/main-window.ui Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar"/>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

29
src/main.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "main-window.h"
#include "music-player.h"
#include <QApplication>
#include <iostream>
#include <string>
using std::string;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if (argc > 1) {
string pathToMusic = "";
for (int p = 1; p < argc; p++) {
pathToMusic += argv[p];
pathToMusic += " ";
}
pathToMusic = pathToMusic.substr(0, pathToMusic.length() - 1);
qDebug() << pathToMusic.c_str();
MusicPlayer mp;
mp.show();
return a.exec();
}
else {
MainWindow w;
w.show();
return a.exec();
}
}

14
src/music-player.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "music-player.h"
#include "ui_music-player.h"
MusicPlayer::MusicPlayer(QWidget *parent) :
QWidget(parent),
ui(new Ui::MusicPlayer)
{
ui->setupUi(this);
}
MusicPlayer::~MusicPlayer()
{
delete ui;
}

22
src/music-player.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef MUSICPLAYER_H
#define MUSICPLAYER_H
#include <QWidget>
namespace Ui {
class MusicPlayer;
}
class MusicPlayer : public QWidget
{
Q_OBJECT
public:
explicit MusicPlayer(QWidget *parent = nullptr);
~MusicPlayer();
private:
Ui::MusicPlayer *ui;
};
#endif // MUSICPLAYER_H

91
src/music-player.ui Normal file
View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MusicPlayer</class>
<widget class="QWidget" name="MusicPlayer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>539</width>
<height>132</height>
</rect>
</property>
<property name="windowTitle">
<string>FullGreaM's Music Player</string>
</property>
<widget class="QSlider" name="progress">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>541</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="musicTitle">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>531</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>MusicName.mp3</string>
</property>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>50</y>
<width>541</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pauseOrResume">
<property name="text">
<string>&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="stop">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="trackInfo">
<property name="text">
<string>i</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QCheckBox" name="repeatFlag">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>531</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Repeat</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>