Buggy but tolerable
[kitchenalert] / src / kitchenalertmainwindow.cpp
index fbc6c5d..5d60117 100644 (file)
@@ -137,7 +137,7 @@ void KitchenAlertMainWindow::newTimerSequence()
 
        connect(timer1,SIGNAL(alert(QModelIndex)),this,SLOT(alert(QModelIndex)));
 
-       //TODO: FIND A WAY TO INFORM THE TIMERS' ALERTSOUND'S OF A CHANGE OF THE SOUND FILE THEY SHOULD USE!!!!
+
 
        connect(this,SIGNAL(defaultSoundEnabled()),timer1,SLOT(enableDefaultSound()));
        connect(this,SIGNAL(soundChanged(QString)),timer1,SLOT(changeAlertSound(QString)));
@@ -173,9 +173,13 @@ void KitchenAlertMainWindow::alert(QModelIndex indexOfAlerter)
 
     // The program is brought to front and activated when alerted
 
-    raise();
+
     activateWindow();
 
+// removing everything below does not solve the bug #6752!
+
+    raise();  //this may be unnecessary
+
     // The alerting timer is selected
     ui->ComingAlertsTableView->selectionModel()->select(QItemSelection(indexOfAlerter,indexOfAlerter),QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows );
 
@@ -189,17 +193,7 @@ void KitchenAlertMainWindow::alert(QModelIndex indexOfAlerter)
 
 
     ui->SnoozeButton->setEnabled(true);
-
-    //Debug message
-
-
-
-    ui->debugLabel->setText(tr("Alert received from row %1").arg(indexOfAlerter.row()));
-    qDebug() << "Wrote the debug message";
-
-    //The alert sound is played
-   //TESTING TO MOVE THIS OPERATION TO THE TIMER ITSELF
-//    alertSound_.play();
+qDebug ("Snooze päälle hälytyksessä");
 
 }
 
@@ -221,8 +215,13 @@ void KitchenAlertMainWindow::timerSelected(QItemSelection selected,QItemSelectio
         if (model_.isThisTimerAlerting(index) == true)
         {
              ui->SnoozeButton->setEnabled(true);
+qDebug() << "Snooze päälle";
+        }
+        else
+        {
+            ui->SnoozeButton->setDisabled(true);
+qDebug() << "Snooze pois päältä";
         }
-        else ui->SnoozeButton->setDisabled(true);
     }
 
 }
@@ -247,7 +246,10 @@ void KitchenAlertMainWindow::restart()
 
         model_.startTimer(row);
     }
+
+
     ui->SnoozeButton->setDisabled(true);
+    qDebug () << "disabled snooze because of restart";
  //   alertSound_.stop();
 
 }
@@ -300,30 +302,27 @@ void KitchenAlertMainWindow::openAbout()
 
 bool KitchenAlertMainWindow::event(QEvent *event)
 {
-    QMainWindow::event(event);
-
 
 
     switch (event->type())
     {
-        case QEvent::ApplicationActivate:
+        case QEvent::WindowActivate:
 
             model_.setUpdateViewOnChanges(true);
-            ui->debugLabel->setText("Returned to the application!");
-
-
-              break;
+//            ui->debugLabel->setText("Returned to the application!");
+            break;
 
-       case QEvent::ApplicationDeactivate:
+       case QEvent::WindowDeactivate:
             model_.setUpdateViewOnChanges(false);
-            ui->debugLabel->setText("");
+//            ui->debugLabel->setText("");
             break;
 
        default:
             break;
 
-
     }
+
+    return QMainWindow::event(event); // Send the event to the base class implementation (also when handling the event in this function): necessary for the program to work!
 }
 
 void KitchenAlertMainWindow::disableSelectionDependentButtons()