💄 Made color palettes coherently

main
Isabell Pflug 2 years ago
parent d0f29a3795
commit 6e44546e97

@ -3,4 +3,4 @@ columns = 9
rows = 9 rows = 9
[colors] [colors]
colors = #590d22, #a4133c, #c9184a, #ff4d6d, #ff758f colors = #A90A5A, #FFD1D9, #DB7093, #F7A8B8, #660033

@ -22,14 +22,13 @@ void MainWindow::clearConnected(std::set<std::vector<int>> *connected) {
} }
void MainWindow::refreshButtonGrid() { void MainWindow::refreshButtonGrid() {
//QSize button_size(max_width/columns, max_height/rows);
for (int i = 0; i < rows; i++) { for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) { for (int j = 0; j < columns; j++) {
buttonGrid[i][j]->setStyleSheet("color: #FFFFFF; Font : 30pt; background-color: " + game->getCell(i,j) + "; border: none;"); buttonGrid[i][j]->setStyleSheet("color: #FFFFFF; Font : 30pt; background-color: " + game->getCell(i,j) + "; border: none;");
buttonGrid[i][j]->setText(""); buttonGrid[i][j]->setText("");
//buttonGrid[i][j]->setFixedSize(button_size);
} }
} }
MainWindow::setEnabled(false);
qApp->processEvents(); qApp->processEvents();
} }
@ -71,6 +70,7 @@ void MainWindow::bubbleBoxes(std::set<std::vector<int>> *connected) {
bubbleUp((*i)[0], (*i)[1]); bubbleUp((*i)[0], (*i)[1]);
} }
refreshButtonGrid(); refreshButtonGrid();
MainWindow::setEnabled(false);
qApp->processEvents(); qApp->processEvents();
usleep(400000); usleep(400000);
for (int j = 0; j < columns; j++) { for (int j = 0; j < columns; j++) {
@ -78,6 +78,7 @@ void MainWindow::bubbleBoxes(std::set<std::vector<int>> *connected) {
checkColumn(j); checkColumn(j);
} }
refreshButtonGrid(); refreshButtonGrid();
MainWindow::setEnabled(true);
} }
// slots // slots
@ -128,7 +129,7 @@ void MainWindow::initialiseGameGrid() {
// Set size text etc. for each button // Set size text etc. for each button
connect(button, &QPushButton::clicked, [=](){ connect(button, &QPushButton::clicked, [=, this](){
buttonPressed(i, j); buttonPressed(i, j);
}); });
} }
@ -152,6 +153,26 @@ void MainWindow::refreshSizes() {
max_height = MainWindow::height() - ui->menuBar->height() - ui->lcdScore->height() - ui->statusBar->height(); max_height = MainWindow::height() - ui->menuBar->height() - ui->lcdScore->height() - ui->statusBar->height();
} }
void MainWindow::setPalettes() {
QPalette palLight = QPalette();
QPalette palDark = QPalette();
const QBrush bgLightBrush = QBrush(0xfff0f3);
const QBrush bgDarkBrush = QBrush(0xffd1d9);
const QBrush textBrush = QBrush(0xa4133c);
auto setColorGroups = [](QPalette *pal, QBrush textBrush, QBrush bgBrush) -> void {
pal->setColorGroup(QPalette::Active, textBrush, bgBrush, bgBrush, bgBrush, bgBrush, textBrush, textBrush, bgBrush, bgBrush);
pal->setColorGroup(QPalette::Inactive, textBrush, bgBrush, bgBrush, bgBrush, bgBrush, textBrush, textBrush, bgBrush, bgBrush);
pal->setColorGroup(QPalette::Disabled, textBrush, bgBrush, bgBrush, bgBrush, bgBrush, textBrush, textBrush, bgBrush, bgBrush);
};
setColorGroups(&palLight, textBrush, bgLightBrush);
setColorGroups(&palDark, textBrush, bgDarkBrush);
this->setPalette(palLight);
ui->menuPlay->setPalette(palLight);
ui->menuBar->setPalette(palDark);
ui->statusBar->setPalette(palLight);
}
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
@ -161,13 +182,7 @@ MainWindow::MainWindow(QWidget *parent)
, max_height(519) , max_height(519)
{ {
ui->setupUi(this); ui->setupUi(this);
QPalette pal = QPalette(); setPalettes();
pal.setColor(QPalette::Window, 0xfff0f3);
pal.setColor(QPalette::Text, 0xa4133c);
this->setPalette(pal);
ui->menuPlay->setPalette(pal);
ui->menuBar->setStyleSheet("QMenuBar::item {color: #a4133c}");
ui->statusBar->setStyleSheet("color: #a4133c");
refreshSizes(); refreshSizes();
game = new SameGame(rows, columns); game = new SameGame(rows, columns);
initialiseGame(); initialiseGame();

@ -37,6 +37,7 @@ public:
void bubbleRight(int column); void bubbleRight(int column);
void bubbleUp(int row, int column); void bubbleUp(int row, int column);
void bubbleBoxes(std::set<std::vector<int>> *connected); void bubbleBoxes(std::set<std::vector<int>> *connected);
void setPalettes();
private slots: private slots:
void buttonPressed(int row, int column); void buttonPressed(int row, int column);

@ -19,7 +19,7 @@ void SameGame::initialiseGameMatrix(int rows, int columns) {
} }
SameGame::SameGame(int rows, int columns) SameGame::SameGame(int rows, int columns)
: colors(settings->value("colors/colors", QList<QVariant>() << "#590d22" << "#a4133c" << "#c9184a" << "#ff4d6d" << "#ff758f").toStringList()) : colors(settings->value("colors/colors", QList<QVariant>() << "#A90A5A" << "#FFD1D9" << "#DB7093" << "#F7A8B8" << "#660033").toStringList())
// also ich finds echt cool! // also ich finds echt cool!
{ {
initialiseGameMatrix(rows, columns); initialiseGameMatrix(rows, columns);

Loading…
Cancel
Save