aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-01-20 17:43:02 -0500
committerAndrew Lee <alee14498@protonmail.com>2020-01-20 17:43:02 -0500
commitc48008443870d54c28f721ce4db373c6030e8720 (patch)
treef2d8a27e096ddea109132f41f8d0659713a76895
parenta8e0d6dea2da5b59d7404a3581a2e96acc747b2a (diff)
downloaderable-godot-c48008443870d54c28f721ce4db373c6030e8720.tar.gz
erable-godot-c48008443870d54c28f721ce4db373c6030e8720.tar.bz2
erable-godot-c48008443870d54c28f721ce4db373c6030e8720.zip
Toggleable pause/play button and license
-rw-r--r--.gitignore2
-rw-r--r--about.ui19
-rw-r--r--player.cpp48
-rw-r--r--player.h4
-rw-r--r--player.ui35
5 files changed, 48 insertions, 60 deletions
diff --git a/.gitignore b/.gitignore
index f147edf..c74505c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,3 +50,5 @@ compile_commands.json
# QtCreator local machine specific files for imported projects
*creator.user*
+
+build
diff --git a/about.ui b/about.ui
index 76acb4b..baad897 100644
--- a/about.ui
+++ b/about.ui
@@ -10,9 +10,24 @@
<height>391</height>
</rect>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>516</width>
+ <height>391</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>516</width>
+ <height>391</height>
+ </size>
+ </property>
<property name="windowTitle">
<string>About</string>
</property>
+ <property name="modal">
+ <bool>false</bool>
+ </property>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
@@ -49,7 +64,7 @@
<string>AleePlayer 0.1 by Alee Productions</string>
</property>
</widget>
- <widget class="QTextEdit" name="textEdit">
+ <widget class="QTextEdit" name="licenseText">
<property name="geometry">
<rect>
<x>20</x>
@@ -68,7 +83,7 @@ p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans';&quot;&gt; AleePlayer: Music player in Qt &lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans';&quot;&gt; Copyright (C) 2020 Alee Productions&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans';&quot;&gt; Copyright (C) 2020 Alee Productions&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans';&quot;&gt; This program is free software: you can redistribute it and/or modify&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans';&quot;&gt; it under the terms of the GNU General Public License as published by&lt;/span&gt;&lt;/p&gt;
diff --git a/player.cpp b/player.cpp
index 0b8d451..c1fa2ec 100644
--- a/player.cpp
+++ b/player.cpp
@@ -29,37 +29,36 @@ void Player::on_actionQuit_triggered()
void Player::on_playButton_pressed()
{
- QPushButton mPlay;
-
- qDebug() << "Playing music...";
-
- mPlayer->play();
+ if (mPlayer->state() == mPlayer->PlayingState) {
+ qDebug() << "Pausing music...";
+ mPlayer->pause();
+ } else {
+ qDebug() << "Playing music...";
+ mPlayer->play();
+ }
}
void Player::on_actionAbout_triggered()
{
qDebug() << "Opening dialog";
About about;
- about.setModal(true);
about.exec();
}
-void Player::on_pauseButton_pressed()
-{
- qDebug() << "Pausing music...";
- mPlayer->pause();
-}
-
-
-void Player::on_pushButton_pressed()
+void Player::on_mediaButton_pressed()
{
QString mFile;
QMessageBox msgbox;
mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3)"));
- mPlayer->setMedia(QUrl::fromLocalFile(mFile));
- qDebug() << "Opening" << mFile;
- msgbox.setText("This audio file has been loaded.");
- msgbox.exec();
+ if (mFile == NULL) {
+ msgbox.setText("File is invalid.");
+ return;
+ } else {
+ mPlayer->setMedia(QUrl::fromLocalFile(mFile));
+ qDebug() << "Opening" << mFile;
+ msgbox.setText("This audio file has been loaded.");
+ msgbox.exec();
+ }
}
void Player::on_actionOpen_triggered()
@@ -67,8 +66,13 @@ void Player::on_actionOpen_triggered()
QString mFile;
QMessageBox msgbox;
mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3)"));
- mPlayer->setMedia(QUrl::fromLocalFile(mFile));
- qDebug() << "Opening" << mFile;
- msgbox.setText("This audio file has been loaded.");
- msgbox.exec();
+ if (mFile == NULL) {
+ msgbox.setText("File is invalid.");
+ return;
+ } else {
+ mPlayer->setMedia(QUrl::fromLocalFile(mFile));
+ qDebug() << "Opening" << mFile;
+ msgbox.setText("This audio file has been loaded.");
+ msgbox.exec();
+ }
}
diff --git a/player.h b/player.h
index 26a8377..d9d6f6a 100644
--- a/player.h
+++ b/player.h
@@ -24,9 +24,7 @@ private slots:
void on_actionAbout_triggered();
- void on_pauseButton_pressed();
-
- void on_pushButton_pressed();
+ void on_mediaButton_pressed();
void on_actionOpen_triggered();
diff --git a/player.ui b/player.ui
index 902e4a4..8c50a77 100644
--- a/player.ui
+++ b/player.ui
@@ -24,7 +24,7 @@
</rect>
</property>
<property name="text">
- <string>Play Audio</string>
+ <string>Play/Pause</string>
</property>
<property name="checkable">
<bool>false</bool>
@@ -33,7 +33,7 @@
<bool>false</bool>
</property>
</widget>
- <widget class="QPushButton" name="pauseButton">
+ <widget class="QPushButton" name="mediaButton">
<property name="geometry">
<rect>
<x>130</x>
@@ -43,40 +43,9 @@
</rect>
</property>
<property name="text">
- <string>Pause</string>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButton">
- <property name="geometry">
- <rect>
- <x>240</x>
- <y>20</y>
- <width>88</width>
- <height>34</height>
- </rect>
- </property>
- <property name="text">
<string>Set Media</string>
</property>
</widget>
- <widget class="QLabel" name="titleLabel">
- <property name="geometry">
- <rect>
- <x>30</x>
- <y>70</y>
- <width>81</width>
- <height>31</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <pointsize>14</pointsize>
- </font>
- </property>
- <property name="text">
- <string>Nothing</string>
- </property>
- </widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">