Added demos.
This commit is contained in:
228
doc/gemini_fluent_light/main.cpp
Normal file
228
doc/gemini_fluent_light/main.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QProgressBar>
|
||||
#include <QPalette>
|
||||
#include <QFontDatabase>
|
||||
|
||||
// Hilfsfunktion: Setzt die Fluent LIGHT Palette global
|
||||
void applyFluentLightTheme(QApplication &app) {
|
||||
// 1. Schriftart setzen
|
||||
QFont font = app.font();
|
||||
font.setFamily("Segoe UI Variable Display");
|
||||
if (!QFontDatabase().families().contains("Segoe UI Variable Display")) {
|
||||
font.setFamily("Segoe UI");
|
||||
}
|
||||
font.setPointSize(10);
|
||||
app.setFont(font);
|
||||
|
||||
// 2. Die Palette definieren (Light Mode)
|
||||
QPalette p;
|
||||
// Window / Background: #F3F3F3 (Mica Alt)
|
||||
QColor colBackground("#F3F3F3");
|
||||
// Surface / Container: #FFFFFF (Solid White)
|
||||
QColor colSurface("#FFFFFF");
|
||||
// Accent: #0078D4 (System Accent Default)
|
||||
QColor colAccent("#0078D4");
|
||||
// Text: Black / Dark Gray
|
||||
QColor colText("#1A1A1A"); // Fast Schwarz für weicheren Kontrast
|
||||
QColor colSubText("#5D5D5D");
|
||||
|
||||
p.setColor(QPalette::Window, colBackground);
|
||||
p.setColor(QPalette::WindowText, colText);
|
||||
p.setColor(QPalette::Base, colSurface);
|
||||
p.setColor(QPalette::AlternateBase, colBackground);
|
||||
p.setColor(QPalette::ToolTipBase, colSurface);
|
||||
p.setColor(QPalette::ToolTipText, colText);
|
||||
p.setColor(QPalette::Text, colText);
|
||||
p.setColor(QPalette::Button, colSurface);
|
||||
p.setColor(QPalette::ButtonText, colText);
|
||||
p.setColor(QPalette::PlaceholderText, colSubText);
|
||||
p.setColor(QPalette::Highlight, colAccent);
|
||||
p.setColor(QPalette::HighlightedText, Qt::white); // Weißer Text auf Blau
|
||||
|
||||
app.setPalette(p);
|
||||
|
||||
// 3. Stylesheets für die Details
|
||||
app.setStyleSheet(R"(
|
||||
QWidget {
|
||||
background-color: #F3F3F3;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
/* CARD / CONTAINER STYLE */
|
||||
QFrame#Card {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #E5E5E5; /* Subtiler Rand zur Abgrenzung */
|
||||
border-radius: 8px;
|
||||
/* Optional: Qt unterstützt simple Schatten, aber auf Pi teuer.
|
||||
Der Border reicht hier. */
|
||||
}
|
||||
|
||||
/* BUTTONS */
|
||||
QPushButton {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #D1D1D1;
|
||||
border-bottom: 1px solid #B0B0B0; /* Tiefe simulieren */
|
||||
border-radius: 4px;
|
||||
padding: 6px 12px;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #FBFBFB;
|
||||
border: 1px solid #C0C0C0;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #F0F0F0;
|
||||
color: #5D5D5D;
|
||||
border-bottom: 1px solid #D1D1D1; /* Flach drücken */
|
||||
}
|
||||
|
||||
/* Accent Button (Primary) */
|
||||
QPushButton#PrimaryButton {
|
||||
background-color: #0078D4;
|
||||
color: #FFFFFF;
|
||||
border: 1px solid #0078D4;
|
||||
}
|
||||
QPushButton#PrimaryButton:hover {
|
||||
background-color: #1084D9;
|
||||
}
|
||||
QPushButton#PrimaryButton:pressed {
|
||||
background-color: #006CC1;
|
||||
border-color: #006CC1;
|
||||
}
|
||||
|
||||
/* INPUT FIELDS */
|
||||
QLineEdit {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #D1D1D1;
|
||||
border-bottom: 2px solid #8A8A8A; /* Stärkerer Indikator */
|
||||
border-radius: 4px;
|
||||
padding: 5px;
|
||||
selection-background-color: #0078D4;
|
||||
selection-color: #FFFFFF;
|
||||
}
|
||||
QLineEdit:hover {
|
||||
background-color: #FDFDFD;
|
||||
}
|
||||
QLineEdit:focus {
|
||||
background-color: #FFFFFF;
|
||||
border-bottom: 2px solid #0078D4; /* Active highlight */
|
||||
}
|
||||
|
||||
/* LABELS */
|
||||
QLabel#Title {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
color: #000000;
|
||||
}
|
||||
QLabel#Subtitle {
|
||||
font-size: 10pt;
|
||||
color: #5D5D5D;
|
||||
}
|
||||
|
||||
/* PROGRESS BAR */
|
||||
QProgressBar {
|
||||
border: none;
|
||||
background-color: #E0E0E0; /* Track Color */
|
||||
border-radius: 2px;
|
||||
height: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
QProgressBar::chunk {
|
||||
background-color: #0078D4; /* Accent Color */
|
||||
border-radius: 2px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// Eine "Card" Komponente (Identisch zum Dark Mode)
|
||||
class FluentCard : public QFrame {
|
||||
public:
|
||||
FluentCard(const QString &title, const QString &value) {
|
||||
setObjectName("Card");
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
|
||||
QLabel *lblTitle = new QLabel(title);
|
||||
lblTitle->setObjectName("Subtitle");
|
||||
|
||||
QLabel *lblValue = new QLabel(value);
|
||||
lblValue->setStyleSheet("font-size: 24pt; font-weight: 300; background: transparent;");
|
||||
// Wichtig: background transparent erzwingen, sonst erben Labels manchmal falsche Farbe
|
||||
|
||||
layout->addWidget(lblTitle);
|
||||
layout->addWidget(lblValue);
|
||||
layout->addStretch();
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// HIER: Light Theme anwenden
|
||||
applyFluentLightTheme(app);
|
||||
|
||||
QWidget window;
|
||||
window.setWindowTitle("Fluent Light Mode Demo");
|
||||
window.resize(800, 500);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(&window);
|
||||
mainLayout->setContentsMargins(24, 24, 24, 24);
|
||||
mainLayout->setSpacing(20);
|
||||
|
||||
// Header
|
||||
QLabel *header = new QLabel("Dashboard");
|
||||
header->setObjectName("Title");
|
||||
mainLayout->addWidget(header);
|
||||
|
||||
// Content Area
|
||||
QHBoxLayout *cardsLayout = new QHBoxLayout();
|
||||
cardsLayout->setSpacing(12);
|
||||
|
||||
cardsLayout->addWidget(new FluentCard("CPU Temp", "42.5 °C"));
|
||||
cardsLayout->addWidget(new FluentCard("Memory", "1.2 GB"));
|
||||
cardsLayout->addWidget(new FluentCard("Network", "12 Mb/s"));
|
||||
|
||||
mainLayout->addLayout(cardsLayout);
|
||||
|
||||
// Controls Area
|
||||
QFrame *controlsCard = new QFrame();
|
||||
controlsCard->setObjectName("Card");
|
||||
QVBoxLayout *controlsLayout = new QVBoxLayout(controlsCard);
|
||||
|
||||
QLabel *lblSettings = new QLabel("System Settings");
|
||||
lblSettings->setStyleSheet("font-size: 14pt; font-weight: bold; margin-bottom: 10px; background: transparent;");
|
||||
controlsLayout->addWidget(lblSettings);
|
||||
|
||||
// Input Row
|
||||
QHBoxLayout *inputRow = new QHBoxLayout();
|
||||
QLineEdit *edit = new QLineEdit();
|
||||
edit->setPlaceholderText("Enter Device Name...");
|
||||
QPushButton *btnApply = new QPushButton("Apply");
|
||||
btnApply->setObjectName("PrimaryButton");
|
||||
|
||||
inputRow->addWidget(edit);
|
||||
inputRow->addWidget(btnApply);
|
||||
controlsLayout->addLayout(inputRow);
|
||||
|
||||
// Progress Bar
|
||||
controlsLayout->addSpacing(10);
|
||||
QLabel *lblProgress = new QLabel("Processing...");
|
||||
lblProgress->setObjectName("Subtitle");
|
||||
controlsLayout->addWidget(lblProgress);
|
||||
|
||||
QProgressBar *progress = new QProgressBar();
|
||||
progress->setValue(75);
|
||||
progress->setTextVisible(false);
|
||||
controlsLayout->addWidget(progress);
|
||||
|
||||
mainLayout->addWidget(controlsCard);
|
||||
mainLayout->addStretch();
|
||||
|
||||
window.show();
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user