Skip to content

Commit

Permalink
Apply coding style to crash reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jan 28, 2021
1 parent 62dedb7 commit 4c46228
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
5 changes: 3 additions & 2 deletions scripts/uncrustify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

set -e

# "src/gui/src/"
find "src/lib/src/" "src/cli/src/" "src/e2e/src/" "src/tests/src/" -name '*.cpp' -o -name '*.h' \
find "src/" -name '*.cpp' -o -name '*.h' \
| grep -v "vendor" \
| grep -v "crashhandler" \
| grep -v "backports" \
| grep -v "cmake" \
| grep -v "gui" \
| uncrustify -c "uncrustify.cfg" --replace --no-backup -F -
39 changes: 19 additions & 20 deletions src/crash-reporter/crash-reporter-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ QString savePath(const QString &file, bool exists = false)
{
#ifdef TEST
Q_UNUSED(exists);
return QDir::toNativeSeparators(QDir::currentPath()+"/tests/resources/"+file);
return QDir::toNativeSeparators(QDir::currentPath() + "/tests/resources/" + file);
#else
const QString &check = exists ? file : "settings.ini";
if (QFile(QDir::toNativeSeparators(qApp->applicationDirPath()+"/"+check)).exists())
{ return QDir::toNativeSeparators(qApp->applicationDirPath()+"/"+file); }
if (QFile(QDir::toNativeSeparators(QDir::currentPath()+"/"+check)).exists())
{ return QDir::toNativeSeparators(QDir::currentPath()+"/"+file); }
if (QFile(QDir::toNativeSeparators(QDir::homePath()+"/Grabber/"+check)).exists())
{ return QDir::toNativeSeparators(QDir::homePath()+"/Grabber/"+file); }
if (QFile(QDir::toNativeSeparators(qApp->applicationDirPath() + "/" + check)).exists()) {
return QDir::toNativeSeparators(qApp->applicationDirPath() + "/" + file);
}
if (QFile(QDir::toNativeSeparators(QDir::currentPath() + "/" + check)).exists()) {
return QDir::toNativeSeparators(QDir::currentPath() + "/" + file);
}
if (QFile(QDir::toNativeSeparators(QDir::homePath() + "/Grabber/" + check)).exists()) {
return QDir::toNativeSeparators(QDir::homePath() + "/Grabber/" + file);
}
#ifdef __linux__
if (QFile(QDir::toNativeSeparators(QDir::homePath()+"/.Grabber/"+check)).exists())
{ return QDir::toNativeSeparators(QDir::homePath()+"/.Grabber/"+file); }
if (QFile(QDir::toNativeSeparators(QDir::homePath() + "/.Grabber/" + check)).exists()) {
return QDir::toNativeSeparators(QDir::homePath() + "/.Grabber/" + file);
}
#endif
return QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::DataLocation)+"/"+file);
return QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + file);
#endif
}

Expand All @@ -41,8 +45,7 @@ CrashReporterWindow::CrashReporterWindow(QWidget *parent) : QMainWindow(parent),
const QLocale locale = QLocale(lang);
QLocale::setDefault(locale);
auto *translator = new QTranslator(this);
if (translator->load("crashreporter/"+lang))
{
if (translator->load("crashreporter/" + lang)) {
qApp->installTranslator(translator);
}

Expand All @@ -51,10 +54,8 @@ CrashReporterWindow::CrashReporterWindow(QWidget *parent) : QMainWindow(parent),
ui->lineSettings->setText(savePath("settings.ini"));
ui->lineLog->setText(savePath("main.log"));
QFile f(savePath("lastdump"));
if (f.exists())
{
if (f.open(QFile::ReadOnly))
{
if (f.exists()) {
if (f.open(QFile::ReadOnly)) {
ui->lineDump->setText(f.readAll());
f.close();
}
Expand All @@ -74,8 +75,7 @@ void CrashReporterWindow::restart()

void CrashReporterWindow::sendCrashReport()
{
if (ui->checkSend->isChecked())
{
if (ui->checkSend->isChecked()) {
QDesktopServices::openUrl(QUrl(QString(PROJECT_GITHUB_URL) + "/issues/new?labels[]=crash"));
}

Expand All @@ -84,8 +84,7 @@ void CrashReporterWindow::sendCrashReport()

void CrashReporterWindow::finished()
{
if (m_restart && QFile::exists("Grabber.exe"))
{
if (m_restart && QFile::exists("Grabber.exe")) {
QProcess::startDetached("\"Grabber.exe\"");
}

Expand Down

0 comments on commit 4c46228

Please sign in to comment.