1
0
Fork 0

[Style+Launcher] Removed clang-format temporarily and improved update checker.

This commit is contained in:
NamedKitten 2018-11-16 09:16:04 +00:00
parent c8cde5086f
commit 8c71f0b341
2 changed files with 52 additions and 159 deletions

View file

@ -1,118 +0,0 @@
---
Language: Cpp
# BasedOnStyle: Mozilla
AccessModifierOffset: -2
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Mozilla
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 1
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...

View file

@ -17,9 +17,9 @@
#endif #endif
#ifdef GIT_COMMIT_HASH #ifdef GIT_COMMIT_HASH
#include <QtNetwork>
#include <QSequentialIterable>
#include <QJsonDocument> #include <QJsonDocument>
#include <QSequentialIterable>
#include <QtNetwork>
#endif #endif
@ -27,53 +27,58 @@
#include <initializer_list> #include <initializer_list>
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
void catchUnixSignals(std::initializer_list<int> quitSignals) { void
auto handler = [](int sig) -> void { catchUnixSignals(std::initializer_list<int> quitSignals)
QCoreApplication::quit(); {
}; auto handler = [](int sig) -> void { QCoreApplication::quit(); };
sigset_t blocking_mask; sigset_t blocking_mask;
sigemptyset(&blocking_mask); sigemptyset(&blocking_mask);
for (auto sig : quitSignals) for (auto sig : quitSignals)
sigaddset(&blocking_mask, sig); sigaddset(&blocking_mask, sig);
struct sigaction sa; struct sigaction sa;
sa.sa_handler = handler; sa.sa_handler = handler;
sa.sa_mask = blocking_mask; sa.sa_mask = blocking_mask;
sa.sa_flags = 0; sa.sa_flags = 0;
for (auto sig : quitSignals) for (auto sig : quitSignals)
sigaction(sig, &sa, nullptr); sigaction(sig, &sa, nullptr);
} }
#endif #endif
int
int main(int argc, char* argv[]) main(int argc, char* argv[])
{ {
setenv("QT_QUICK_CONTROLS_STYLE", "Desktop", 1); setenv("QT_QUICK_CONTROLS_STYLE", "Desktop", 1);
QApplication app(argc, argv); QApplication app(argc, argv);
#ifdef __linux__ #ifdef __linux__
catchUnixSignals({SIGQUIT, SIGINT, SIGTERM, SIGHUP}); catchUnixSignals({ SIGQUIT, SIGINT, SIGTERM, SIGHUP });
#endif #endif
#ifdef GIT_COMMIT_HASH #ifdef GIT_COMMIT_HASH
QString current_version = QString(GIT_COMMIT_HASH); QString current_version = QString(GIT_COMMIT_HASH);
qDebug() << "Current Version: " << current_version; qDebug() << "Current Version: " << current_version;
QNetworkRequest request(QUrl("https://api.github.com/repos/NamedKitten/KittehPlayer/releases/tags/continuous")); QNetworkRequest request(QUrl("https://api.github.com/repos/NamedKitten/"
QNetworkAccessManager nam; "KittehPlayer/releases/tags/continuous"));
QNetworkReply *reply = nam.get(request); QNetworkAccessManager nam;
QNetworkReply* reply = nam.get(request);
while(!reply->isFinished()) { while (!reply->isFinished()) {
qApp->processEvents(); qApp->processEvents();
} }
QByteArray response_data = reply->readAll(); QByteArray response_data = reply->readAll();
QJsonDocument json = QJsonDocument::fromJson(response_data); QJsonDocument json = QJsonDocument::fromJson(response_data);
QJsonArray jsonArray = json["assets"].toArray();
qDebug() << "Latest Version: " << json["target_commitish"].toString(); if (json["target_commitish"].toString().length() != 0) {
if (json["target_commitish"].toString().endsWith(current_version) == 0) { if (json["target_commitish"].toString().endsWith(current_version) == 0) {
qDebug() << "Update Available. Please update ASAP."; qDebug() << "Latest Version: " << json["target_commitish"].toString();
} qDebug() << "Update Available. Please update ASAP.";
}
} else {
qDebug() << "Couldn't check for new version.";
}
#endif #endif
app.setOrganizationName("KittehPlayer"); app.setOrganizationName("KittehPlayer");
@ -81,10 +86,15 @@ if (json["target_commitish"].toString().endsWith(current_version) == 0) {
app.setApplicationName("KittehPlayer"); app.setApplicationName("KittehPlayer");
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
if (!qstrcmp(argv[i], "--update")) { if (!qstrcmp(argv[i], "--update")) {
QString program = QProcessEnvironment::systemEnvironment().value("APPDIR", "") + "/usr/bin/appimageupdatetool"; QString program =
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
"/usr/bin/appimageupdatetool";
QProcess updater; QProcess updater;
updater.setProcessChannelMode(QProcess::ForwardedChannels); updater.setProcessChannelMode(QProcess::ForwardedChannels);
updater.start(program, QStringList() << QProcessEnvironment::systemEnvironment().value("APPIMAGE", "")); updater.start(program,
QStringList()
<< QProcessEnvironment::systemEnvironment().value(
"APPIMAGE", ""));
updater.waitForFinished(); updater.waitForFinished();
exit(0); exit(0);
} }
@ -92,8 +102,9 @@ if (json["target_commitish"].toString().endsWith(current_version) == 0) {
SetDPMS(false); SetDPMS(false);
QString newpath = QProcessEnvironment::systemEnvironment().value("APPDIR", "") + QString newpath =
"/usr/bin:" + QProcessEnvironment::systemEnvironment().value("PATH", ""); QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
"/usr/bin:" + QProcessEnvironment::systemEnvironment().value("PATH", "");
setenv("PATH", newpath.toUtf8().constData(), 1); setenv("PATH", newpath.toUtf8().constData(), 1);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);