Skip to content

Commit

Permalink
Amazing, FactDev is also a coffeeMaker ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
KraTuX31 committed Apr 11, 2015
1 parent 0cef8e6 commit ea79c4f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 11 deletions.
10 changes: 8 additions & 2 deletions src/gui/docks/searchdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;"
Expand All @@ -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);
}
Expand All @@ -44,6 +46,10 @@ void SearchDock::search(QString text)

emit textChanged(s.getFilter());
}
QString SearchDock::getText() const
{
return _text;
}


}
Expand Down
7 changes: 7 additions & 0 deletions src/gui/docks/searchdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,6 +49,7 @@ public slots:

private:
Ui::SearchDock *ui; //!< User interface
QString _text; //!< Search text

};

Expand Down
4 changes: 1 addition & 3 deletions src/gui/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void MainWindow::responsiveBillingTable()
}

bool MainWindow::isEasterEgg(const QString filter) {
return filter == "FleuryMigeon42";
return _searchDock->getText() == "FleuryMigeon42";
}


Expand Down Expand Up @@ -705,8 +705,6 @@ void MainWindow::updateTableCustomers(QString filter, const int row) {
}
responsiveCustomerTable();
} else {

qDebug() << "test";
changeEasterEgg();
}

Expand Down
23 changes: 21 additions & 2 deletions src/gui/mainwindow/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1413</width>
<height>492</height>
<height>548</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -425,7 +425,7 @@
</property>
</spacer>
</item>
<item row="0" column="1">
<item row="2" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -438,6 +438,19 @@
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
Expand Down Expand Up @@ -596,6 +609,12 @@
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
Expand Down
19 changes: 15 additions & 4 deletions src/gui/widgets/coffeeeastereggwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";

}

Expand All @@ -44,6 +46,7 @@ void CoffeeEasterEggWidget::makeCoffeeFirstStep() {
"</p></body></html>");
ui->btnCoffeeMaker->setText("Faire le café !");
ui->btnCoffeeMaker->setEnabled(false);
_state = 2;
}

void CoffeeEasterEggWidget::makeCoffeeSecondStep() {
Expand All @@ -55,6 +58,7 @@ void CoffeeEasterEggWidget::makeCoffeeSecondStep() {
"</p></body></html>");
ui->btnCoffeeMaker->setText("Faire le café !");
ui->btnCoffeeMaker->setEnabled(false);
_state = 3;
}

void CoffeeEasterEggWidget::makeCoffeeThirdStep() {
Expand All @@ -66,6 +70,7 @@ void CoffeeEasterEggWidget::makeCoffeeThirdStep() {
"</p></body></html>");
ui->btnCoffeeMaker->setText("Faire le café !");
ui->btnCoffeeMaker->setEnabled(false);
_state = 4;
}

void CoffeeEasterEggWidget::makeCoffeeFourthStep() {
Expand All @@ -77,6 +82,7 @@ void CoffeeEasterEggWidget::makeCoffeeFourthStep() {
"</p></body></html>");
ui->btnCoffeeMaker->setText("Faire le café !");
ui->btnCoffeeMaker->setEnabled(false);
_state = 5;
}

void CoffeeEasterEggWidget::makeCoffeeReadyStep() {
Expand All @@ -91,7 +97,10 @@ void CoffeeEasterEggWidget::makeCoffeeReadyStep() {
ui->btnCoffeeMaker->setEnabled(false);
_drinked++;
} else {
setupUI();
_timer->stop();
delete _timer;
setupUI();

}

}
Expand All @@ -101,6 +110,7 @@ bool CoffeeEasterEggWidget::isDrinked() {
}

void CoffeeEasterEggWidget::nextState() {
qDebug() << "nextState -->" + _state;
switch(_state) {
case 0:
setupUI();
Expand All @@ -123,6 +133,7 @@ void CoffeeEasterEggWidget::nextState() {
default:
setupUI();
}

}


Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/coffeeeastereggwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QWidget>
#include <QTimer>
#include <QDebug>
#include "gui/utils/image.h"

namespace Ui {
Expand Down Expand Up @@ -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
};
Expand Down

0 comments on commit ea79c4f

Please sign in to comment.