|
|
|
@ -22,14 +22,13 @@ void MainWindow::clearConnected(std::set<std::vector<int>> *connected) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::refreshButtonGrid() {
|
|
|
|
|
//QSize button_size(max_width/columns, max_height/rows);
|
|
|
|
|
for (int i = 0; i < rows; i++) {
|
|
|
|
|
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]->setText("");
|
|
|
|
|
//buttonGrid[i][j]->setFixedSize(button_size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MainWindow::setEnabled(false);
|
|
|
|
|
qApp->processEvents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -71,6 +70,7 @@ void MainWindow::bubbleBoxes(std::set<std::vector<int>> *connected) {
|
|
|
|
|
bubbleUp((*i)[0], (*i)[1]);
|
|
|
|
|
}
|
|
|
|
|
refreshButtonGrid();
|
|
|
|
|
MainWindow::setEnabled(false);
|
|
|
|
|
qApp->processEvents();
|
|
|
|
|
usleep(400000);
|
|
|
|
|
for (int j = 0; j < columns; j++) {
|
|
|
|
@ -78,6 +78,7 @@ void MainWindow::bubbleBoxes(std::set<std::vector<int>> *connected) {
|
|
|
|
|
checkColumn(j);
|
|
|
|
|
}
|
|
|
|
|
refreshButtonGrid();
|
|
|
|
|
MainWindow::setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// slots
|
|
|
|
@ -128,7 +129,7 @@ void MainWindow::initialiseGameGrid() {
|
|
|
|
|
|
|
|
|
|
// Set size text etc. for each button
|
|
|
|
|
|
|
|
|
|
connect(button, &QPushButton::clicked, [=](){
|
|
|
|
|
connect(button, &QPushButton::clicked, [=, this](){
|
|
|
|
|
buttonPressed(i, j);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -152,6 +153,26 @@ void MainWindow::refreshSizes() {
|
|
|
|
|
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)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
, ui(new Ui::MainWindow)
|
|
|
|
@ -161,13 +182,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
, max_height(519)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
QPalette pal = QPalette();
|
|
|
|
|
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");
|
|
|
|
|
setPalettes();
|
|
|
|
|
refreshSizes();
|
|
|
|
|
game = new SameGame(rows, columns);
|
|
|
|
|
initialiseGame();
|
|
|
|
|