From 7319b50a5d7c46abd7495aa51740ec6cb0ec0141 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 13 Sep 2018 17:45:14 +0200 Subject: code cleanup: replace lring with file local function And simplify the code. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 99d716fd5..af22991a2 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -81,6 +81,10 @@ namespace { QProgressDialog *progressDialog = nullptr; bool progressDialogCanceled = false; int progressCounter = 0; + + int round_int (double value) { + return static_cast(lrint(value)); + }; } @@ -1141,24 +1145,13 @@ void MainWindow::on_actionViewAll_triggered() { toggleCollapsible(false); beginChangeState(VIEWALL); - static QList mainSizes; + const int appH = qApp->desktop()->size().height(); const int appW = qApp->desktop()->size().width(); - if (mainSizes.empty()) { - mainSizes.append(lrint(appH * 0.7)); - mainSizes.append(lrint(appH * 0.3)); - } - static QList infoProfileSizes; - if (infoProfileSizes.empty()) { - infoProfileSizes.append(lrint(appW * 0.3)); - infoProfileSizes.append(lrint(appW * 0.7)); - } - static QList listGlobeSizes; - if (listGlobeSizes.empty()) { - listGlobeSizes.append(lrint(appW * 0.7)); - listGlobeSizes.append(lrint(appW * 0.3)); - } + QList mainSizes = { round_int(appH * 0.7), round_int(appH * 0.3) }; + QList infoProfileSizes = { round_int(appW * 0.3), round_int(appW * 0.7) }; + QList listGlobeSizes = { round_int(appW * 0.7), round_int(appW * 0.3) }; QSettings settings; settings.beginGroup("MainWindow"); @@ -1196,7 +1189,7 @@ void MainWindow::enterEditState() ui.topSplitter->setSizes({ EXPANDED, EXPANDED }); ui.mainSplitter->setSizes({ EXPANDED, COLLAPSED }); int appW = qApp->desktop()->size().width(); - QList infoProfileSizes { (int)lrint(appW * 0.3), (int)lrint(appW * 0.7) }; + QList infoProfileSizes { round_int(appW * 0.3), round_int(appW * 0.7) }; QSettings settings; settings.beginGroup("MainWindow"); -- cgit v1.2.3-70-g09d2