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/Qt5Gui.dll
|
||||||
addFile /c/Qt/5.9/mingw53_32/bin/Qt5Widgets.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/Qt5WinExtras.dll
|
||||||
|
addFile /c/Qt/5.9/mingw53_32/bin/Qt5Multimedia.dll
|
||||||
|
|
||||||
addFileIn /c/Qt/5.9/mingw53_32/plugins/platforms/qwindows.dll platforms
|
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 Widgets
|
||||||
* Qt 5 GUI
|
* Qt 5 GUI
|
||||||
* Qt 5 Network
|
* Qt 5 Network
|
||||||
|
* Qt 5 Multimedia
|
||||||
* Qt 5 X11Extras | Winextras
|
* Qt 5 X11Extras | Winextras
|
||||||
* [QHotkey](https://github.com/Skycoder42/QHotkey)
|
* [QHotkey](https://github.com/Skycoder42/QHotkey)
|
||||||
* libavformat
|
* 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
|
TARGET = kshare
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
@ -191,6 +191,7 @@ FORMS += mainwindow.ui \
|
|||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
icon.qrc \
|
icon.qrc \
|
||||||
|
sounds.qrc \
|
||||||
translations.qrc
|
translations.qrc
|
||||||
|
|
||||||
QMAKE_CFLAGS_DEBUG += -g
|
QMAKE_CFLAGS_DEBUG += -g
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <logger.hpp>
|
#include <logger.hpp>
|
||||||
#include <notifications.hpp>
|
#include <notifications.hpp>
|
||||||
#include <settings.hpp>
|
#include <settings.hpp>
|
||||||
|
#include "mainwindow.hpp"
|
||||||
|
|
||||||
UploaderSingleton::UploaderSingleton() : QObject() {
|
UploaderSingleton::UploaderSingleton() : QObject() {
|
||||||
updateSaveSettings();
|
updateSaveSettings();
|
||||||
@ -68,6 +69,7 @@ void UploaderSingleton::upload(QPixmap pixmap) {
|
|||||||
file = new QTemporaryFile();
|
file = new QTemporaryFile();
|
||||||
}
|
}
|
||||||
if (file->open(QFile::ReadWrite)) {
|
if (file->open(QFile::ReadWrite)) {
|
||||||
|
playSound();
|
||||||
pixmap.save(file, format.toLocal8Bit().constData(), settings::settings().value("imageQuality", -1).toInt());
|
pixmap.save(file, format.toLocal8Bit().constData(), settings::settings().value("imageQuality", -1).toInt());
|
||||||
file->seek(0);
|
file->seek(0);
|
||||||
u->doUpload(file->readAll(), format);
|
u->doUpload(file->readAll(), format);
|
||||||
@ -88,6 +90,7 @@ void UploaderSingleton::upload(QByteArray img, QString format) {
|
|||||||
file = new QTemporaryFile();
|
file = new QTemporaryFile();
|
||||||
}
|
}
|
||||||
if (file->open(QFile::WriteOnly)) {
|
if (file->open(QFile::WriteOnly)) {
|
||||||
|
playSound();
|
||||||
file->write(img);
|
file->write(img);
|
||||||
file->close();
|
file->close();
|
||||||
}
|
}
|
||||||
@ -101,6 +104,7 @@ void UploaderSingleton::upload(QFile &img, QString format) {
|
|||||||
if (!saveImages || img.rename(saveDir.absoluteFilePath(
|
if (!saveImages || img.rename(saveDir.absoluteFilePath(
|
||||||
formatter::format(settings::settings().value("fileFormat", "Screenshot %(yyyy-MM-dd HH-mm-ss)date.%ext").toString(),
|
formatter::format(settings::settings().value("fileFormat", "Screenshot %(yyyy-MM-dd HH-mm-ss)date.%ext").toString(),
|
||||||
format.toLower())))) {
|
format.toLower())))) {
|
||||||
|
playSound();
|
||||||
if (img.open(QFile::ReadWrite))
|
if (img.open(QFile::ReadWrite))
|
||||||
uploaders.value(uploader)->doUpload(img.readAll(), format);
|
uploaders.value(uploader)->doUpload(img.readAll(), format);
|
||||||
else
|
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 "uploader.hpp"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QMediaPlayer>
|
||||||
|
|
||||||
class UploaderSingleton : public QObject {
|
class UploaderSingleton : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -30,10 +31,12 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void updateSaveSettings();
|
void updateSaveSettings();
|
||||||
|
void playSound();
|
||||||
QDir saveDir;
|
QDir saveDir;
|
||||||
bool saveImages = true;
|
bool saveImages = true;
|
||||||
QMap<QString, Uploader *> uploaders;
|
QMap<QString, Uploader *> uploaders;
|
||||||
QString uploader = "imgur";
|
QString uploader = "imgur";
|
||||||
|
QMediaPlayer *mediaPlayer;
|
||||||
QList<std::runtime_error> errs;
|
QList<std::runtime_error> errs;
|
||||||
UploaderSingleton();
|
UploaderSingleton();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user