From ea79c4f7e7972b2c2673c9c7db6dd923e2b7bbc2 Mon Sep 17 00:00:00 2001 From: Florent Berbie Date: Sat, 11 Apr 2015 12:13:15 +0200 Subject: [PATCH] Amazing, FactDev is also a coffeeMaker ;) --- src/gui/docks/searchdock.cpp | 10 ++++++++-- src/gui/docks/searchdock.h | 7 +++++++ src/gui/mainwindow/mainwindow.cpp | 4 +--- src/gui/mainwindow/mainwindow.ui | 23 +++++++++++++++++++++-- src/gui/widgets/coffeeeastereggwidget.cpp | 19 +++++++++++++++---- src/gui/widgets/coffeeeastereggwidget.h | 2 ++ 6 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/gui/docks/searchdock.cpp b/src/gui/docks/searchdock.cpp index 8dc4312..31ac772 100644 --- a/src/gui/docks/searchdock.cpp +++ b/src/gui/docks/searchdock.cpp @@ -3,7 +3,8 @@ namespace Gui { namespace Docks { -SearchDock::SearchDock(QWidget* parent, Qt::WindowFlags flags) : QDockWidget(parent, flags), ui(new Ui::SearchDock) +SearchDock::SearchDock(QWidget* parent, Qt::WindowFlags flags) + : QDockWidget(parent, flags), ui(new Ui::SearchDock) { ui->setupUi(this); @@ -18,6 +19,7 @@ SearchDock::~SearchDock() void SearchDock::search(QString text) { Models::Search s; + _text = text; QString styleSearchBackground = "background: url(:/icons/searchMini);" "background-position: right;" @@ -30,7 +32,7 @@ void SearchDock::search(QString text) "height: 25px;" "border: 1px solid #bbb;"; if(ui->leSearch->text() != "") { - ui->leSearch->setStyleSheet(styleSearchNoBackground); + ui->leSearch->setStyleSheet(styleSearchNoBackground); } else { ui->leSearch->setStyleSheet(styleSearchBackground); } @@ -44,6 +46,10 @@ void SearchDock::search(QString text) emit textChanged(s.getFilter()); } +QString SearchDock::getText() const +{ + return _text; +} } diff --git a/src/gui/docks/searchdock.h b/src/gui/docks/searchdock.h index be44dcf..2d129ce 100644 --- a/src/gui/docks/searchdock.h +++ b/src/gui/docks/searchdock.h @@ -26,6 +26,12 @@ class SearchDock : public QDockWidget explicit SearchDock(QWidget *parent=0, Qt::WindowFlags flags = 0); ~SearchDock(); + /** + * @brief SearchDock::getText Get the current text searched + * @return Text searched + */ + QString getText() const; + public slots: /** * @brief SearchDock::search Search elements in database which correspond @@ -43,6 +49,7 @@ public slots: private: Ui::SearchDock *ui; //!< User interface + QString _text; //!< Search text }; diff --git a/src/gui/mainwindow/mainwindow.cpp b/src/gui/mainwindow/mainwindow.cpp index 7e789bb..2002752 100644 --- a/src/gui/mainwindow/mainwindow.cpp +++ b/src/gui/mainwindow/mainwindow.cpp @@ -238,7 +238,7 @@ void MainWindow::responsiveBillingTable() } bool MainWindow::isEasterEgg(const QString filter) { - return filter == "FleuryMigeon42"; + return _searchDock->getText() == "FleuryMigeon42"; } @@ -705,8 +705,6 @@ void MainWindow::updateTableCustomers(QString filter, const int row) { } responsiveCustomerTable(); } else { - - qDebug() << "test"; changeEasterEgg(); } diff --git a/src/gui/mainwindow/mainwindow.ui b/src/gui/mainwindow/mainwindow.ui index 882fdd4..2c86c7a 100644 --- a/src/gui/mainwindow/mainwindow.ui +++ b/src/gui/mainwindow/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1413 - 492 + 548 @@ -425,7 +425,7 @@ - + Qt::Vertical @@ -438,6 +438,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -596,6 +609,12 @@ 1 + + + 0 + 0 + + 9 diff --git a/src/gui/widgets/coffeeeastereggwidget.cpp b/src/gui/widgets/coffeeeastereggwidget.cpp index f47d9e2..655aac5 100644 --- a/src/gui/widgets/coffeeeastereggwidget.cpp +++ b/src/gui/widgets/coffeeeastereggwidget.cpp @@ -29,9 +29,11 @@ void CoffeeEasterEggWidget::setupUI() { } void CoffeeEasterEggWidget::makeCoffeeInProgress() { - QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(nextState())); - timer->start(1000); + _timer = new QTimer(this); + _state = 1; + connect(_timer, SIGNAL(timeout()), this, SLOT(nextState())); + _timer->start(1000); + qDebug() << "makeCoffeeInProgress"; } @@ -44,6 +46,7 @@ void CoffeeEasterEggWidget::makeCoffeeFirstStep() { "

"); ui->btnCoffeeMaker->setText("Faire le café !"); ui->btnCoffeeMaker->setEnabled(false); + _state = 2; } void CoffeeEasterEggWidget::makeCoffeeSecondStep() { @@ -55,6 +58,7 @@ void CoffeeEasterEggWidget::makeCoffeeSecondStep() { "

"); ui->btnCoffeeMaker->setText("Faire le café !"); ui->btnCoffeeMaker->setEnabled(false); + _state = 3; } void CoffeeEasterEggWidget::makeCoffeeThirdStep() { @@ -66,6 +70,7 @@ void CoffeeEasterEggWidget::makeCoffeeThirdStep() { "

"); ui->btnCoffeeMaker->setText("Faire le café !"); ui->btnCoffeeMaker->setEnabled(false); + _state = 4; } void CoffeeEasterEggWidget::makeCoffeeFourthStep() { @@ -77,6 +82,7 @@ void CoffeeEasterEggWidget::makeCoffeeFourthStep() { "

"); ui->btnCoffeeMaker->setText("Faire le café !"); ui->btnCoffeeMaker->setEnabled(false); + _state = 5; } void CoffeeEasterEggWidget::makeCoffeeReadyStep() { @@ -91,7 +97,10 @@ void CoffeeEasterEggWidget::makeCoffeeReadyStep() { ui->btnCoffeeMaker->setEnabled(false); _drinked++; } else { - setupUI(); + _timer->stop(); + delete _timer; + setupUI(); + } } @@ -101,6 +110,7 @@ bool CoffeeEasterEggWidget::isDrinked() { } void CoffeeEasterEggWidget::nextState() { + qDebug() << "nextState -->" + _state; switch(_state) { case 0: setupUI(); @@ -123,6 +133,7 @@ void CoffeeEasterEggWidget::nextState() { default: setupUI(); } + } diff --git a/src/gui/widgets/coffeeeastereggwidget.h b/src/gui/widgets/coffeeeastereggwidget.h index 7e00a98..1b68419 100644 --- a/src/gui/widgets/coffeeeastereggwidget.h +++ b/src/gui/widgets/coffeeeastereggwidget.h @@ -3,6 +3,7 @@ #include #include +#include #include "gui/utils/image.h" namespace Ui { @@ -85,6 +86,7 @@ public slots: void nextState(); private: Ui::CoffeeEasterEggWidget *ui; //!< User interface + QTimer *_timer; //!< Timer of coffeeMaker int _state; //!< current state to make coffee int _drinked; //!< coffee has been drinked };