From f57013d557c2835c15867d16cd9b70fa7d2eecb2 Mon Sep 17 00:00:00 2001 From: ArsenArsen Date: Tue, 11 Jul 2017 16:24:36 +0200 Subject: [PATCH] Add an installer --- KShare.pro | 3 ++- README.md | 4 ++-- install.sh | 35 +++++++++++++++++++++++++++++ mainwindow.ui | 8 ++++--- recording/recordingformats.cpp | 4 ---- settings.cpp | 21 ++++++++++++----- settings.hpp | 1 + uploaders/default/imguruploader.cpp | 14 +++++++----- 8 files changed, 69 insertions(+), 21 deletions(-) create mode 100755 install.sh diff --git a/KShare.pro b/KShare.pro index c92c8fc..74d2d48 100644 --- a/KShare.pro +++ b/KShare.pro @@ -170,7 +170,8 @@ DISTFILES += \ OlderSystemFix.patch \ AppVeyor/appveyor.yml \ AppVeyor/make_installer.sh \ - .travis.yml + .travis.yml \ + install.sh RESOURCES += \ icon.qrc diff --git a/README.md b/README.md index 84e0371..0cb5725 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,11 @@ You have to obtain the dependencies though. ```bash git clone https://github.com/ArsenArsen/KShare.git cd KShare -qmake // Might be qmake-qt5 on your system +qmake # Might be qmake-qt5 on your system make ``` On systems with FFMpeg pre-3.1 you need to apply `OlderSystemFix.patch` to `recording/encoders/encoder.cpp`. On systems with Qt pre-5.7 you need to install the Qt version from their website. - +You can attempt to `curl https://raw.githubusercontent.com/ArsenArsen/KShare/master/install.sh | bash` ###### Started on 19th of April 2017 to bring some attention and improvement to Linux screenshotting. diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..c324471 --- /dev/null +++ b/install.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +uname=$(uname) +function installIfNeeded { + brew ls --versions $1 > /dev/null + if [[ ! $? = 0 ]]; then brew install $1 + else brew upgrade $1; fi +} + +resultfile="" + +if [[ "$uname" = "Darwin" ]]; then +export PATH="/usr/local/opt/qt/bin:$PATH" +installIfNeeded qt +installIfNeeded ffmpeg +installIfNeeded pkg-config +installIfNeeded git +resultfile="$(pwd)/KShare/build/KShare.app/" +elif [[ "$uname" = "Linux" ]]; then +echo "Please install Qt5 SDK, qmake, ffmpeg development files, git, and pkgcondig" +bash +resultfile="$(pwd)/KShare/build/KShare" +else echo "Unsupported OS!" && exit 1; fi + +git clone --recursive https://github.com/ArsenArsen/KShare.git || exit 2 +cd KShare +mkdir build || exit 3 +cd build +qmake-qt5 .. || qmake .. || exit 4 +make -j$(($(nproc) + 1)) || exit 5 +echo "------------------------------------------------------" +echo "Resulting file is $resultfile" +if [[ "$uname" = "Linux" ]]; then echo "To link the file into path, run sudo ln -s $resultfile /usr/bin/kshare"; fi +cd .. +echo "To update, go to $(pwd), git pull, cd build, and make -j$(($(nproc) + 1))" +echo "------------------------------------------------------" diff --git a/mainwindow.ui b/mainwindow.ui index fc55e2c..4c409dc 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -14,8 +14,8 @@ KShare - - :/icons/icon.jpg:/icons/icon.jpg + + :/icons/icon.svg:/icons/icon.svg @@ -144,6 +144,8 @@ - + + + diff --git a/recording/recordingformats.cpp b/recording/recordingformats.cpp index a95f1a5..a16abfb 100644 --- a/recording/recordingformats.cpp +++ b/recording/recordingformats.cpp @@ -39,8 +39,6 @@ RecordingFormats::RecordingFormats(formats::Recording f) { return false; } } catch (std::runtime_error &e) { - // notifications::notify("KShare Video Encoder Error", e.what(), - // QSystemTrayIcon::Critical); qCritical() << "Encoder error: " << e.what(); interrupt = true; delete enc; @@ -54,8 +52,6 @@ RecordingFormats::RecordingFormats(formats::Recording f) { frameAdded = true; enc->addFrame(img); } catch (std::runtime_error &e) { - // notifications::notify("KShare Video Encoder Error", e.what(), - // QSystemTrayIcon::Critical); qCritical() << "Encoder error: " << e.what(); interrupt = true; } diff --git a/settings.cpp b/settings.cpp index 4ab49d6..86cb78d 100644 --- a/settings.cpp +++ b/settings.cpp @@ -1,5 +1,6 @@ #include "settings.hpp" +#include #include #include @@ -7,11 +8,19 @@ QMutex *lock = new QMutex; QSettings &settings::settings() { QMutexLocker l(lock); - static QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); - if (configDir.dirName() != "KShare") { - configDir.mkdir("KShare"); - configDir.cd("KShare"); - } - static QSettings settings(configDir.absoluteFilePath("settings.ini"), QSettings::IniFormat); + static QSettings settings(dir().absoluteFilePath("settings.ini"), QSettings::IniFormat); return settings; } + +QDir settings::dir() { + static QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); + if (configDir.dirName() != "KShare") { + if (!configDir.cd("KShare")) + if (!configDir.mkdir("KShare")) { + qFatal("Could not make config directory"); + } else { + configDir.cd("KShare"); + } + } + return configDir; +} diff --git a/settings.hpp b/settings.hpp index e2a7870..e363b84 100644 --- a/settings.hpp +++ b/settings.hpp @@ -6,6 +6,7 @@ namespace settings { QSettings &settings(); +QDir dir(); } #endif // SETTINGS_HPP diff --git a/uploaders/default/imguruploader.cpp b/uploaders/default/imguruploader.cpp index 7103215..ec051a9 100644 --- a/uploaders/default/imguruploader.cpp +++ b/uploaders/default/imguruploader.cpp @@ -11,7 +11,7 @@ #include #include -struct SegfaultWorkaround { +struct SegfaultWorkaround { // I'm a scrub for doing this SegfaultWorkaround(QByteArray a, ImgurUploader *u, QString m) : byteArray(), dis(u), mime(m) { a.swap(byteArray); QJsonObject object; @@ -81,16 +81,20 @@ void ImgurUploader::handleSend(QString auth, QString mime, QByteArray byteArray) ioutils::postJson(QUrl("https://api.imgur.com/3/image"), QList>() << QPair("Content-Type", mime.toUtf8()) << QPair("Authorization", auth), - byteArray, [](QJsonDocument res, QByteArray, QNetworkReply *) { + byteArray, [byteArray, this, mime](QJsonDocument res, QByteArray, QNetworkReply *r) { QString result = res.object()["data"].toObject()["link"].toString(); + if (r->error() == QNetworkReply::ContentAccessDenied) { + new SegfaultWorkaround(byteArray, this, mime); + return; + } if (!result.isEmpty()) { screenshotutil::toClipboard(result); notifications::notify("KShare imgur Uploader ", "Uploaded to imgur!"); } else { notifications::notify("KShare imgur Uploader ", - QString("Failed upload! imgur said: HTTP %2: %1") - .arg(res.object()["data"].toObject()["error"].toString()) - .arg(QString::number(res.object()["status"].toInt()))); + QString("Failed upload! imgur said: HTTP %1: %2") + .arg(r->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()) + .arg(r->errorString())); } }); }