From 261dc10a82fadee5df1942340eaa7b101ff9323d Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 19 Jan 2020 23:30:36 -0500 Subject: Added about page and finally music is playing :D --- AleePlayer.pro | 4 ++++ about.cpp | 14 ++++++++++++++ about.h | 22 ++++++++++++++++++++++ about.ui | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ player.cpp | 22 +++++++++++++++++++++- player.h | 6 ++++++ player.ui | 30 ++++++++++++++++++++++-------- 7 files changed, 144 insertions(+), 9 deletions(-) create mode 100644 about.cpp create mode 100644 about.h create mode 100644 about.ui diff --git a/AleePlayer.pro b/AleePlayer.pro index 1b6707b..1e93944 100644 --- a/AleePlayer.pro +++ b/AleePlayer.pro @@ -1,4 +1,5 @@ QT += core gui +QT += multimedia greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @@ -16,13 +17,16 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + about.cpp \ main.cpp \ player.cpp HEADERS += \ + about.h \ player.h FORMS += \ + about.ui \ player.ui TRANSLATIONS += \ diff --git a/about.cpp b/about.cpp new file mode 100644 index 0000000..5bea58a --- /dev/null +++ b/about.cpp @@ -0,0 +1,14 @@ +#include "about.h" +#include "ui_about.h" + +About::About(QWidget *parent) : + QDialog(parent), + ui(new Ui::About) +{ + ui->setupUi(this); +} + +About::~About() +{ + delete ui; +} diff --git a/about.h b/about.h new file mode 100644 index 0000000..a88d2ac --- /dev/null +++ b/about.h @@ -0,0 +1,22 @@ +#ifndef ABOUT_H +#define ABOUT_H + +#include + +namespace Ui { +class About; +} + +class About : public QDialog +{ + Q_OBJECT + +public: + explicit About(QWidget *parent = nullptr); + ~About(); + +private: + Ui::About *ui; +}; + +#endif // ABOUT_H diff --git a/about.ui b/about.ui new file mode 100644 index 0000000..d5737ef --- /dev/null +++ b/about.ui @@ -0,0 +1,55 @@ + + + About + + + + 0 + 0 + 400 + 300 + + + + About + + + + + 90 + 60 + 231 + 18 + + + + + 16 + + + + Licensed with GPL-3.0 + + + + + + 30 + 20 + 351 + 31 + + + + + 16 + + + + AleePlayer 0.1 by Alee Productions + + + + + + diff --git a/player.cpp b/player.cpp index 9513423..6c2a311 100644 --- a/player.cpp +++ b/player.cpp @@ -1,6 +1,9 @@ #include #include "player.h" #include "ui_player.h" +#include "about.h" +#include + Player::Player(QWidget *parent) : QMainWindow(parent) @@ -11,11 +14,28 @@ Player::Player(QWidget *parent) Player::~Player() { + std::cout << "Closing AleePlayer...\n"; + mPlayer->deleteLater(); delete ui; } void Player::on_actionQuit_triggered() { - std::cout << "Closing AleePlayer...\n"; close(); } + +void Player::on_pushButton_pressed() +{ + std::cout << "Playing music...\n"; + mPlayer->setMedia(QUrl::fromLocalFile("/home/andrew/Music/4616-werq-by-kevin-macleod.mp3")); + mPlayer->setVolume(50); + mPlayer->play(); +} + +void Player::on_actionAbout_triggered() +{ + std::cout << "Opening dialog\n"; + About about; + about.setModal(true); + about.exec(); +} diff --git a/player.h b/player.h index 687375f..0879d61 100644 --- a/player.h +++ b/player.h @@ -1,5 +1,6 @@ #ifndef PLAYER_H #define PLAYER_H +#include #include @@ -14,10 +15,15 @@ class Player : public QMainWindow public: Player(QWidget *parent = nullptr); ~Player(); + QMediaPlayer* mPlayer = new QMediaPlayer(); private slots: void on_actionQuit_triggered(); + void on_pushButton_pressed(); + + void on_actionAbout_triggered(); + private: Ui::Player *ui; }; diff --git a/player.ui b/player.ui index d1ce767..f03497e 100644 --- a/player.ui +++ b/player.ui @@ -11,9 +11,23 @@ - Player + AleePlayer - + + + + + 10 + 20 + 88 + 34 + + + + Play Audio + + + @@ -27,15 +41,10 @@ File + - - - About - - - @@ -43,6 +52,11 @@ Quit + + + About + + -- cgit v1.2.3