From d0540d7655980e50fb43fec3299f5ceaea4a460a Mon Sep 17 00:00:00 2001 From: ncyellow Date: Sat, 30 Mar 2019 09:13:01 +0300 Subject: [PATCH] Get color for optimization (#1404) * small optimization function getColorFor --- src/dialogs/NewFileDialog.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index 041377f7..1ab8995b 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -14,20 +14,17 @@ const int NewFileDialog::MaxRecentFiles; -static QColor getColorFor(const QString &str, int pos) +static QColor getColorFor(int pos) { - Q_UNUSED(str); - - QList Colors; - Colors << QColor(29, 188, 156); // Turquoise - Colors << QColor(52, 152, 219); // Blue - Colors << QColor(155, 89, 182); // Violet - Colors << QColor(52, 73, 94); // Grey - Colors << QColor(231, 76, 60); // Red - Colors << QColor(243, 156, 17); // Orange - - return Colors[pos % 6]; - + static const QList colors = { + QColor(29, 188, 156), // Turquoise + QColor(52, 152, 219), // Blue + QColor(155, 89, 182), // Violet + QColor(52, 73, 94), // Grey + QColor(231, 76, 60), // Red + QColor(243, 156, 17) // Orange + }; + return colors[pos % 6]; } static QIcon getIconFor(const QString &str, int pos) @@ -42,7 +39,7 @@ static QIcon getIconFor(const QString &str, int pos) QPainter pixPaint(&pixmap); pixPaint.setPen(Qt::NoPen); pixPaint.setRenderHint(QPainter::Antialiasing); - pixPaint.setBrush(QBrush(QBrush(getColorFor(str, pos)))); + pixPaint.setBrush(getColorFor(pos)); pixPaint.drawEllipse(1, 1, w - 2, h - 2); pixPaint.setPen(Qt::white); pixPaint.setFont(QFont("Verdana", 24, 1));