Files
fmviewer3/project/fm_viewer/ui/fm_layer.cpp
2026-02-21 17:11:31 +09:00

121 lines
4.7 KiB
C++

#include "fm_layer.h"
#include <QDebug>
void FMWidgetBorder(QWidget* w,const char* name, int c) {
w->setObjectName(name);
QString color = QString().sprintf("#%06X",c);
QString style = "QWidget#%name%{border: 1px solid %color%;}";
w->setStyleSheet(style.replace("%name%",name).replace("%color%",color));
}
void FMWidgetBackground(QWidget* w,const char* name, int c)
{
// background-color: #818181;
w->setObjectName(name);
QString color = QString().sprintf("#%06X",c);
QString style = "QWidget#%name%{background-color: %color%;}";
w->setStyleSheet(style.replace("%name%",name).replace("%color%",color));
}
void FMWidgetBorderBackground(QWidget* w,const char* name, int clBack, int clBorder) {
w->setObjectName(name);
QString bg = QString().sprintf("#%06X",clBack);
QString border = QString().sprintf("#%06X",clBorder);
QString style = "QWidget#%name%{border: 1px solid %border%;background-color: %bg%;}";
w->setStyleSheet(style.replace("%name%",name).replace("%border%",border).replace("%bg%",bg));
}
void FMWidgetBottomBorderBackground(QWidget* w,const char* name, int clBack, int clBorder)
{
w->setObjectName(name);
QString bg = QString().sprintf("#%06X",clBack);
QString border = QString().sprintf("#%06X",clBorder);
QString style = "QWidget#%name%{border: 1px solid %border%;border-left: none;border-right: none;border-top: none;background-color: %bg%;}";
w->setStyleSheet(style.replace("%name%",name).replace("%border%",border).replace("%bg%",bg));
}
void FMLabel(QLabel* lb,const char* name, const char* font,int c, int size, bool bold)
{
lb->setObjectName(name);
QString color = QString().sprintf("#%06X",c);
QString style = "QLabel#%name%{font-family: %font%;color : %color%;font-size: %size%px;font-weight: %weight%;}";
lb->setStyleSheet(style.replace("%name%",name).
replace("%color%",color).
replace("%font%",font).
replace("%size%",QString::number(size)).
replace("%weight%",bold ? "bold" : "normal"));
}
void FMLabelBackground(QLabel* lb,const char* name, const char* font,int c, int size, bool bold, int bg)
{
lb->setObjectName(name);
QString color = QString().sprintf("#%06X",c);
QString background = QString().sprintf("#%06X",bg);
QString style = "QLabel#%name%{font-family: %font%;color : %color%;font-size: %size%px;font-weight: %weight%;background-color: %bg%;border-radius: 3px;}";
lb->setStyleSheet(style.replace("%name%",name).
replace("%bg%",background).
replace("%color%",color).
replace("%font%",font).
replace("%size%",QString::number(size)).
replace("%weight%",bold ? "bold" : "normal"));
}
void FMSlider(QSlider* sl,const char* name,int cp, int cb,bool small)
{
sl->setFixedHeight(small ? 14 : 18);
sl->setObjectName(name);
// LEFT BAR = sub-page:horizontal
// RIGHT BAR = add-page:horizontal
// border: 1px solid red;
// margin: 7px 0px 7px 0px;
// margin: 7px 0px 7px 0px;
const QString knobName = small ? "slider_knob_small" : "slider_knob";
const QString border = small ? "6" : "7";
const QString height = small ? "2" : "4";
// margin: top, left???
QString style = "\
QSlider#%name%\
{\
}\
QSlider#%name%::groove:horizontal\
{\
border: %border%px;\
height: %height%px;\
}\
QSlider#%name%::sub-page:horizontal\
{\
background: %color_cp%;\
}\
QSlider#%name%::add-page:horizontal\
{\
background: %color_cb%;\
}\
QSlider#%name%::handle:horizontal\
{\
image: url(:/image/%knob%.png);\
margin: -%border%px -0px -%border%px -0px;\
}\
QSlider#%name%::handle:horizontal:hover:!pressed\
{\
image: url(:/image/%knob%_1.png);\
margin: -%border%px -0px -%border%px -0px;\
}\
QSlider#%name%::handle:horizontal:pressed\
{\
image: url(:/image/%knob%_2.png);\
margin: -%border%px -0px -%border%px -0px;\
}\
QSlider#%name%::handle:horizontal:disabled\
{\
image: url(:/image/%knob%_3.png);\
margin: -%border%px -0px -%border%px -0px;\
}";
sl->setStyleSheet(style.replace("%name%",name).
replace("%knob%",knobName).
replace("%border%",border).
replace("%height%",height).
replace("%color_cb%",QString().sprintf("#%06X",cb)).
replace("%color_cp%",QString().sprintf("#%06X",cp)));
}
//_paramTextEdit->setStyleSheet("font-family: Fixedsys;color : #00FF00;background-color: #111111;border:1px;border-style:solid;border-color:#313131;");