Add an installer

This commit is contained in:
ArsenArsen 2017-07-11 16:24:36 +02:00
parent 3768ce2f51
commit f57013d557
8 changed files with 69 additions and 21 deletions

View File

@ -170,7 +170,8 @@ DISTFILES += \
OlderSystemFix.patch \
AppVeyor/appveyor.yml \
AppVeyor/make_installer.sh \
.travis.yml
.travis.yml \
install.sh
RESOURCES += \
icon.qrc

View File

@ -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.

35
install.sh Executable file
View File

@ -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 "------------------------------------------------------"

View File

@ -14,8 +14,8 @@
<string>KShare</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>:/icons/icon.jpg</normaloff>:/icons/icon.jpg</iconset>
<iconset resource="icon.qrc">
<normaloff>:/icons/icon.svg</normaloff>:/icons/icon.svg</iconset>
</property>
<widget class="QWidget" name="centralWidget">
<property name="sizePolicy">
@ -144,6 +144,8 @@
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<resources>
<include location="icon.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -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;
}

View File

@ -1,5 +1,6 @@
#include "settings.hpp"
#include <QDebug>
#include <QMutex>
#include <QStandardPaths>
@ -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;
}

View File

@ -6,6 +6,7 @@
namespace settings {
QSettings &settings();
QDir dir();
}
#endif // SETTINGS_HPP

View File

@ -11,7 +11,7 @@
#include <screenshotutil.hpp>
#include <settings.hpp>
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<QString, QString>>() << QPair<QString, QString>("Content-Type", mime.toUtf8())
<< QPair<QString, QString>("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()));
}
});
}