added first sound
This commit is contained in:
parent
dc488ed8f9
commit
32ea161483
@ -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
|
||||
|
||||
|
@ -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
Normal file
7
src/sounds.qrc
Normal file
@ -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
Normal file
BIN
src/sounds/CaptureSound.wav
Normal file
Binary file not shown.
BIN
src/sounds/ErrorSound.wav
Normal file
BIN
src/sounds/ErrorSound.wav
Normal file
Binary file not shown.
BIN
src/sounds/TaskCompletedSound.wav
Normal file
BIN
src/sounds/TaskCompletedSound.wav
Normal file
Binary file not shown.
@ -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
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user