From b3025d9e09f5fa0a315dd6e437d672f4d2bba78c Mon Sep 17 00:00:00 2001
From: Eunice Sarah Siregar <13521013@mahasiswa.itb.ac.id>
Date: Thu, 13 Apr 2023 01:35:58 +0700
Subject: [PATCH] feat: update controller dashboard

---
 src/controller.py   | 34 +++++++++++++++++++++++-----------
 src/customize.py    |  7 ++++---
 src/dashboard.py    | 19 ++++++++++++-------
 src/listlatihan2.py |  4 ++--
 4 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/src/controller.py b/src/controller.py
index 14ccca9..d90966b 100644
--- a/src/controller.py
+++ b/src/controller.py
@@ -5,6 +5,8 @@ from register import register
 from dashboard import dashboard
 from listlatihan2 import listLatihan2
 from tesBacaDB import tesBaca
+from customize import customizeWorkout
+from plan import plan
 class controller:
     def __init__(self):
         self.conn = sqlite3.connect('fitu.db')
@@ -12,9 +14,11 @@ class controller:
         self.registerWin = register()
         self.registerWin.switch.connect(self.fromRegister)
         self.dashboard = dashboard()
-        # self.dashboard.switch.connect(self.fromDashboard)
-        # self.listLatihan = listLatihan2()
-        # self.listLatihan.switch.connect(self.fromListLatihan)
+        self.dashboard.switch.connect(self.fromDashboard)
+        self.listLatihan = listLatihan2()
+        self.listLatihan.switch.connect(self.fromListLatihan)
+        self.customize = customizeWorkout()
+        self.plan = plan()
         pass
 
         
@@ -32,15 +36,23 @@ class controller:
         self.registerWin.close()
         self.dashboard.show()
 
-    # def fromDashboard(self, page):
-    #     self.registerWin.close()
-    #     if (page == "listLatihan"):
-    #         self.listLatihan.show()
+    def fromDashboard(self, page):
+        self.registerWin.close()
+        self.dashboard.close()
+        if (page == "listLatihan"):
+            self.listLatihan.show()
+        elif (page == "customize"):
+            self.customize.show()
+        elif (page == "plan"):
+            self.plan.show()
+
 
-    # def fromListLatihan(self, page):
-    #     self.listLatihan.close()
-    #     if (page == "dashboard"):
-    #         self.dashboard.show()
+    def fromListLatihan(self, page):
+        self.listLatihan.close()
+        if (page == "dashboard"):
+            self.dashboard.show()
+        elif (page == "customize"):
+            self.customize.show()
 
 if __name__ == "__main__":
     app = QApplication(sys.argv)
diff --git a/src/customize.py b/src/customize.py
index cd41fed..5fce0a1 100644
--- a/src/customize.py
+++ b/src/customize.py
@@ -1,7 +1,7 @@
 import sqlite3
 import sys
 
-from PyQt6.QtCore import Qt, QSize, QPropertyAnimation, QAbstractAnimation, QEasingCurve, QAnimationGroup
+from PyQt6.QtCore import Qt, QSize, QPropertyAnimation, QAbstractAnimation, QEasingCurve, QAnimationGroup, pyqtSignal
 from PyQt6.QtGui import QIcon, QPixmap, QCursor, QFont, QMovie
 from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QGridLayout,
                              QGroupBox, QRadioButton, QCheckBox, QMessageBox,
@@ -13,8 +13,8 @@ text_color = '#EEEEE2'
 cardColor = '#D2DCC4'
 
 class customizeWorkout(QWidget):
-    
-    
+    switch = pyqtSignal(str, dict)
+
     def __init__(self):
         
         super().__init__()
@@ -435,6 +435,7 @@ class customizeWorkout(QWidget):
         saveButton.setCursor(
             QCursor(Qt.CursorShape.PointingHandCursor))       
         saveButton.clicked.connect(saveButtonClicked)
+    
                 
 if __name__ == '__main__':
     app = QApplication(sys.argv)
diff --git a/src/dashboard.py b/src/dashboard.py
index 4a29e42..bf038ff 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -1,6 +1,6 @@
 import sys
 
-from PyQt6.QtCore import Qt, pyqtSignal, QSize
+from PyQt6.QtCore import Qt, pyqtSignal, QSize, pyqtSignal
 from PyQt6.QtGui import QCursor, QFont, QPixmap, QMovie
 from PyQt6.QtWidgets import QApplication, QLabel, QPushButton, QWidget, QScrollArea, QVBoxLayout, QHBoxLayout
 import sqlite3
@@ -53,7 +53,7 @@ styleSheetCard = (
 
 
 class dashboard(QWidget):
-    switch_window = pyqtSignal(str, dict)
+    switch = pyqtSignal(str, dict)
     def __init__(self, user=None):
         super().__init__()
         if (user == None):
@@ -268,6 +268,7 @@ class dashboard(QWidget):
         customizeButton.move(649, 58)
         customizeButton.setCursor(
             QCursor(Qt.CursorShape.PointingHandCursor))
+        customizeButton.clicked.connect(self.customWindow)
         
         # tombol plan
         planButton = QPushButton(self)
@@ -301,6 +302,7 @@ class dashboard(QWidget):
         listButton.move(898, 58)
         listButton.setCursor(
             QCursor(Qt.CursorShape.PointingHandCursor))
+        listButton.clicked.connect(self.listWindow)
         
         
         # tombol history
@@ -355,6 +357,7 @@ class dashboard(QWidget):
         start.setFixedSize(233, 47) #pake ini buat kalau dia buletan
         start.move(101, 511)    
         start.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
+        start.clicked.connect(self.planWindow)
 
         # membuat history card
         historyDate = cur.execute("""
@@ -476,11 +479,13 @@ class dashboard(QWidget):
             self.historyElement(historyDate, self.index_history+1)
     
     def planWindow(self):
-        self.label = QLabel("")
-        self.label.setParent(self)
-        # self.window = plan(self.user)
-        # self.window.show()
-        # self.close()
+        self.switch.emit("plan", {})
+    
+    def listWindow(self):
+        self.switch.emit("listLatihan", {})
+    
+    def customWindow(self):
+        self.switch.emit("customize", {})
     
     def boxdelete(self, box):
         for i in range(self.vlayout.count()):
diff --git a/src/listlatihan2.py b/src/listlatihan2.py
index 3004f09..fc746e6 100644
--- a/src/listlatihan2.py
+++ b/src/listlatihan2.py
@@ -3,7 +3,7 @@ import sys
 import textwrap
 from functools import partial
 
-from PyQt6.QtCore import Qt, QSize
+from PyQt6.QtCore import Qt, QSize, pyqtSignal
 from PyQt6.QtGui import QIcon, QPixmap, QCursor, QFont, QMovie
 from PyQt6.QtWidgets import (QWidget, QApplication, QWidget,
                              QLabel, QVBoxLayout, QHBoxLayout, QPushButton, QScrollArea, QDialog)
@@ -21,8 +21,8 @@ titleLat = None
 class listLatihan2(QWidget):
     
     
+    switch = pyqtSignal(str, dict)
     def __init__(self):
-        
         super().__init__()    
         self.con = sqlite3.connect('fitu.db')
         self.listLat = self.fetchListLatihan()  
-- 
GitLab