From dfd9ecf23d3d4f0661d46aba677fa803a75f7500 Mon Sep 17 00:00:00 2001
From: Florent Berbie
Date: Thu, 9 Apr 2015 21:42:13 +0200
Subject: [PATCH 1/8] Add EasterEgg widget #147
---
documents/LaTexTemplate | 2 +-
fact-team.github.io | 2 +-
src/gui/widgets/coffeeeastereggwidget.cpp | 14 +++++
src/gui/widgets/coffeeeastereggwidget.h | 22 ++++++++
src/gui/widgets/coffeeeastereggwidget.ui | 67 +++++++++++++++++++++++
src/src.pro | 9 ++-
6 files changed, 111 insertions(+), 5 deletions(-)
create mode 100644 src/gui/widgets/coffeeeastereggwidget.cpp
create mode 100644 src/gui/widgets/coffeeeastereggwidget.h
create mode 100644 src/gui/widgets/coffeeeastereggwidget.ui
diff --git a/documents/LaTexTemplate b/documents/LaTexTemplate
index 59e0e74..5c18e6e 160000
--- a/documents/LaTexTemplate
+++ b/documents/LaTexTemplate
@@ -1 +1 @@
-Subproject commit 59e0e744832005315f5572cbfce69adf6ae313a7
+Subproject commit 5c18e6e55e09a899cc44aa7db8d4ae8c98824376
diff --git a/fact-team.github.io b/fact-team.github.io
index 91c6818..559cd1f 160000
--- a/fact-team.github.io
+++ b/fact-team.github.io
@@ -1 +1 @@
-Subproject commit 91c68182b6b51ce4867ae81c37d4b14d98241708
+Subproject commit 559cd1f57b7970aa658f373568617ffc7a572858
diff --git a/src/gui/widgets/coffeeeastereggwidget.cpp b/src/gui/widgets/coffeeeastereggwidget.cpp
new file mode 100644
index 0000000..42a8c51
--- /dev/null
+++ b/src/gui/widgets/coffeeeastereggwidget.cpp
@@ -0,0 +1,14 @@
+#include "coffeeeastereggwidget.h"
+#include "ui_coffeeeastereggwidget.h"
+
+CoffeeEasterEggWidget::CoffeeEasterEggWidget(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::CoffeeEasterEggWidget)
+{
+ ui->setupUi(this);
+}
+
+CoffeeEasterEggWidget::~CoffeeEasterEggWidget()
+{
+ delete ui;
+}
diff --git a/src/gui/widgets/coffeeeastereggwidget.h b/src/gui/widgets/coffeeeastereggwidget.h
new file mode 100644
index 0000000..0c7c7df
--- /dev/null
+++ b/src/gui/widgets/coffeeeastereggwidget.h
@@ -0,0 +1,22 @@
+#ifndef COFFEEEASTEREGGWIDGET_H
+#define COFFEEEASTEREGGWIDGET_H
+
+#include
+
+namespace Ui {
+class CoffeeEasterEggWidget;
+}
+
+class CoffeeEasterEggWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit CoffeeEasterEggWidget(QWidget *parent = 0);
+ ~CoffeeEasterEggWidget();
+
+private:
+ Ui::CoffeeEasterEggWidget *ui;
+};
+
+#endif // COFFEEEASTEREGGWIDGET_H
diff --git a/src/gui/widgets/coffeeeastereggwidget.ui b/src/gui/widgets/coffeeeastereggwidget.ui
new file mode 100644
index 0000000..4b6ddd8
--- /dev/null
+++ b/src/gui/widgets/coffeeeastereggwidget.ui
@@ -0,0 +1,67 @@
+
+
+ CoffeeEasterEggWidget
+
+
+
+ 0
+ 0
+ 274
+ 355
+
+
+
+ Form
+
+
+ -
+
+
+ TextLabel
+
+
+
+ -
+
+
+
+ 256
+ 256
+
+
+
+
+ 256
+ 256
+
+
+
+ TextLabel
+
+
+
+ -
+
+
+ PushButton
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
diff --git a/src/src.pro b/src/src.pro
index 374aee0..a1236fe 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -106,7 +106,8 @@ SOURCES += gui/mainwindow/mainwindow.cpp \
models/unit.cpp \
models/calculable.cpp \
utils/double.cpp \
- gui/widgets/userdailyhourswidget.cpp
+ gui/widgets/userdailyhourswidget.cpp \
+ gui/widgets/coffeeeastereggwidget.cpp
HEADERS += gui/mainwindow/mainwindow.h \
utils/log.h\
@@ -226,7 +227,8 @@ HEADERS += gui/mainwindow/mainwindow.h \
gui/dialogs/statisticsdialog.h \
models/unit.h \
models/calculable.h \
- gui/widgets/userdailyhourswidget.h
+ gui/widgets/userdailyhourswidget.h \
+ gui/widgets/coffeeeastereggwidget.h
FORMS += gui/mainwindow/mainwindow.ui \
@@ -249,7 +251,8 @@ FORMS += gui/mainwindow/mainwindow.ui \
gui/widgets/browseimagewidget.ui\
gui/widgets/path/chosepathwidget.ui\
gui/dialogs/statisticsdialog.ui \
- gui/widgets/userdailyhourswidget.ui
+ gui/widgets/userdailyhourswidget.ui \
+ gui/widgets/coffeeeastereggwidget.ui
RESOURCES += \
icons.qrc \
From 284177084d11cff7713086579a6bec87ee9191bc Mon Sep 17 00:00:00 2001
From: Florent Berbie
Date: Thu, 9 Apr 2015 22:39:51 +0200
Subject: [PATCH 2/8] Add methods to EasterEgg
---
src/gui/utils/image.cpp | 8 ++
src/gui/utils/image.h | 12 +++
src/gui/widgets/coffeeeastereggwidget.cpp | 125 ++++++++++++++++++++++
src/gui/widgets/coffeeeastereggwidget.h | 30 ++++++
src/gui/widgets/coffeeeastereggwidget.ui | 40 +++++--
5 files changed, 207 insertions(+), 8 deletions(-)
diff --git a/src/gui/utils/image.cpp b/src/gui/utils/image.cpp
index 1e8ccac..e5c46d4 100644
--- a/src/gui/utils/image.cpp
+++ b/src/gui/utils/image.cpp
@@ -18,6 +18,14 @@ QPixmap Image::bytesToPixmap(const QByteArray bytes)
return QPixmap::fromImage(QImage::fromData(bytes));
}
+QPixmap Image::getImage(QString path, int width, int height)
+{
+ QPixmap img(path);
+ img.scaled(width,height,Qt::KeepAspectRatio);
+
+ return img;
+}
+
QByteArray Image::imageToBytes(QImage image, const QString ext) {
QByteArray bytesArray;
QByteArray extArray = ext.toLocal8Bit();
diff --git a/src/gui/utils/image.h b/src/gui/utils/image.h
index e0af535..e2f4152 100644
--- a/src/gui/utils/image.h
+++ b/src/gui/utils/image.h
@@ -44,6 +44,18 @@ class Image
* @return QPixmap from bytes
*/
static QPixmap bytesToPixmap(const QByteArray bytes);
+
+ /**
+ * @brief Image::getImage Return a scaled image from the
+ * icon specified by it path. The image returned has a resolution of
+ * width*height (default 256*256)
+ * @param path Icon path
+ * @param width Icon width
+ * @param height Icon height
+ * @return Scaled image
+ */
+ static QPixmap getImage(QString path, int width = 256, int height = 256);
+
};
}
diff --git a/src/gui/widgets/coffeeeastereggwidget.cpp b/src/gui/widgets/coffeeeastereggwidget.cpp
index 42a8c51..e34aaf6 100644
--- a/src/gui/widgets/coffeeeastereggwidget.cpp
+++ b/src/gui/widgets/coffeeeastereggwidget.cpp
@@ -1,14 +1,139 @@
#include "coffeeeastereggwidget.h"
#include "ui_coffeeeastereggwidget.h"
+namespace Gui {
+namespace Widgets {
CoffeeEasterEggWidget::CoffeeEasterEggWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::CoffeeEasterEggWidget)
{
ui->setupUi(this);
+ setupUI();
}
CoffeeEasterEggWidget::~CoffeeEasterEggWidget()
{
delete ui;
}
+
+void CoffeeEasterEggWidget::setupUI() {
+ _state = 0;
+ _drinked = 0;
+ ui->lbCoffee->setPixmap(
+ Gui::Utils::Image::getImage(":/icons/img/coffee_level0.png"));
+ ui->lbScreenControl->setText(""
+ "Pour bien bosser, il faut du café!"
+ "
");
+ ui->btnCoffeeMaker->setText("Faire le café !");
+ ui->btnCoffeeMaker->setEnabled(true);
+ /*
+ ":/icons/img/coffee_level0.png"
+ ":/icons/img/coffee_level1.png"
+ ":/icons/img/coffee_level2.png"
+ ":/icons/img/coffee_level3.png"
+ ":/icons/img/coffee_level4.png"
+ ":/icons/img/coffee_ready.png"
+ */
+}
+
+void CoffeeEasterEggWidget::makeCoffeeInProgress()
+{
+ QTimer *timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(nextState()));
+ timer->start(1000);
+
+}
+
+void CoffeeEasterEggWidget::makeCoffeeFirstStep() {
+ _state = 1;
+ ui->lbCoffee->setPixmap(
+ Gui::Utils::Image::getImage(":/icons/img/coffee_level1.png"));
+ ui->lbScreenControl->setText(""
+ "Chauffage de l'eau..."
+ "
");
+ ui->btnCoffeeMaker->setText("Faire le café !");
+ ui->btnCoffeeMaker->setEnabled(false);
+}
+
+void CoffeeEasterEggWidget::makeCoffeeSecondStep() {
+ _state = 2;
+ ui->lbCoffee->setPixmap(
+ Gui::Utils::Image::getImage(":/icons/img/coffee_level2.png"));
+ ui->lbScreenControl->setText("
"
+ "En train de moudre le café..."
+ "
");
+ ui->btnCoffeeMaker->setText("Faire le café !");
+ ui->btnCoffeeMaker->setEnabled(false);
+}
+
+void CoffeeEasterEggWidget::makeCoffeeThirdStep() {
+ _state = 3;
+ ui->lbCoffee->setPixmap(
+ Gui::Utils::Image::getImage(":/icons/img/coffee_level3.png"));
+ ui->lbScreenControl->setText(""
+ "Préparation du café"
+ "
");
+ ui->btnCoffeeMaker->setText("Faire le café !");
+ ui->btnCoffeeMaker->setEnabled(false);
+}
+
+void CoffeeEasterEggWidget::makeCoffeeFourthStep() {
+ _state = 4;
+ ui->lbCoffee->setPixmap(
+ Gui::Utils::Image::getImage(":/icons/img/coffee_level4.png"));
+ ui->lbScreenControl->setText(""
+ "Préparation du café..."
+ "
");
+ ui->btnCoffeeMaker->setText("Faire le café !");
+ ui->btnCoffeeMaker->setEnabled(false);
+}
+
+void CoffeeEasterEggWidget::makeCoffeeReadyStep() {
+ _state = 5;
+ if (!isDrinked()) {
+ ui->lbCoffee->setPixmap(
+ Gui::Utils::Image::getImage(":/icons/img/coffee_ready.png"));
+ ui->lbScreenControl->setText(""
+ "Café prêt :)"
+ "
");
+ ui->btnCoffeeMaker->setText("Faire le café !");
+ ui->btnCoffeeMaker->setEnabled(false);
+ _drinked++;
+ } else {
+ setupUI();
+ }
+
+}
+
+bool CoffeeEasterEggWidget::isDrinked() {
+ return _drinked == 3;
+}
+
+void CoffeeEasterEggWidget::nextState() {
+ switch(_state) {
+ case 0:
+ setupUI();
+ break;
+ case 1:
+ makeCoffeeFirstStep();
+ break;
+ case 2:
+ makeCoffeeSecondStep();
+ break;
+ case 3:
+ makeCoffeeThirdStep();
+ break;
+ case 4:
+ makeCoffeeFourthStep();
+ break;
+ case 5:
+ makeCoffeeReadyStep();
+ break;
+ default:
+ setupUI();
+ }
+}
+
+
+}
+}
diff --git a/src/gui/widgets/coffeeeastereggwidget.h b/src/gui/widgets/coffeeeastereggwidget.h
index 0c7c7df..02c53d3 100644
--- a/src/gui/widgets/coffeeeastereggwidget.h
+++ b/src/gui/widgets/coffeeeastereggwidget.h
@@ -2,21 +2,51 @@
#define COFFEEEASTEREGGWIDGET_H
#include
+#include
+#include "gui/utils/image.h"
namespace Ui {
class CoffeeEasterEggWidget;
}
+namespace Gui {
+namespace Widgets {
+
+/**
+ * @brief The CoffeeEasterEggWidget class
+ */
class CoffeeEasterEggWidget : public QWidget
{
Q_OBJECT
public:
+ /**
+ * @brief CoffeeEasterEggWidget
+ * @param parent
+ */
explicit CoffeeEasterEggWidget(QWidget *parent = 0);
~CoffeeEasterEggWidget();
+ void setupUI();
+
+ void makeCoffeeInProgress();
+
+ void makeCoffeeFirstStep();
+ void makeCoffeeSecondStep();
+ void makeCoffeeThirdStep();
+ void makeCoffeeFourthStep();
+ void makeCoffeeReadyStep();
+ bool isDrinked();
+
+public slots:
+ void nextState();
private:
Ui::CoffeeEasterEggWidget *ui;
+ int _state;
+ int _drinked;
+
};
+}
+}
#endif // COFFEEEASTEREGGWIDGET_H
diff --git a/src/gui/widgets/coffeeeastereggwidget.ui b/src/gui/widgets/coffeeeastereggwidget.ui
index 4b6ddd8..e175420 100644
--- a/src/gui/widgets/coffeeeastereggwidget.ui
+++ b/src/gui/widgets/coffeeeastereggwidget.ui
@@ -7,7 +7,7 @@
0
0
274
- 355
+ 364
@@ -15,14 +15,29 @@
-
-
+
+
+
+ 0
+ 48
+
+
+
+
+ 16777215
+ 72
+
+
+
+ QFrame::StyledPanel
+
- TextLabel
+ <html><head/><body><p align="center">Pour bien bosser, il faut du café!</p></body></html>
-
-
+
256
@@ -36,14 +51,21 @@
- TextLabel
+
+
+
+ true
-
-
+
- PushButton
+ Faire le café !
+
+
+
+ :/icons/img/coffee_ready.png:/icons/img/coffee_ready.png
@@ -62,6 +84,8 @@
-
+
+
+
From 1ce535e15f5fd658ee1729db05fe7ddf36dfdbbe Mon Sep 17 00:00:00 2001
From: Florent Berbie
Date: Thu, 9 Apr 2015 23:04:23 +0200
Subject: [PATCH 3/8] Change mainWindow #147
---
src/gui/mainwindow/mainwindow.cpp | 44 +++++++++++-----
src/gui/mainwindow/mainwindow.h | 12 +++++
src/gui/mainwindow/mainwindow.ui | 63 ++++++++++++++++++++++-
src/gui/widgets/coffeeeastereggwidget.cpp | 3 +-
src/gui/widgets/coffeeeastereggwidget.h | 3 +-
src/gui/widgets/coffeeeastereggwidget.ui | 22 +++++++-
6 files changed, 129 insertions(+), 18 deletions(-)
diff --git a/src/gui/mainwindow/mainwindow.cpp b/src/gui/mainwindow/mainwindow.cpp
index 7eaabe6..7e789bb 100644
--- a/src/gui/mainwindow/mainwindow.cpp
+++ b/src/gui/mainwindow/mainwindow.cpp
@@ -237,6 +237,10 @@ void MainWindow::responsiveBillingTable()
}
}
+bool MainWindow::isEasterEgg(const QString filter) {
+ return filter == "FleuryMigeon42";
+}
+
void MainWindow::billingIsPaid()
@@ -576,6 +580,11 @@ void MainWindow::changeDocsTable()
updateButtons();
}
+void MainWindow::changeEasterEgg()
+{
+ ui->stackedWidget->setCurrentIndex(3);
+}
+
void MainWindow::customersTableToProjectsTable()
{
updateTableProjects(getCurrentCustomerId());
@@ -685,15 +694,22 @@ void MainWindow::openContextualMenuTree(const QPoint point)
void MainWindow::updateTableCustomers(QString filter, const int row) {
- ui->tblCustomers->setModel(
- Databases::CustomerDatabase::instance()->getCustomersTable(filter));
+ if (!isEasterEgg(filter)) {
+ ui->tblCustomers->setModel(
+ Databases::CustomerDatabase::instance()->getCustomersTable(filter));
- if (row > -1) {
- ui->tblCustomers->selectRow(row);
+ if (row > -1) {
+ ui->tblCustomers->selectRow(row);
+ } else {
+ ui->tblCustomers->clearSelection();
+ }
+ responsiveCustomerTable();
} else {
- ui->tblCustomers->clearSelection();
+
+ qDebug() << "test";
+ changeEasterEgg();
}
- responsiveCustomerTable();
+
}
void MainWindow::updateTableProjects(const int pId, const int row)
@@ -744,13 +760,17 @@ void MainWindow::updateCostAndTurnover()
ui->tblCustomers->currentIndex().row());
}
-void MainWindow::updateTree(QString filter)
-{
- if (ui->trCustomers->model() != NULL) {
- delete ui->trCustomers->model();
+void MainWindow::updateTree(QString filter) {
+ if (!isEasterEgg(filter)) {
+ if (ui->trCustomers->model() != NULL) {
+ delete ui->trCustomers->model();
+ }
+ ui->trCustomers->setModel(
+ Databases::CustomerDatabase::instance()->getTree(filter));
+ } else {
+ changeEasterEgg();
}
- ui->trCustomers->setModel(
- Databases::CustomerDatabase::instance()->getTree(filter));
+
}
void MainWindow::updateButtons()
diff --git a/src/gui/mainwindow/mainwindow.h b/src/gui/mainwindow/mainwindow.h
index 65f0c3e..849d11c 100644
--- a/src/gui/mainwindow/mainwindow.h
+++ b/src/gui/mainwindow/mainwindow.h
@@ -135,6 +135,13 @@ class MainWindow : public QMainWindow
*/
void responsiveBillingTable();
+ /**
+ * @brief MainWindow::isEasterEgg Return TRUE if search filter is
+ * FleuryMigeon42 else FALSE
+ * @param filter Search filter
+ * @return boolean
+ */
+ bool isEasterEgg(const QString filter);
public slots:
/**
* @brief MainWindow::addCustomer open window to add a new customer
@@ -286,6 +293,11 @@ private slots:
* when we change the selected doc in tblQuotes
*/
void changeDocsTable();
+ /**
+ * @brief MainWindow::changeEasterEgg function to update the view
+ * when we change the selected dock in easter egg
+ */
+ void changeEasterEgg();
/**
* @brief MainWindow::customersTableToProjectsTable changes projects with
* the index
diff --git a/src/gui/mainwindow/mainwindow.ui b/src/gui/mainwindow/mainwindow.ui
index b1d9564..882fdd4 100644
--- a/src/gui/mainwindow/mainwindow.ui
+++ b/src/gui/mainwindow/mainwindow.ui
@@ -22,7 +22,7 @@
-
- 0
+ 3
@@ -387,6 +387,59 @@
+
+
+ -
+
+
+
+ 400
+ 400
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 206
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
@@ -397,7 +450,7 @@
0
0
1413
- 27
+ 20
@@ -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() {
"