From 391e847ebc4a162a697c7e473494a2cf375274d9 Mon Sep 17 00:00:00 2001 From: Marco Grassi Date: Sun, 11 Mar 2018 18:29:37 +0800 Subject: [PATCH] Dynamic size for color selection and compile warning fixes (#380) --- src/dialogs/preferences/GeneralOptionsWidget.cpp | 9 +++++++++ src/widgets/GraphView.h | 2 +- src/widgets/HexdumpWidget.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dialogs/preferences/GeneralOptionsWidget.cpp b/src/dialogs/preferences/GeneralOptionsWidget.cpp index 1ada10cb..1ae2f660 100644 --- a/src/dialogs/preferences/GeneralOptionsWidget.cpp +++ b/src/dialogs/preferences/GeneralOptionsWidget.cpp @@ -44,6 +44,15 @@ void GeneralOptionsWidget::updateThemeFromConfig() QString curTheme = Config()->getCurrentTheme(); int index = themes.indexOf(curTheme) + 1; ui->colorComboBox->setCurrentIndex(index); + int maxThemeLen = 0; + for (QString str : themes){ + int strLen = str.length(); + if (strLen > maxThemeLen) { + maxThemeLen = strLen; + } + } + ui->colorComboBox->setMinimumContentsLength(maxThemeLen); + ui->colorComboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); connect(ui->colorComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_colorComboBox_currentIndexChanged(int))); } diff --git a/src/widgets/GraphView.h b/src/widgets/GraphView.h index b2d68ce1..95e1af1d 100644 --- a/src/widgets/GraphView.h +++ b/src/widgets/GraphView.h @@ -129,7 +129,7 @@ protected: void adjustSize(int new_width, int new_height); - bool event(QEvent *event); + bool event(QEvent *event) override; private: bool checkPointClicked(QPointF &point, int x, int y, bool above_y=false); diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index 98b5cf78..eb530764 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -432,7 +432,7 @@ std::array HexdumpWidget::fetchHexdump(RVA addr, int lines) cur_addr += cols; } - return { offsetText, hexText, asciiText}; + return {{offsetText, hexText, asciiText}}; } void HexdumpWidget::selectionChanged()