mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-17 19:21:30 +12:00
Add dark theme button
This commit is contained in:
parent
155d2b8f24
commit
837bf7524f
2 changed files with 43 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QMenuBar>
|
||||||
|
#include <QPalette>
|
||||||
|
#include <QPushBUtton>
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "panda_qt/screen.hpp"
|
#include "panda_qt/screen.hpp"
|
||||||
|
@ -9,8 +12,13 @@ class MainWindow : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QMenuBar* menuBar = nullptr;
|
||||||
|
QPushButton* themeButton = nullptr;
|
||||||
ScreenWidget screen;
|
ScreenWidget screen;
|
||||||
|
|
||||||
|
void setDarkTheme();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QApplication* app, QWidget* parent = nullptr);
|
MainWindow(QApplication* app, QWidget* parent = nullptr);
|
||||||
|
~MainWindow();
|
||||||
};
|
};
|
|
@ -4,7 +4,41 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
||||||
setWindowTitle("Alber");
|
setWindowTitle("Alber");
|
||||||
// Enable drop events for loading ROMs
|
// Enable drop events for loading ROMs
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
resize(320, 240);
|
resize(320, 240);
|
||||||
screen.show();
|
screen.show();
|
||||||
|
|
||||||
|
// Set our menu bar up
|
||||||
|
menuBar = new QMenuBar(this);
|
||||||
|
setMenuBar(menuBar);
|
||||||
|
|
||||||
|
auto pandaMenu = menuBar->addMenu(tr("PANDA"));
|
||||||
|
auto pandaAction = pandaMenu->addAction(tr("panda..."));
|
||||||
|
|
||||||
|
auto themeButton = new QPushButton(tr("Dark theme"), this);
|
||||||
|
themeButton->setGeometry(40, 40, 100, 400);
|
||||||
|
themeButton->show();
|
||||||
|
connect(themeButton, &QPushButton::pressed, this, [&]() { setDarkTheme(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow() { delete menuBar; }
|
||||||
|
|
||||||
|
void MainWindow::setDarkTheme() {
|
||||||
|
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
||||||
|
|
||||||
|
QPalette p;
|
||||||
|
p.setColor(QPalette::Window, QColor(53, 53, 53));
|
||||||
|
p.setColor(QPalette::WindowText, Qt::white);
|
||||||
|
p.setColor(QPalette::Base, QColor(25, 25, 25));
|
||||||
|
p.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
|
||||||
|
p.setColor(QPalette::ToolTipBase, Qt::white);
|
||||||
|
p.setColor(QPalette::ToolTipText, Qt::white);
|
||||||
|
p.setColor(QPalette::Text, Qt::white);
|
||||||
|
p.setColor(QPalette::Button, QColor(53, 53, 53));
|
||||||
|
p.setColor(QPalette::ButtonText, Qt::white);
|
||||||
|
p.setColor(QPalette::BrightText, Qt::red);
|
||||||
|
p.setColor(QPalette::Link, QColor(42, 130, 218));
|
||||||
|
|
||||||
|
p.setColor(QPalette::Highlight, QColor(42, 130, 218));
|
||||||
|
p.setColor(QPalette::HighlightedText, Qt::black);
|
||||||
|
qApp->setPalette(p);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue