From f7cb84994a1f711730d43e022679c894717df843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 3 Dec 2017 15:46:22 +0100 Subject: [PATCH] Adjust logo in NewFileDialog and OptionsDialog to palette #89 --- src/dialogs/NewFileDialog.cpp | 5 + src/dialogs/NewfileDialog.ui | 86 +- src/dialogs/OptionsDialog.cpp | 4 +- src/dialogs/OptionsDialog.ui | 1521 ++++++++++++++++----------------- src/utils/Helpers.cpp | 30 +- src/utils/Helpers.h | 3 + 6 files changed, 823 insertions(+), 826 deletions(-) diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index caaf6631..cc72af30 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -58,6 +58,8 @@ static QString formatBytecount(const long bytecount) return stream.readAll(); } +#include "utils/Helpers.h" + NewFileDialog::NewFileDialog(QWidget *parent) : QDialog(parent), ui(new Ui::NewFileDialog) @@ -67,6 +69,9 @@ NewFileDialog::NewFileDialog(QWidget *parent) : ui->recentsListWidget->addAction(ui->actionRemove_item); ui->recentsListWidget->addAction(ui->actionClear_all); + QColor logoColor = (palette().window().color().value() < 127) ? QColor(255, 255, 255) : QColor(0, 0, 0); + ui->logoSvgWidget->load(qhelpers::applyColorToSvg(":/img/cutter.svg", logoColor)); + fillRecentFilesList(); bool projectsExist = fillProjectsList(); diff --git a/src/dialogs/NewfileDialog.ui b/src/dialogs/NewfileDialog.ui index 9efd2e3e..1e582b34 100644 --- a/src/dialogs/NewfileDialog.ui +++ b/src/dialogs/NewfileDialog.ui @@ -14,57 +14,37 @@ Open File - - 5 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 96 - 96 - - - - - 96 - 96 - - - - - - - :/img/cutter.svg - - - true - - - Qt::AlignCenter - - + + + 8 - + + 8 + + + 8 + + + 8 + + + + + + 88 + 88 + + + + + 88 + 88 + + + + + @@ -462,6 +442,14 @@ + + + QSvgWidget + QWidget +
qsvgwidget.h
+ 1 +
+
diff --git a/src/dialogs/OptionsDialog.cpp b/src/dialogs/OptionsDialog.cpp index a90edff6..2fd908ba 100644 --- a/src/dialogs/OptionsDialog.cpp +++ b/src/dialogs/OptionsDialog.cpp @@ -25,6 +25,9 @@ OptionsDialog::OptionsDialog(MainWindow *main): ui->progressBar->setVisible(0); ui->statusLabel->setVisible(0); + QColor logoColor = (palette().window().color().value() < 127) ? QColor(255, 255, 255) : QColor(0, 0, 0); + ui->logoSvgWidget->load(qhelpers::applyColorToSvg(":/img/cutter.svg", logoColor)); + ui->analSlider->setValue(defaultAnalLevel); // Fill the plugins combo @@ -121,7 +124,6 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList advanced) ui->analSlider->setValue(level); this->setEnabled(0); - ui->logo->setEnabled(true); // Show Progress Bar ui->progressBar->setEnabled(1); diff --git a/src/dialogs/OptionsDialog.ui b/src/dialogs/OptionsDialog.ui index ef428dc8..2d3294c8 100644 --- a/src/dialogs/OptionsDialog.ui +++ b/src/dialogs/OptionsDialog.ui @@ -6,12 +6,12 @@ 0 0 - 576 - 1167 + 400 + 1143 - + 0 0 @@ -34,808 +34,771 @@ margin-bottom: 5px; } - + - QLayout::SetFixedSize - - - 5 - - - 5 - - - 5 - - - 5 + QLayout::SetMinAndMaxSize - - - 5 + + + 8 - - - - 0 + + 8 + + + 8 + + + 8 + + + + + + 88 + 88 + - - 0 + + + 88 + 88 + - - 0 - - - - - - 0 - 0 - - - - - 96 - 96 - - - - - 96 - 96 - - - - - - - :/img/cutter.svg - - - true - - - Qt::AlignCenter - - - 8 - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - + + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + 10 + + + QLayout::SetDefaultConstraint + + + 5 + + + 5 + + + 5 + + + 0 + + + + + 5 + + + + + + 0 + 0 + + + + Program: + + + + + + + + 12 + + + + + + + false + + + true + + + false + + + + + + + + + Qt::Horizontal + + + + + + + 5 + + + - 10 + 5 QLayout::SetDefaultConstraint - - 5 - - - 5 - - - 5 - - - 0 - - - - 5 - - - - - - 0 - 0 - - - - Program: - - - - - - - - 12 - - - - - - - false - - - true - - - false - - - - - - - + - Qt::Horizontal + Qt::Vertical - - - 5 + + + + 0 + 0 + - - - - 5 + + Qt::LeftToRight + + + + + + Analysis: Enabled + + + true + + + + + + + + 0 + 0 + + + + Level: + + + + + + + + + + 0 + 0 + + + + 0 + + + 3 + + + 1 + + + 0 + + + Qt::Horizontal + + + false + + + QSlider::NoTicks + + + + + + + true + + + + 0 + 0 + + + + + 6 + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Analyze all symbols (aa) + + + true + + + + + + + Analyze for references (aar) + + + true + + + + + + + Analyze function calls (aac) + + + true + + + + + + + Autorename functions based on context (aan) + + + true + + + + + + + Experimental: + + + + + + + Emulate code to find computed references (aae) + + + + + + + Analyze for consecutive function (aat) + + + + + + + Type and Argument matching analysis (afta) + + + + + + + Analyze code after trap-sleds (aaT) + + + + + + + Analyze function preludes (aap) + + + + + + + Analyze jump tables in switch statements (e! anal.jmptbl) + + + + + + + Analyze push+ret as jmp (e! anal.pushret) + + + + + + + + + + + + Qt::Horizontal + + + + + + + 0 + + + QLayout::SetMinimumSize + + + + + Load bin information + + + true + + + + + + + + + + Use virtual addressing + + + true + + + + + + + Import demangled symbols + + + true + + + + + + + + + 0 + + + + + ... + + + + 8 + 8 + + + + true + + + Qt::RightArrow + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Advanced options + + + + + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + + + + + + + CPU options + + + + + + + + + + 0 + 0 + + + + Architecture: + + + + + + + Auto + + + + Auto - - QLayout::SetDefaultConstraint + + + + + + + + 0 + 0 + + + + CPU: + + + + + + + + 70 + 0 + + + + true + + + + + + + + + + + + + 0 + 0 + + + + Bits: + + + + + + + + Auto + + + + + 8 + + + + + 16 + + + + + 32 + + + + + 64 + + + + + + + + + + 0 + + + + + + 0 + 0 + + + + Kernel: + + + + + + + false + + + Auto + + + + Auto + + + + + + + + + 0 + 0 + + + + Format: + + + + + + + Auto + + + + Auto + + + + + + + + + + Qt::Horizontal + + + + + + + QLayout::SetDefaultConstraint + + + QFormLayout::ExpandingFieldsGrow + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 10 + + + 0 + + + + + + 0 + 0 + + + + Load offset: + + + + + + + + 12 + + + + + + + 0 + + + false + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Map offset: + + + + + + + + 12 + + + + 0 + + + false + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Load PDB + + + + + + + true + + + + 0 + + + 0 + + + 0 + + + 0 - - - Qt::Vertical + + + pdb file - - - - 0 - 0 - - - - Qt::LeftToRight - - - - + - Analysis: Enabled - - - true - - - - - - - - 0 - 0 - - - - Level: + Select - - - - - - 0 - 0 - - - - 0 - - - 3 - - - 1 - - - 0 - - - Qt::Horizontal - - - false - - - QSlider::NoTicks - - - - - - - true - - - - 0 - 0 - - - - - 6 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - Analyze all symbols (aa) - - - true - - - - - - - Analyze for references (aar) - - - true - - - - - - - Analyze function calls (aac) - - - true - - - - - - - Autorename functions based on context (aan) - - - true - - - - - - - Experimental: - - - - - - - Emulate code to find computed references (aae) - - - - - - - Analyze for consecutive function (aat) - - - - - - - Type and Argument matching analysis (afta) - - - - - - - Analyze code after trap-sleds (aaT) - - - - - - - Analyze function preludes (aap) - - - - - - - Analyze jump tables in switch statements (e! anal.jmptbl) - - - - - - - Analyze push+ret as jmp (e! anal.pushret) - - - - - - - - - - - - Qt::Horizontal - - - - - - - 0 - - - QLayout::SetMinimumSize - - - - - Load bin information - - - true - - - - - - - - - - Use virtual addressing - - - true - - - - - - - Import demangled symbols - - - true - - - - - - - - - 0 - - - - - ... - - - - 8 - 8 - - - - true - - - Qt::RightArrow - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Advanced options - - - - - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - - - - - - - CPU options - - - - - - - - - - 0 - 0 - - - - Architecture: - - - - - - - Auto - - - - Auto - - - - - - - - - 0 - 0 - - - - CPU: - - - - - - - - 70 - 0 - - - - true - - - - - - - - - - - - - 0 - 0 - - - - Bits: - - - - - - - - Auto - - - - - 8 - - - - - 16 - - - - - 32 - - - - - 64 - - - - - - - - - - 0 - - - - - - 0 - 0 - - - - Kernel: - - - - - - - false - - - Auto - - - - Auto - - - - - - - - - 0 - 0 - - - - Format: - - - - - - - Auto - - - - Auto - - - - - - - - - - Qt::Horizontal - - - - - - - QLayout::SetDefaultConstraint - - - QFormLayout::ExpandingFieldsGrow - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 10 - - - 0 - - - - - - 0 - 0 - - - - Load offset: - - - - - - - - 12 - - - - - - - 0 - - - false - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Map offset: - - - - - - - - 12 - - - - 0 - - - false - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Load PDB - - - - - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - pdb file - - - - - - - Select - - - - - - - - - - - - - - - - - + + + +
+ + + + + @@ -929,6 +892,14 @@ + + + QSvgWidget + QWidget +
qsvgwidget.h
+ 1 +
+
diff --git a/src/utils/Helpers.cpp b/src/utils/Helpers.cpp index 82b9d72d..b6aa066b 100644 --- a/src/utils/Helpers.cpp +++ b/src/utils/Helpers.cpp @@ -9,7 +9,6 @@ #include #include #include -#include static QAbstractItemView::ScrollMode scrollMode() @@ -128,4 +127,33 @@ namespace qhelpers / fontMetrics.lineSpacing(); } + + QByteArray applyColorToSvg(const QString &filename, QColor color) + { + static QRegularExpression styleRegExp("(?:style=\".*fill:(.*?);.*?\")|(?:fill=\"(.*?)\")"); + + QString replaceStr = QString("#%1").arg(color.rgb() & 0xffffff, 6, 16, QLatin1Char('0')); + int replaceStrLen = replaceStr.length(); + + QFile file(filename); + file.open(QIODevice::ReadOnly); + QString xml = QString::fromUtf8(file.readAll()); + + int offset = 0; + while(true) + { + QRegularExpressionMatch match = styleRegExp.match(xml, offset); + if (!match.hasMatch()) + { + break; + } + + int captureIndex = match.captured(1).isNull() ? 2 : 1; + xml.replace(match.capturedStart(captureIndex), match.capturedLength(captureIndex), replaceStr); + offset = match.capturedStart(captureIndex) + replaceStrLen; + } + + return xml.toUtf8(); + } + } // end namespace diff --git a/src/utils/Helpers.h b/src/utils/Helpers.h index 77c669cd..285adc4d 100644 --- a/src/utils/Helpers.h +++ b/src/utils/Helpers.h @@ -2,6 +2,7 @@ #define QHELPERS_H #include +#include #include class QPlainTextEdit; @@ -40,6 +41,8 @@ namespace qhelpers int getMaxFullyDisplayedLines(QPlainTextEdit *plainTextEdit); + + QByteArray applyColorToSvg(const QString &filename, QColor color); } #endif // HELPERS_H