Browse Source

added first sound

tags/v5.0.0^2
Niklas 3 years ago
parent
commit
32ea161483
  1. 1
      AppVeyor/make_installer.sh
  2. 1
      README.md
  3. 7
      src/sounds.qrc
  4. BIN
      src/sounds/CaptureSound.wav
  5. BIN
      src/sounds/ErrorSound.wav
  6. BIN
      src/sounds/TaskCompletedSound.wav
  7. 3
      src/src.pro
  8. 15
      src/uploaders/uploadersingleton.cpp
  9. 3
      src/uploaders/uploadersingleton.hpp

1
AppVeyor/make_installer.sh

@ -35,6 +35,7 @@ addFile /c/Qt/5.9/mingw53_32/bin/Qt5Network.dll
addFile /c/Qt/5.9/mingw53_32/bin/Qt5Gui.dll
addFile /c/Qt/5.9/mingw53_32/bin/Qt5Widgets.dll
addFile /c/Qt/5.9/mingw53_32/bin/Qt5WinExtras.dll
addFile /c/Qt/5.9/mingw53_32/bin/Qt5Multimedia.dll
addFileIn /c/Qt/5.9/mingw53_32/plugins/platforms/qwindows.dll platforms

1
README.md

@ -18,6 +18,7 @@ Please note that KShare is not compatiable with Wayland due to some permission i
* Qt 5 Widgets
* Qt 5 GUI
* Qt 5 Network
* Qt 5 Multimedia
* Qt 5 X11Extras | Winextras
* [QHotkey](https://github.com/Skycoder42/QHotkey)
* libavformat

7
src/sounds.qrc

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file alias="capturesound.wav">sounds/CaptureSound.wav</file>
<file alias="errorsound.wav">sounds/ErrorSound.wav</file>
<file alias="successsound.wav">sounds/TaskCompletedSound.wav</file>
</qresource>
</RCC>

BIN
src/sounds/CaptureSound.wav

Binary file not shown.

BIN
src/sounds/ErrorSound.wav

Binary file not shown.

BIN
src/sounds/TaskCompletedSound.wav

Binary file not shown.

3
src/src.pro

@ -4,7 +4,7 @@
#
#-------------------------------------------------
QT += core gui network widgets svg
QT += core gui network widgets svg multimedia
TARGET = kshare
TEMPLATE = app
@ -191,6 +191,7 @@ FORMS += mainwindow.ui \
RESOURCES += \
icon.qrc \
sounds.qrc \
translations.qrc
QMAKE_CFLAGS_DEBUG += -g

15
src/uploaders/uploadersingleton.cpp

@ -12,6 +12,7 @@
#include <logger.hpp>
#include <notifications.hpp>
#include <settings.hpp>
#include "mainwindow.hpp"
UploaderSingleton::UploaderSingleton() : QObject() {
updateSaveSettings();
@ -68,6 +69,7 @@ void UploaderSingleton::upload(QPixmap pixmap) {
file = new QTemporaryFile();
}
if (file->open(QFile::ReadWrite)) {
playSound();
pixmap.save(file, format.toLocal8Bit().constData(), settings::settings().value("imageQuality", -1).toInt());
file->seek(0);
u->doUpload(file->readAll(), format);
@ -88,6 +90,7 @@ void UploaderSingleton::upload(QByteArray img, QString format) {
file = new QTemporaryFile();
}
if (file->open(QFile::WriteOnly)) {
playSound();
file->write(img);
file->close();
}
@ -101,6 +104,7 @@ void UploaderSingleton::upload(QFile &img, QString format) {
if (!saveImages || img.rename(saveDir.absoluteFilePath(
formatter::format(settings::settings().value("fileFormat", "Screenshot %(yyyy-MM-dd HH-mm-ss)date.%ext").toString(),
format.toLower())))) {
playSound();
if (img.open(QFile::ReadWrite))
uploaders.value(uploader)->doUpload(img.readAll(), format);
else
@ -168,3 +172,14 @@ void UploaderSingleton::updateSaveSettings() {
}
}
}
void UploaderSingleton::playSound() {
mediaPlayer = new QMediaPlayer(MainWindow::inst());
mediaPlayer->setMedia(QUrl("qrc:/capturesound.wav"));
mediaPlayer->setVolume(50);
mediaPlayer->play();
if(mediaPlayer->error() != QMediaPlayer::NoError && mediaPlayer->error() != QMediaPlayer::ServiceMissingError)
notifications::notify(QString::number(mediaPlayer->error()), mediaPlayer->errorString(), QSystemTrayIcon::Warning);
}

3
src/uploaders/uploadersingleton.hpp

@ -4,6 +4,7 @@
#include "uploader.hpp"
#include <QDir>
#include <QMap>
#include <QMediaPlayer>
class UploaderSingleton : public QObject {
Q_OBJECT
@ -30,10 +31,12 @@ signals:
private:
void updateSaveSettings();
void playSound();
QDir saveDir;
bool saveImages = true;
QMap<QString, Uploader *> uploaders;
QString uploader = "imgur";
QMediaPlayer *mediaPlayer;
QList<std::runtime_error> errs;
UploaderSingleton();
};

Loading…
Cancel
Save