From 3d699bd5339a464381c603d38dcc578f44f20f6a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 19 May 2024 13:36:02 +0400 Subject: [PATCH] Improve operation widget appearance --- apps/opencs/view/doc/operation.cpp | 27 ++++++++++----------------- apps/opencs/view/doc/operations.cpp | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/apps/opencs/view/doc/operation.cpp b/apps/opencs/view/doc/operation.cpp index 4825f87ff3..cbe94694af 100644 --- a/apps/opencs/view/doc/operation.cpp +++ b/apps/opencs/view/doc/operation.cpp @@ -13,21 +13,21 @@ void CSVDoc::Operation::updateLabel(int threads) { if (threads == -1 || ((threads == 0) != mStalling)) { - std::string name("unknown operation"); + std::string name("Unknown operation"); switch (mType) { case CSMDoc::State_Saving: - name = "saving"; + name = "Saving"; break; case CSMDoc::State_Verifying: - name = "verifying"; + name = "Verifying"; break; case CSMDoc::State_Searching: - name = "searching"; + name = "Searching"; break; case CSMDoc::State_Merging: - name = "merging"; + name = "Merging"; break; } @@ -98,7 +98,7 @@ void CSVDoc::Operation::setBarColor(int type) "QProgressBar::chunk {" "background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 %1, stop:.50 %2 stop: .51 %3 stop:1 %4);" "text-align: center;" - "margin: 2px 1px 1p 2px;" + "margin: 2px 2px 2px 2px;" "}"; QString topColor = "#F2F6F8"; @@ -121,10 +121,10 @@ void CSVDoc::Operation::setBarColor(int type) case CSMDoc::State_Searching: - topColor = "#EBF1F6"; - midTopColor = "#ABD3EE"; - midBottomColor = "#89C3EB"; - bottomColor = "#D5EBFB"; // blue gloss #4 + topColor = "#6DB3F2"; + midTopColor = "#54A3EE"; + midBottomColor = "#3690F0"; + bottomColor = "#1E69DE"; // blue gloss #3 break; case CSMDoc::State_Verifying: @@ -142,13 +142,6 @@ void CSVDoc::Operation::setBarColor(int type) midBottomColor = "#B68D4C"; bottomColor = "#E9D4B3"; // l Brown 3D break; - - default: - - topColor = "#F2F6F8"; - bottomColor = "#E0EFF9"; - midTopColor = "#D8E1E7"; - midBottomColor = "#B5C6D0"; // gray gloss for undefined ops } mProgressBar->setStyleSheet(style.arg(topColor).arg(midTopColor).arg(midBottomColor).arg(bottomColor)); diff --git a/apps/opencs/view/doc/operations.cpp b/apps/opencs/view/doc/operations.cpp index 4fe53d6297..00736b93c5 100644 --- a/apps/opencs/view/doc/operations.cpp +++ b/apps/opencs/view/doc/operations.cpp @@ -8,6 +8,11 @@ #include "operation.hpp" +namespace +{ + constexpr int operationLineHeight = 40; +} + CSVDoc::Operations::Operations() { /// \todo make widget height fixed (exactly the height required to display all operations) @@ -20,7 +25,7 @@ CSVDoc::Operations::Operations() widgetContainer->setLayout(mLayout); setWidget(widgetContainer); setVisible(false); - setFixedHeight(widgetContainer->height()); + setFixedHeight(operationLineHeight); setTitleBarWidget(new QWidget(this)); } @@ -33,9 +38,6 @@ void CSVDoc::Operations::setProgress(int current, int max, int type, int threads return; } - int oldCount = static_cast(mOperations.size()); - int newCount = oldCount + 1; - Operation* operation = new Operation(type, this); connect(operation, qOverload(&Operation::abortOperation), this, &Operations::abortOperation); @@ -43,8 +45,8 @@ void CSVDoc::Operations::setProgress(int current, int max, int type, int threads mOperations.push_back(operation); operation->setProgress(current, max, threads); - if (oldCount > 0) - setFixedHeight(height() / oldCount * newCount); + int newCount = static_cast(mOperations.size()); + setFixedHeight(operationLineHeight * newCount); setVisible(true); } @@ -54,16 +56,14 @@ void CSVDoc::Operations::quitOperation(int type) for (std::vector::iterator iter(mOperations.begin()); iter != mOperations.end(); ++iter) if ((*iter)->getType() == type) { - int oldCount = static_cast(mOperations.size()); - int newCount = oldCount - 1; - mLayout->removeItem((*iter)->getLayout()); (*iter)->deleteLater(); mOperations.erase(iter); - if (oldCount > 1) - setFixedHeight(height() / oldCount * newCount); + int newCount = static_cast(mOperations.size()); + if (newCount > 0) + setFixedHeight(operationLineHeight * newCount); else setVisible(false);