Im stupid

This commit is contained in:
ArsenArsen 2017-05-22 15:56:47 +02:00
parent 96f4cf7305
commit 91aa7badc6
4 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#include <QApplication> #include <QApplication>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QtGlobal> #include <QtGlobal>
#include <notifications.hpp>
#include <stdio.h> #include <stdio.h>
bool verbose = false; bool verbose = false;
@ -23,6 +24,7 @@ void handler(QtMsgType type, const QMessageLogContext &, const QString &msg) {
break; break;
case QtFatalMsg: case QtFatalMsg:
fprintf(stderr, "FATAL: %s\n", localMsg.constData()); fprintf(stderr, "FATAL: %s\n", localMsg.constData());
notifications::notify("KShare Fatal Error", msg, QSystemTrayIcon::Critical);
break; break;
} }
} }

View File

@ -4,6 +4,7 @@
#include <QStatusBar> #include <QStatusBar>
void notifications::notify(QString title, QString body, QSystemTrayIcon::MessageIcon icon) { void notifications::notify(QString title, QString body, QSystemTrayIcon::MessageIcon icon) {
if (!MainWindow::inst()) return;
MainWindow::inst()->tray->showMessage(title, body, icon, 5000); MainWindow::inst()->tray->showMessage(title, body, icon, 5000);
MainWindow::inst()->statusBar()->showMessage(title + ": " + body); MainWindow::inst()->statusBar()->showMessage(title + ": " + body);
} }

View File

@ -11,10 +11,12 @@
UploaderSingleton::UploaderSingleton() UploaderSingleton::UploaderSingleton()
: QObject(), saveDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) { : QObject(), saveDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) {
if (QStandardPaths::writableLocation(QStandardPaths::PicturesLocation).isEmpty()) { if (QStandardPaths::writableLocation(QStandardPaths::PicturesLocation).isEmpty()) {
qFatal() << "Cannot determine location for pictures"; qFatal("Cannot determine location for pictures");
} }
if (!saveDir.exists()) { if (!saveDir.exists()) {
saveDir.mkpath(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); if (!saveDir.mkpath(".")) {
qFatal("Could not create the path %s to store images in!", saveDir.absoluteFilePath(".").toLocal8Bit().constData());
}
} }
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
configDir.mkpath("KShare/uploaders"); configDir.mkpath("KShare/uploaders");

View File

@ -2,6 +2,7 @@
#define UPLOADERSINGLETON_HPP #define UPLOADERSINGLETON_HPP
#include "uploader.hpp" #include "uploader.hpp"
#include <QDir>
#include <QMap> #include <QMap>
class UploaderSingleton : public QObject { class UploaderSingleton : public QObject {
@ -21,6 +22,7 @@ class UploaderSingleton : public QObject {
void newUploader(Uploader *u); void newUploader(Uploader *u);
private: private:
QDir saveDir;
UploaderSingleton(); UploaderSingleton();
QMap<QString, Uploader *> uploaders; QMap<QString, Uploader *> uploaders;
QString uploader = "imgur"; QString uploader = "imgur";