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
|
#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
|
//-------------api
|
||||||
QString GetIconPath()
|
QString GetIconPath()
|
||||||
@@ -513,7 +531,7 @@ QString GetDecodeScriptDir()
|
|||||||
// ./decoders
|
// ./decoders
|
||||||
if (dir1.exists(path))
|
if (dir1.exists(path))
|
||||||
{
|
{
|
||||||
return path;
|
return path; QColor GetStyleColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir dir(QCoreApplication::applicationDirPath());
|
QDir dir(QCoreApplication::applicationDirPath());
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
#define LAN_CN 25
|
#define LAN_CN 25
|
||||||
#define LAN_EN 31
|
#define LAN_EN 31
|
||||||
@@ -158,6 +159,10 @@ public:
|
|||||||
|
|
||||||
static void GetFontSizeRange(float *minSize, float *maxSize);
|
static void GetFontSizeRange(float *minSize, float *maxSize);
|
||||||
|
|
||||||
|
bool IsDarkStyle();
|
||||||
|
|
||||||
|
QColor GetStyleColor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AppOptions appOptions;
|
AppOptions appOptions;
|
||||||
UserHistory userHistory;
|
UserHistory userHistory;
|
||||||
|
|||||||
@@ -215,6 +215,8 @@ void MeasureDock::reStyle()
|
|||||||
{
|
{
|
||||||
(*it).del_bt->setIcon(QIcon(iconPath+"/del.svg"));
|
(*it).del_bt->setIcon(QIcon(iconPath+"/del.svg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_dist();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeasureDock::refresh()
|
void MeasureDock::refresh()
|
||||||
@@ -592,23 +594,25 @@ void MeasureDock::update_dist()
|
|||||||
{
|
{
|
||||||
auto &cursor_list = _view.get_cursorList();
|
auto &cursor_list = _view.get_cursorList();
|
||||||
|
|
||||||
|
QColor bkColor = AppConfig::Instance().GetStyleColor();
|
||||||
|
|
||||||
for (auto &inf : _dist_row_list)
|
for (auto &inf : _dist_row_list)
|
||||||
{
|
{
|
||||||
if (inf.cursor1 != -1) {
|
if (inf.cursor1 != -1) {
|
||||||
if (inf.cursor1 > (int)cursor_list.size()) {
|
if (inf.cursor1 > (int)cursor_list.size()) {
|
||||||
inf.start_bt->setText("");
|
inf.start_bt->setText("");
|
||||||
set_cursor_btn_color(inf.start_bt);
|
|
||||||
inf.cursor1 = -1;
|
inf.cursor1 = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set_cursor_btn_color(inf.start_bt);
|
||||||
|
|
||||||
if (inf.cursor2 != -1) {
|
if (inf.cursor2 != -1) {
|
||||||
if (inf.cursor2 > (int)cursor_list.size()) {
|
if (inf.cursor2 > (int)cursor_list.size()) {
|
||||||
inf.end_bt->setText("");
|
inf.end_bt->setText("");
|
||||||
set_cursor_btn_color(inf.end_bt);
|
|
||||||
inf.cursor2 = -1;
|
inf.cursor2 = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set_cursor_btn_color(inf.end_bt);
|
||||||
|
|
||||||
if (inf.cursor1 != -1 && inf.cursor2 != -1) {
|
if (inf.cursor1 != -1 && inf.cursor2 != -1) {
|
||||||
int64_t delta = _view.get_cursor_samples(inf.cursor1-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)
|
void MeasureDock::set_cursor_btn_color(QPushButton *btn)
|
||||||
{
|
{
|
||||||
bool ret;
|
//#302F2F
|
||||||
const unsigned int start = btn->text().toInt(&ret) - 1;
|
// QColor bkColor = AppConfig::Instance().IsDarkStyle() ? QColor("#383838") : QColor("#FFFFFF");
|
||||||
QColor cursor_color = ret ? view::Ruler::CursorColorTable[start%CURSOR_COLOR_TABLE_SIZE] : QColor("#302F2F");
|
|
||||||
QString border_width = ret ? "0px" : "1px";
|
QColor bkColor = AppConfig::Instance().GetStyleColor();
|
||||||
QString normal = "{background-color:" + cursor_color.name() +
|
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 + ";}";
|
"; 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 + ";}";
|
"; color:black" + "; border-width:" + border_width + ";}";
|
||||||
QString style = "QPushButton:hover" + hover +
|
QString style = "QPushButton:hover" + hover +
|
||||||
"QPushButton" + normal;
|
"QPushButton" + normal;
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ private slots:
|
|||||||
void update_dist();
|
void update_dist();
|
||||||
void update_edge();
|
void update_edge();
|
||||||
void set_cursor_btn_color(QPushButton *btn);
|
void set_cursor_btn_color(QPushButton *btn);
|
||||||
|
void set_cursor_btn_color(QPushButton *btn, QColor cursorColor, QColor bkColor, bool isCursor);
|
||||||
|
|
||||||
void del_cursor();
|
void del_cursor();
|
||||||
void add_dist_measure();
|
void add_dist_measure();
|
||||||
|
|
||||||
|
|||||||
@@ -715,13 +715,9 @@ void MainFrame::AttachNativeWindow()
|
|||||||
int w = _normalRegion.w * k;
|
int w = _normalRegion.w * k;
|
||||||
int h = _normalRegion.h * k;
|
int h = _normalRegion.h * k;
|
||||||
|
|
||||||
bool isDrak = false;
|
|
||||||
|
QColor bkColor = AppConfig::Instance().GetStyleColor();
|
||||||
if (AppConfig::Instance().frameOptions.style == THEME_STYLE_DARK){
|
WinNativeWidget *nativeWindow = new WinNativeWidget(x, y, w, h, bkColor);
|
||||||
isDrak = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
WinNativeWidget *nativeWindow = new WinNativeWidget(x, y, w, h, isDrak);
|
|
||||||
nativeWindow->setGeometry(x, y, w, h);
|
nativeWindow->setGeometry(x, y, w, h);
|
||||||
|
|
||||||
if (nativeWindow->Handle() == NULL){
|
if (nativeWindow->Handle() == NULL){
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace pv {
|
|||||||
|
|
||||||
//-----------------------------WinNativeWidget
|
//-----------------------------WinNativeWidget
|
||||||
WinNativeWidget::WinNativeWidget(const int x, const int y, const int width,
|
WinNativeWidget::WinNativeWidget(const int x, const int y, const int width,
|
||||||
const int height, bool isDark)
|
const int height, QColor backColor)
|
||||||
{
|
{
|
||||||
_childWindow = nullptr;
|
_childWindow = nullptr;
|
||||||
childWidget = nullptr;
|
childWidget = nullptr;
|
||||||
@@ -60,6 +60,9 @@ WinNativeWidget::WinNativeWidget(const int x, const int y, const int width,
|
|||||||
_hCurrentMonitor = NULL;
|
_hCurrentMonitor = NULL;
|
||||||
_shadow = NULL;
|
_shadow = NULL;
|
||||||
_border_color = QColor(0x80,0x80,0x80);
|
_border_color = QColor(0x80,0x80,0x80);
|
||||||
|
int r = backColor.red();
|
||||||
|
int g = backColor.green();
|
||||||
|
int b = backColor.blue();
|
||||||
|
|
||||||
HINSTANCE hInstance = GetModuleHandle(nullptr);
|
HINSTANCE hInstance = GetModuleHandle(nullptr);
|
||||||
WNDCLASSEX wcx;
|
WNDCLASSEX wcx;
|
||||||
@@ -74,13 +77,7 @@ WinNativeWidget::WinNativeWidget(const int x, const int y, const int width,
|
|||||||
wcx.cbWndExtra = 0;
|
wcx.cbWndExtra = 0;
|
||||||
wcx.lpszClassName = L"DSViewWindowClass";
|
wcx.lpszClassName = L"DSViewWindowClass";
|
||||||
wcx.hCursor = LoadCursor(hInstance, IDC_ARROW);
|
wcx.hCursor = LoadCursor(hInstance, IDC_ARROW);
|
||||||
|
wcx.hbrBackground = CreateSolidBrush(RGB(r, g, b));
|
||||||
if (isDark){
|
|
||||||
wcx.hbrBackground = CreateSolidBrush(RGB(38, 38, 38));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
wcx.hbrBackground = CreateSolidBrush(RGB(248, 248, 248));
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterClassEx(&wcx);
|
RegisterClassEx(&wcx);
|
||||||
if (FAILED(RegisterClassEx(&wcx)))
|
if (FAILED(RegisterClassEx(&wcx)))
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <Windowsx.h>
|
#include <Windowsx.h>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
#include "interface/icallbacks.h"
|
#include "interface/icallbacks.h"
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ class WinNativeWidget
|
|||||||
{
|
{
|
||||||
public:
|
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();
|
~WinNativeWidget();
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|||||||
Reference in New Issue
Block a user