forked from Ivasoft/DSView
fix: The button's used an error background color, on the measure pannel
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QColor>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <Windowsx.h>
|
||||
#include <QWidget>
|
||||
#include <QByteArray>
|
||||
#include <QColor>
|
||||
|
||||
#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);
|
||||
|
||||
Reference in New Issue
Block a user