12#include <QtCore/QOperatingSystemVersion>
13#include <QtCore/QString>
15#include <QtGui/QGuiApplication>
51static inline QString statusLabelStyle(
const QString &bg =
"#6699ff",
52 const QString &fg =
"#000000") {
53#if defined(Q_OS_MACOS)
54 return QStringLiteral(
"QLabel{background-color: %1; color: %2; "
55 "border-radius: 6px; padding: 2px 8px; "
56 "border: 1px solid rgba(0,0,0,0.15)}")
58#elif defined(Q_OS_WIN)
59 return QStringLiteral(
"QLabel{background-color:%1; color:%2; "
60 "border-radius:4px; padding:0px 8px; "
61 "border:1px solid rgba(0,0,0,0.25)}")
64 return QStringLiteral(
"QLabel{background-color:%1; color:%2; "
65 "border-radius:1px; padding:1px 6px; "
66 "border:1px inset rgba(0,0,0,0.18)}")
71enum class TxStatusAppearance {
80static inline QString makeStyle(
const QString &bg,
const QString &fg) {
81#if defined(Q_OS_LINUX)
82 return QString(
"QLabel{background-color:%1; color:%2; "
83 "border-radius:1px; padding:1px 6px; "
84 "border:1px inset rgba(0,0,0,0.18);}")
86#elif defined(Q_OS_WIN)
87 return QString(
"QLabel{background-color:%1; color:%2; "
88 "border-radius:4px; padding:0px 8px; "
89 "border:1px solid rgba(0,0,0,0.25);}")
91#elif defined(Q_OS_MACOS)
92 return QString(
"QLabel{background-color:%1; color:%2; "
93 "border-radius:6px; padding:2px 8px; "
94 "border:1px solid rgba(0,0,0,0.15);}")
97 return QString(
"QLabel{background-color:%1; color:%2;}").arg(bg, fg);
102 switch (appearance) {
103 case TxStatusAppearance::Receiving:
104 return makeStyle(
"#22ff22",
"#000000");
105 case TxStatusAppearance::Transmitting:
106 return makeStyle(
"#ff2222",
"#000000");
107 case TxStatusAppearance::Decoding:
108 return makeStyle(
"#22ff22",
"#000000");
109 case TxStatusAppearance::IdleTimeout:
110 return makeStyle(
"#000000",
"#ffffff");
132static inline QString progress_bar_stylesheet(
bool small =
false) {
133 const QString base = QString(
"QProgressBar {"
135 " background-color: #ffffff;"
137 " text-align: center;"
141 "QProgressBar::chunk {"
142 " background-color: #a5cdff;"
143 " border-radius: %2px;"
147 const int height = small ? 10 : 14;
148 const int radius = small ? 3 : 5;
149 const QString barDim =
150 QString(
"min-height:%1px; max-height:%1px; border-radius:%2px;")
153 const QString chunkDim = QString(
"min-height:%1px;").arg(height);
154 return base.arg(barDim, QString::number(radius), chunkDim);
183 background-color: #6699ff;
190 font-family: "Segoe UI";
193 background-color: #4d7fff;
196 QPushButton:pressed {
197 background-color: #003EAA;
199 QPushButton:disabled {
200 background-color: #ececec;
205#elif defined(Q_OS_MACOS)
208 background-color: #6699ff;
215 font-family: "-apple-system";
218 background-color: #4d7fff;
221 QPushButton:pressed {
222 background-color: #003EAA;
224 QPushButton:disabled {
225 background-color: #ececec;
230#elif defined(Q_OS_LINUX)
233 background-color: #6699ff;
238 font-family: "Ubuntu", "Noto Sans";
241 background-color: #4d7fff;
243 QPushButton:pressed {
244 background-color: #003EAA;
246 QPushButton:disabled {
247 background-color: #ececec;
259static inline QString logFrameStyle() {
260#if defined(Q_OS_MACOS)
261 return QStringLiteral(
"QFrame#frame { background-color: #F2F2F0; }"
262 "QLabel#currentFreq {"
264 " background-color: black;"
265 " border-radius:6px; padding:0px 8px; "
266 " font-family: Monaco, 'Courier New', monospace;"
268 " font-weight: bold;"
272#elif defined(Q_OS_WIN)
273 return QStringLiteral(
"QFrame#frame { background-color: #DDEEFF; }"
274 "QLabel#currentFreq {"
276 " background-color: black;"
277 " border-radius:4px; padding:0px 8px; "
278 " font-family: Consolas, 'Courier New', monospace;"
280 " font-weight: bold;"
285 return QStringLiteral(
"QFrame#frame { background-color: #F2F2F0; }"
286 "QLabel#currentFreq {"
288 " background-color: black;"
289 " border-radius:0px; padding:0px 8px; "
291 " font-weight: bold;"
315#if defined(Q_OS_MACOS)
318constexpr const char *LogWidgetStyle =
319 "QFrame#logWidget { background-color: #F2F2F0; }";
321constexpr const char *DialFreqUpDownButtonStyle =
323 " background-color: #000000;"
327 " border-radius:2px;"
329 "QPushButton:pressed {"
330 " background-color: #222;"
333class OffsetSliderWidget :
public QWidget {
335 explicit OffsetSliderWidget(QWidget *parent =
nullptr) : QWidget(parent) {
336 auto *layout =
new QHBoxLayout(
this);
337 auto *caption =
new QLabel(
"Offset:",
this);
338 caption->setStyleSheet(
"QLabel { color: black; }");
339 slider =
new QSlider(Qt::Horizontal,
this);
341 slider->setStyleSheet(R
"(
343 background: transparent;
346 QSlider::groove:horizontal {
347 border: 1px solid #b0b0b0;
352 QSlider::handle:horizontal {
354 border: 1px solid #003eaa;
359 QSlider::sub-page:horizontal {
363 QSlider::add-page:horizontal {
368 slider->setRange(0, 3000);
369 slider->setValue(1500);
370 valueLabel = new QLabel(
"0 Hz",
this);
371 valueLabel->setStyleSheet(
"QLabel { color: black; }");
372 valueLabel->setMinimumWidth(60);
373 layout->addWidget(caption);
374 layout->addWidget(slider, 1);
375 layout->addWidget(valueLabel);
376 connect(slider, &QSlider::valueChanged,
this, [
this](
int val) {
377 valueLabel->setText(QString(
"%1 Hz").arg(val));
378 if (onValueChanged) onValueChanged(val);
382 int offset()
const {
return slider->value(); }
383 void setValue(
int hz) { slider->setValue(hz); }
384 void setOnValueChanged(std::function<
void(
int)> cb) { onValueChanged = cb; }
389 std::function<void(
int)> onValueChanged;
392constexpr const char *LabCallsignStyle =
"QLabel {"
398constexpr const char *LabUTCStyle =
400 " border-radius:6px;"
403 " font-family: Monaco, 'Courier New', monospace;"
404 " font-weight: bold;"
405 " background-color: black;"
409constexpr const char *ButtonGridStyle =
411 " background-color:lightgray;"
412 " padding:0.25em 0.25em; font-weight:normal;"
413 " border-style:solid;"
415 " border-radius:6px;"
417 "QPushButton:checked {"
418 " background-color:#6699ff;"
421constexpr const char *MonitorTxButtonStyle =
423 " background-color:lightgray;"
425 " padding:0.25em 0.25em; font-weight:normal;"
426 " border-style:solid;"
428 " border-radius:6px;"
430 "QPushButton:checked {"
431 " background-color:#22FF22;"
434 "QPushButton[transmitting=\"true\"] {"
435 " background-color:#FF2222;"
439constexpr const char *MonitorButtonStyle =
441 " background-color:lightgray;"
443 " padding:0.25em 0.25em; font-weight:normal;"
444 " border-style:solid;"
446 " border-radius:6px;"
448 "QPushButton:checked {"
449 " background-color:#22FF22;"
453constexpr const char *LogQSOButtonStyle =
455 " background-color:#6699ff;"
457 " padding:0.25em 0.25em; font-weight:normal;"
458 " border-style:solid;"
460 " border-radius:6px;"
462 "QPushButton:checked {"
463 " background-color:#6699ff;"
467constexpr const char *TuneButtonStyle =
469 " background-color:lightgray;"
471 " padding:0.25em 0.25em; font-weight:normal;"
472 " border-style:solid;"
474 " border-radius:6px;"
476 "QPushButton:checked {"
477 " background-color:#6699ff;"
481constexpr const char *ModeButtonStyle =
483 " padding:0.25em 0.25em; font-weight:bold;"
484 " border-style:solid;"
486 " border-radius:6px;"
487 " background-color:#6699ff;"
490 "QPushButton:checked {"
491 " background-color:#6699ff;"
495constexpr const char *SpotButtonStyle =
497 " background-color:lightgray;"
499 " padding:0.25em 0.25em; font-weight:normal;"
500 " border-style:solid;"
502 " border-radius:6px;"
504 "QPushButton:checked {"
505 " background-color:#6699ff;"
510#elif defined(Q_OS_WIN)
513constexpr const char *LogWidgetStyle =
514 "QFrame#logWidget { background-color: #DDEEFF; }";
516constexpr const char *DialFreqUpDownButtonStyle =
518 " background-color: #000000;"
522 " border-radius:2px;"
524 "QPushButton:pressed {"
525 " background-color: #222;"
528constexpr const char *LabDialFreqOffsetStyle =
"QLabel {"
534constexpr const char *LabCallsignStyle =
"QLabel {"
540constexpr const char *LabUTCStyle =
542 " border-radius:4px;"
545 " font-family: Consolas, 'Courier New', monospace;"
546 " font-weight: bold;"
547 " background-color: black;"
551constexpr const char *ButtonGridStyle =
553 " background-color:lightgray;"
554 " padding:0.25em 0.25em; font-weight:normal;"
555 " border-style:solid;"
557 " border-radius:4px;"
559 "QPushButton:checked {"
560 " background-color:#6699ff;"
563constexpr const char *MonitorTxButtonStyle =
565 " background-color:lightgray;"
567 " padding:0.25em 0.25em; font-weight:normal;"
568 " border-style:solid;"
570 " border-radius:4px;"
572 "QPushButton:checked {"
573 " background-color:#22FF22;"
576 "QPushButton[transmitting=\"true\"] {"
577 " background-color:#FF2222;"
581constexpr const char *MonitorButtonStyle =
583 " background-color:lightgray;"
585 " padding:0.25em 0.25em; font-weight:normal;"
586 " border-style:solid;"
588 " border-radius:4px;"
590 "QPushButton:checked {"
591 " background-color:#22FF22;"
595constexpr const char *LogQSOButtonStyle =
597 " background-color:lightgray;"
599 " padding:0.25em 0.25em; font-weight:normal;"
600 " border-style:solid;"
602 " border-radius:4px;"
604 "QPushButton:checked {"
605 " background-color:#6699ff;"
609constexpr const char *TuneButtonStyle = LogQSOButtonStyle;
611constexpr const char *ModeButtonStyle =
613 " padding:0.25em 0.25em; font-weight:bold;"
614 " border-style:solid;"
616 " border-radius:4px;"
617 " background-color:#6699ff;"
620 "QPushButton:checked {"
621 " background-color:#6699ff;"
625constexpr const char *SpotButtonStyle =
627 " background-color:lightgray;"
629 " padding:0.25em 0.25em; font-weight:normal;"
630 " border-style:solid;"
632 " border-radius:4px;"
634 "QPushButton:checked {"
635 " background-color:#6699ff;"
644constexpr const char *LogWidgetStyle =
645 "QFrame#logWidget { background-color: #F2F2F0; }";
648constexpr const char *DialFreqUpDownButtonStyle =
650 " background-color: #000000;"
654 " border-radius:0px;"
656 "QPushButton:pressed {"
657 " background-color: #222;"
660constexpr const char *LabDialFreqOffsetStyle =
"QLabel {"
667constexpr const char *LabCallsignStyle =
"QLabel {"
674constexpr const char *LabUTCStyle =
676 " border-radius:0px;"
679 " font-family: \"DejaVu Sans Mono\", \"Liberation Mono\", \"Noto Mono\", \"Ubuntu Mono\", monospace;"
680 " font-weight: bold;"
681 " background-color: black;"
686constexpr const char *ButtonGridStyle =
688 " background-color:lightgray;"
689 " padding:0.25em 0.25em; font-weight:normal;"
690 " border-style:solid;"
692 " border-radius:0px;"
694 "QPushButton:checked {"
695 " background-color:#6699ff;"
699constexpr const char *MonitorTxButtonStyle =
701 " background-color:lightgray;"
702 " padding:0.25em 0.25em; font-weight:normal;"
703 " border-style:solid;"
705 " border-radius:0px;"
707 "QPushButton:checked {"
708 " background-color:#22FF22;"
710 "QPushButton[transmitting=\"true\"] {"
711 " background-color:#FF2222;"
715constexpr const char *MonitorButtonStyle =
717 " background-color:lightgray;"
718 " padding:0.25em 0.25em; font-weight:normal;"
719 " border-style:solid;"
721 " border-radius:0px;"
723 "QPushButton:checked {"
724 " background-color:#22FF22;"
728constexpr const char *LogQSOButtonStyle =
730 " background-color:lightgray;"
731 " padding:0.25em 0.25em; font-weight:normal;"
732 " border-style:solid;"
734 " border-radius:0px;"
736 "QPushButton:checked {"
737 " background-color:#6699ff;"
740constexpr const char *TuneButtonStyle = LogQSOButtonStyle;
743constexpr const char *ModeButtonStyle =
745 " padding:0.25em 0.25em; font-weight:bold;"
746 " border-style:solid;"
748 " border-radius:0px;"
749 " background-color:#6699ff;"
751 "QPushButton:checked {"
752 " background-color:#6699ff;"
756constexpr const char *SpotButtonStyle =
758 " background-color:lightgray;"
759 " padding:0.25em 0.25em; font-weight:normal;"
760 " border-style:solid;"
762 " border-radius:0px;"
764 "QPushButton:checked {"
765 " background-color:#6699ff;"
Defines platform-specific style constants for JS8Call's header bar controls.
QString buttonStyle()
Returns a platform-native QPushButton stylesheet.
Definition styles.h:179
QString txStatusLabelStyle(TxStatusAppearance appearance)
Returns the QSS stylesheet string for a given TX status state.
Definition styles.h:101