Added more demo stuff.
This commit is contained in:
Binary file not shown.
224
doc/fancy_switch/.qtcreator/fancy_switch.pro.user
Normal file
224
doc/fancy_switch/.qtcreator/fancy_switch.pro.user
Normal file
@@ -0,0 +1,224 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 18.0.1, 2025-12-31T16:15:34. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{350f6538-4791-42f9-b43d-6ea1a7b22b7b}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="qlonglong">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoDetect">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.LineEndingBehavior">1</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
|
||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<value type="bool" key="AutoTest.ApplyFilter">false</value>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">16</value>
|
||||
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="RcSync">0</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="bool" key="HasPerBcDcs">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.10.1 MinGW 64-bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.10.1 MinGW 64-bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.6101.win64_mingw_kit</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\syncMePlease\projects.now\fancy_switch\build\Desktop_Qt_6_10_1_MinGW_64_bit-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/syncMePlease/projects.now/fancy_switch/build/Desktop_Qt_6_10_1_MinGW_64_bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph "dwarf,4096" -F 250</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/syncMePlease/projects.now/fancy_switch/fancy_switch.pro</value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph "dwarf,4096" -F 250</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/syncMePlease/projects.now/fancy_switch/fancy_switch.pro</value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="qlonglong">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
26
doc/fancy_switch/fancy_switch.pro
Normal file
26
doc/fancy_switch/fancy_switch.pro
Normal file
@@ -0,0 +1,26 @@
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
themetogglewidget.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
themetogglewidget.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
54
doc/fancy_switch/main.cpp
Normal file
54
doc/fancy_switch/main.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// ============================================================================
|
||||
// main.cpp - Vollständiges Beispiel
|
||||
// ============================================================================
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QStatusBar>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <mainwindow.h>
|
||||
#include <themetogglewidget.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QMainWindow window;
|
||||
window.setWindowTitle("Theme Toggle Demo");
|
||||
window.resize(600, 400);
|
||||
|
||||
// Central Widget
|
||||
QWidget* central = new QWidget();
|
||||
QVBoxLayout* layout = new QVBoxLayout(central);
|
||||
|
||||
QLabel* label = new QLabel("Toggle theme using the button in the status bar →");
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setStyleSheet("font-size: 14pt;");
|
||||
layout->addWidget(label);
|
||||
|
||||
window.setCentralWidget(central);
|
||||
|
||||
// StatusBar mit Theme Toggle
|
||||
QStatusBar* statusBar = window.statusBar();
|
||||
statusBar->showMessage("Ready");
|
||||
|
||||
ThemeToggleWidget* themeToggle = new ThemeToggleWidget();
|
||||
statusBar->addPermanentWidget(themeToggle);
|
||||
|
||||
// Optional: Speichere Theme-Einstellung
|
||||
QObject::connect(themeToggle, &ThemeToggleWidget::themeChanged,
|
||||
[](bool isDark) {
|
||||
// Settings speichern
|
||||
// QSettings settings;
|
||||
// settings.setValue("theme/darkMode", isDark);
|
||||
qDebug() << "Theme:" << (isDark ? "Dark" : "Light");
|
||||
});
|
||||
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
1
doc/fancy_switch/mainwindow.cpp
Normal file
1
doc/fancy_switch/mainwindow.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "mainwindow.h"
|
||||
122
doc/fancy_switch/mainwindow.h
Normal file
122
doc/fancy_switch/mainwindow.h
Normal file
@@ -0,0 +1,122 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
// MainWindow.h
|
||||
#include <QMainWindow>
|
||||
#include <QStatusBar>
|
||||
#include <QToolBar>
|
||||
#include "ThemeToggleWidget.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget* parent = nullptr) : QMainWindow(parent) {
|
||||
setupUI();
|
||||
setupStatusBar();
|
||||
}
|
||||
|
||||
private:
|
||||
void setupUI() {
|
||||
// Dein UI Setup
|
||||
setWindowTitle("My Application");
|
||||
resize(800, 600);
|
||||
}
|
||||
|
||||
void setupStatusBar() {
|
||||
QStatusBar* statusBar = this->statusBar();
|
||||
statusBar->setSizeGripEnabled(true);
|
||||
|
||||
// Theme Toggle Widget rechts hinzufügen
|
||||
ThemeToggleWidget* themeToggle = new ThemeToggleWidget(this);
|
||||
statusBar->addPermanentWidget(themeToggle);
|
||||
|
||||
// Optional: Reagiere auf Theme-Änderungen
|
||||
connect(themeToggle, &ThemeToggleWidget::themeChanged,
|
||||
this, &MainWindow::onThemeChanged);
|
||||
|
||||
// Status-Message links
|
||||
statusBar->showMessage("Ready");
|
||||
}
|
||||
|
||||
private slots:
|
||||
void onThemeChanged(bool isDarkMode) {
|
||||
qDebug() << "Theme changed to:" << (isDarkMode ? "Dark" : "Light");
|
||||
|
||||
// Hier kannst du zusätzliche Aktionen durchführen:
|
||||
// - Icons aktualisieren
|
||||
// - Custom Widgets neu zeichnen
|
||||
// - Settings speichern
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// Alternative: Mit QAction für Menu/Toolbar
|
||||
// ============================================================================
|
||||
|
||||
/*
|
||||
class MainWindowB : public MainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindowB(QWidget* parent = nullptr) : MainWindow(parent)
|
||||
{
|
||||
//setupUI();
|
||||
setupThemeToggle();
|
||||
}
|
||||
|
||||
private:
|
||||
void setupThemeToggle()
|
||||
{
|
||||
// Als QAction (kann in Menu UND StatusBar)
|
||||
m_themeAction = new QAction(this);
|
||||
m_themeAction->setText("🌙"); // Initial: Dark Mode Icon
|
||||
m_themeAction->setToolTip("Toggle Dark/Light Mode");
|
||||
|
||||
connect(m_themeAction, &QAction::triggered, this, &MainWindowB::toggleTheme);
|
||||
|
||||
// In Toolbar
|
||||
QToolBar* toolbar = addToolBar("Main");
|
||||
toolbar->addAction(m_themeAction);
|
||||
|
||||
// UND in StatusBar
|
||||
QPushButton* statusBarThemeBtn = new QPushButton("🌙", this);
|
||||
statusBarThemeBtn->setFixedSize(32, 24);
|
||||
statusBarThemeBtn->setFlat(true);
|
||||
statusBarThemeBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(statusBarThemeBtn, &QPushButton::clicked, this, &MainWindowB::toggleTheme);
|
||||
|
||||
statusBar()->addPermanentWidget(statusBarThemeBtn);
|
||||
}
|
||||
|
||||
private slots:
|
||||
void toggleTheme()
|
||||
{
|
||||
m_isDarkMode = !m_isDarkMode;
|
||||
|
||||
QString icon = m_isDarkMode ? "☀️" : "🌙";
|
||||
m_themeAction->setText(icon);
|
||||
|
||||
// Theme anwenden...
|
||||
if (m_isDarkMode)
|
||||
{
|
||||
applyDarkTheme();
|
||||
} else {
|
||||
applyLightTheme();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_isDarkMode = true;
|
||||
QAction* m_themeAction;
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
31
doc/fancy_switch/mainwindow.ui
Normal file
31
doc/fancy_switch/mainwindow.ui
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
2
doc/fancy_switch/themetogglewidget.cpp
Normal file
2
doc/fancy_switch/themetogglewidget.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "themetogglewidget.h"
|
||||
|
||||
278
doc/fancy_switch/themetogglewidget.h
Normal file
278
doc/fancy_switch/themetogglewidget.h
Normal file
@@ -0,0 +1,278 @@
|
||||
// ThemeToggleWidget.h
|
||||
#ifndef THEMETOGGLEWIDGET_H
|
||||
#define THEMETOGGLEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPainter>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
class ThemeToggleWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int position READ position WRITE setPosition)
|
||||
|
||||
public:
|
||||
|
||||
explicit ThemeToggleWidget(QWidget* parent = nullptr)
|
||||
: QWidget(parent), m_isDarkMode(true), m_position(0) {
|
||||
|
||||
setupUI();
|
||||
applyDarkTheme();
|
||||
|
||||
}
|
||||
|
||||
bool isDarkMode() const { return m_isDarkMode; }
|
||||
|
||||
void setDarkMode(bool dark)
|
||||
{
|
||||
if (m_isDarkMode != dark)
|
||||
{
|
||||
m_isDarkMode = dark;
|
||||
animateToggle();
|
||||
applyTheme();
|
||||
emit themeChanged(m_isDarkMode);
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
void themeChanged(bool isDarkMode);
|
||||
|
||||
private slots:
|
||||
|
||||
void toggleTheme()
|
||||
{
|
||||
setDarkMode(!m_isDarkMode);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void setupUI()
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
// Toggle Button
|
||||
m_toggleButton = new QPushButton(this);
|
||||
m_toggleButton->setFixedSize(64, 28);
|
||||
m_toggleButton->setCursor(Qt::PointingHandCursor);
|
||||
m_toggleButton->setFlat(true);
|
||||
|
||||
connect(m_toggleButton, &QPushButton::clicked, this, &ThemeToggleWidget::toggleTheme);
|
||||
|
||||
layout->addWidget(m_toggleButton);
|
||||
|
||||
setFixedSize(64, 28);
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent*) override
|
||||
{
|
||||
qDebug() << " --- paint!";
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
int thumbX = 2 + m_position;
|
||||
/*
|
||||
// Track background
|
||||
QColor trackColor = m_isDarkMode ? QColor(0x3A3A3A) : QColor(0xE1DFDD);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(trackColor);
|
||||
painter.drawRoundedRect(rect(), 14, 14);
|
||||
|
||||
// Animated thumb
|
||||
int thumbX = 2 + m_position;
|
||||
QColor thumbColor = m_isDarkMode ? QColor(0x1F1F1F) : QColor(0xFFFFFF);
|
||||
|
||||
// Shadow
|
||||
painter.setBrush(QColor(0, 0, 0, 30));
|
||||
painter.drawEllipse(thumbX + 1, 3, 22, 22);
|
||||
|
||||
// Thumb
|
||||
painter.setBrush(thumbColor);
|
||||
painter.drawEllipse(thumbX, 2, 24, 24);
|
||||
|
||||
|
||||
// Icon on thumb
|
||||
painter.setPen(m_isDarkMode ? QColor(0xFFD700) : QColor(0xFFA500));
|
||||
QFont iconFont = font();
|
||||
iconFont.setPointSize(12);
|
||||
painter.setFont(iconFont);
|
||||
*/
|
||||
|
||||
QString icon = "FITZ!";// m_isDarkMode ? "🌙" : "☀️";
|
||||
painter.drawText(QRect(0, 2, 24, 24), Qt::AlignLeft, icon);
|
||||
}
|
||||
|
||||
int position() const { return m_position; }
|
||||
void setPosition(int pos) {
|
||||
m_position = pos;
|
||||
update();
|
||||
}
|
||||
|
||||
void animateToggle()
|
||||
{
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(this, "position");
|
||||
anim->setDuration(200);
|
||||
anim->setEasingCurve(QEasingCurve::InOutQuad);
|
||||
anim->setStartValue(m_position);
|
||||
anim->setEndValue(m_isDarkMode ? 36 : 0);
|
||||
anim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
void applyTheme()
|
||||
{
|
||||
if (m_isDarkMode) {
|
||||
applyDarkTheme();
|
||||
} else {
|
||||
applyLightTheme();
|
||||
}
|
||||
}
|
||||
|
||||
void applyDarkTheme()
|
||||
{
|
||||
QFile file(":/styles/fluent_dark.qss");
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
qApp->setStyleSheet(file.readAll());
|
||||
} else {
|
||||
// Fallback: Inline Dark Theme
|
||||
qApp->setStyleSheet(R"(
|
||||
* {
|
||||
background-color: #202020;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
QPushButton {
|
||||
background-color: #2B2B2B;
|
||||
border: 1px solid #3F3F3F;
|
||||
border-radius: 4px;
|
||||
padding: 6px 16px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #3A3A3A;
|
||||
}
|
||||
QStatusBar {
|
||||
background-color: #2B2B2B;
|
||||
color: #B0B0B0;
|
||||
border-top: 1px solid #3F3F3F;
|
||||
}
|
||||
)");
|
||||
}
|
||||
}
|
||||
|
||||
void applyLightTheme() {
|
||||
QFile file(":/styles/fluent_light.qss");
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
qApp->setStyleSheet(file.readAll());
|
||||
} else {
|
||||
// Fallback: Inline Light Theme
|
||||
qApp->setStyleSheet(R"(
|
||||
* {
|
||||
background-color: #F3F3F3;
|
||||
color: #000000;
|
||||
}
|
||||
QPushButton {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #E1DFDD;
|
||||
border-radius: 4px;
|
||||
padding: 6px 16px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #F9F9F9;
|
||||
}
|
||||
QStatusBar {
|
||||
background-color: #FFFFFF;
|
||||
color: #605E5C;
|
||||
border-top: 1px solid #E1DFDD;
|
||||
}
|
||||
)");
|
||||
}
|
||||
}
|
||||
|
||||
bool m_isDarkMode;
|
||||
int m_position;
|
||||
QPushButton* m_toggleButton;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// Alternative: Kompaktere Version ohne Animation
|
||||
// ============================================================================
|
||||
|
||||
class SimpleThemeToggle : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimpleThemeToggle(QWidget* parent = nullptr)
|
||||
: QPushButton(parent), m_isDarkMode(true) {
|
||||
|
||||
setFixedSize(48, 28);
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
setFlat(true);
|
||||
updateIcon();
|
||||
|
||||
connect(this, &QPushButton::clicked, this, &SimpleThemeToggle::toggleTheme);
|
||||
|
||||
// Tooltip
|
||||
setToolTip("Toggle Dark/Light Mode");
|
||||
}
|
||||
|
||||
bool isDarkMode() const { return m_isDarkMode; }
|
||||
|
||||
signals:
|
||||
void themeChanged(bool isDarkMode);
|
||||
|
||||
private slots:
|
||||
void toggleTheme() {
|
||||
m_isDarkMode = !m_isDarkMode;
|
||||
updateIcon();
|
||||
applyTheme();
|
||||
emit themeChanged(m_isDarkMode);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void updateIcon()
|
||||
{
|
||||
QString icon = m_isDarkMode ? "☀️" : "🌙";
|
||||
setText(icon);
|
||||
|
||||
// Style
|
||||
QString style = QString(
|
||||
"QPushButton {"
|
||||
" background-color: %1;"
|
||||
" border: 1px solid %2;"
|
||||
" border-radius: 14px;"
|
||||
" font-size: 16pt;"
|
||||
" padding: 0px;"
|
||||
"}"
|
||||
"QPushButton:hover {"
|
||||
" background-color: %3;"
|
||||
"}"
|
||||
).arg(m_isDarkMode ? "#2B2B2B" : "#FFFFFF")
|
||||
.arg(m_isDarkMode ? "#3F3F3F" : "#E1DFDD")
|
||||
.arg(m_isDarkMode ? "#3A3A3A" : "#F9F9F9");
|
||||
|
||||
setStyleSheet(style);
|
||||
}
|
||||
|
||||
void applyTheme()
|
||||
{
|
||||
if (m_isDarkMode) {
|
||||
// Dark theme
|
||||
qApp->setStyleSheet("* { background-color: #202020; color: #FFFFFF; }");
|
||||
} else {
|
||||
// Light theme
|
||||
qApp->setStyleSheet("* { background-color: #F3F3F3; color: #000000; }");
|
||||
}
|
||||
}
|
||||
|
||||
bool m_isDarkMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
Binary file not shown.
Reference in New Issue
Block a user