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