diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index 5ad2416e..8f2b541c 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -430,6 +430,24 @@ void AppConfig::GetFontSizeRange(float *minSize, float *maxSize) #endif } +bool AppConfig::IsDarkStyle() +{ + if (frameOptions.style == THEME_STYLE_DARK){ + return true; + } + return false; +} + +QColor AppConfig::GetStyleColor() +{ + if (IsDarkStyle()){ + return QColor(38, 38, 38); + } + else{ + return QColor(248, 248, 248); + } +} + //-------------api QString GetIconPath() @@ -513,7 +531,7 @@ QString GetDecodeScriptDir() // ./decoders if (dir1.exists(path)) { - return path; + return path; QColor GetStyleColor(); } QDir dir(QCoreApplication::applicationDirPath()); diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index 0cccbebe..106db5ce 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -25,6 +25,7 @@ #include #include #include +#include #define LAN_CN 25 #define LAN_EN 31 @@ -158,6 +159,10 @@ public: static void GetFontSizeRange(float *minSize, float *maxSize); + bool IsDarkStyle(); + + QColor GetStyleColor(); + public: AppOptions appOptions; UserHistory userHistory; diff --git a/DSView/pv/dock/measuredock.cpp b/DSView/pv/dock/measuredock.cpp index 42e40304..a46e294c 100644 --- a/DSView/pv/dock/measuredock.cpp +++ b/DSView/pv/dock/measuredock.cpp @@ -215,6 +215,8 @@ void MeasureDock::reStyle() { (*it).del_bt->setIcon(QIcon(iconPath+"/del.svg")); } + + update_dist(); } void MeasureDock::refresh() @@ -592,23 +594,25 @@ void MeasureDock::update_dist() { auto &cursor_list = _view.get_cursorList(); + QColor bkColor = AppConfig::Instance().GetStyleColor(); + for (auto &inf : _dist_row_list) { if (inf.cursor1 != -1) { if (inf.cursor1 > (int)cursor_list.size()) { inf.start_bt->setText(""); - set_cursor_btn_color(inf.start_bt); inf.cursor1 = -1; } } + set_cursor_btn_color(inf.start_bt); if (inf.cursor2 != -1) { if (inf.cursor2 > (int)cursor_list.size()) { - inf.end_bt->setText(""); - set_cursor_btn_color(inf.end_bt); + inf.end_bt->setText(""); inf.cursor2 = -1; } } + set_cursor_btn_color(inf.end_bt); if (inf.cursor1 != -1 && inf.cursor2 != -1) { int64_t delta = _view.get_cursor_samples(inf.cursor1-1) - @@ -679,13 +683,23 @@ void MeasureDock::update_edge() void MeasureDock::set_cursor_btn_color(QPushButton *btn) { - bool ret; - const unsigned int start = btn->text().toInt(&ret) - 1; - QColor cursor_color = ret ? view::Ruler::CursorColorTable[start%CURSOR_COLOR_TABLE_SIZE] : QColor("#302F2F"); - QString border_width = ret ? "0px" : "1px"; - QString normal = "{background-color:" + cursor_color.name() + + //#302F2F + // QColor bkColor = AppConfig::Instance().IsDarkStyle() ? QColor("#383838") : QColor("#FFFFFF"); + + QColor bkColor = AppConfig::Instance().GetStyleColor(); + bool isCursor = false; + const unsigned int start = btn->text().toInt(&isCursor) - 1; + QColor cursor_color = isCursor ? view::Ruler::CursorColorTable[start%CURSOR_COLOR_TABLE_SIZE] : bkColor; + set_cursor_btn_color(btn, cursor_color, bkColor, isCursor); +} + +void MeasureDock::set_cursor_btn_color(QPushButton *btn, QColor cursorColor, QColor bkColor, bool isCursor) +{ + QString border_width = isCursor ? "0px" : "1px"; + QString hoverColor = isCursor ? cursorColor.darker().name() : bkColor.name(); + QString normal = "{background-color:" + cursorColor.name() + "; color:black" + "; border-width:" + border_width + ";}"; - QString hover = "{background-color:" + cursor_color.darker().name() + + QString hover = "{background-color:" + hoverColor + "; color:black" + "; border-width:" + border_width + ";}"; QString style = "QPushButton:hover" + hover + "QPushButton" + normal; diff --git a/DSView/pv/dock/measuredock.h b/DSView/pv/dock/measuredock.h index 43fb71ae..570111b3 100644 --- a/DSView/pv/dock/measuredock.h +++ b/DSView/pv/dock/measuredock.h @@ -113,6 +113,8 @@ private slots: void update_dist(); void update_edge(); void set_cursor_btn_color(QPushButton *btn); + void set_cursor_btn_color(QPushButton *btn, QColor cursorColor, QColor bkColor, bool isCursor); + void del_cursor(); void add_dist_measure(); diff --git a/DSView/pv/mainframe.cpp b/DSView/pv/mainframe.cpp index e90bc0e2..02ed135a 100644 --- a/DSView/pv/mainframe.cpp +++ b/DSView/pv/mainframe.cpp @@ -715,13 +715,9 @@ void MainFrame::AttachNativeWindow() int w = _normalRegion.w * k; int h = _normalRegion.h * k; - bool isDrak = false; - - if (AppConfig::Instance().frameOptions.style == THEME_STYLE_DARK){ - isDrak = true; - } - - WinNativeWidget *nativeWindow = new WinNativeWidget(x, y, w, h, isDrak); + + QColor bkColor = AppConfig::Instance().GetStyleColor(); + WinNativeWidget *nativeWindow = new WinNativeWidget(x, y, w, h, bkColor); nativeWindow->setGeometry(x, y, w, h); if (nativeWindow->Handle() == NULL){ diff --git a/DSView/pv/winnativewidget.cpp b/DSView/pv/winnativewidget.cpp index 99c548ea..e3cddbb4 100644 --- a/DSView/pv/winnativewidget.cpp +++ b/DSView/pv/winnativewidget.cpp @@ -48,7 +48,7 @@ namespace pv { //-----------------------------WinNativeWidget WinNativeWidget::WinNativeWidget(const int x, const int y, const int width, - const int height, bool isDark) + const int height, QColor backColor) { _childWindow = nullptr; childWidget = nullptr; @@ -60,6 +60,9 @@ WinNativeWidget::WinNativeWidget(const int x, const int y, const int width, _hCurrentMonitor = NULL; _shadow = NULL; _border_color = QColor(0x80,0x80,0x80); + int r = backColor.red(); + int g = backColor.green(); + int b = backColor.blue(); HINSTANCE hInstance = GetModuleHandle(nullptr); WNDCLASSEX wcx; @@ -74,13 +77,7 @@ WinNativeWidget::WinNativeWidget(const int x, const int y, const int width, wcx.cbWndExtra = 0; wcx.lpszClassName = L"DSViewWindowClass"; wcx.hCursor = LoadCursor(hInstance, IDC_ARROW); - - if (isDark){ - wcx.hbrBackground = CreateSolidBrush(RGB(38, 38, 38)); - } - else{ - wcx.hbrBackground = CreateSolidBrush(RGB(248, 248, 248)); - } + wcx.hbrBackground = CreateSolidBrush(RGB(r, g, b)); RegisterClassEx(&wcx); if (FAILED(RegisterClassEx(&wcx))) diff --git a/DSView/pv/winnativewidget.h b/DSView/pv/winnativewidget.h index 45740920..1659a34c 100644 --- a/DSView/pv/winnativewidget.h +++ b/DSView/pv/winnativewidget.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "interface/icallbacks.h" @@ -49,7 +50,7 @@ class WinNativeWidget { public: - WinNativeWidget(const int x, const int y, const int width, const int heigh, bool isDark); + WinNativeWidget(const int x, const int y, const int width, const int heigh, QColor backColor); ~WinNativeWidget(); static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);