From 735d6e894e5e89e4e35ed2355692d4fa20d7fe51 Mon Sep 17 00:00:00 2001
From: Mark Watkins <jedimark@users.sourceforge.net>
Date: Tue, 20 Dec 2011 11:04:29 +1000
Subject: [PATCH] Mac build fix, new secret Preference option

---
 Graphs/gGraphView.cpp | 19 +++++++++----------
 SleepyHeadQT.pro      |  4 ++--
 mainwindow.cpp        |  2 --
 preferencesdialog.cpp |  3 +++
 preferencesdialog.ui  |  9 ++++++++-
 5 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp
index e14ccac6..17d11f34 100644
--- a/Graphs/gGraphView.cpp
+++ b/Graphs/gGraphView.cpp
@@ -2217,9 +2217,9 @@ void gGraphView::renderSomethingFun()
 
 void gGraphView::paintGL()
 {
-    bool something_fun=PREF.ExistsAndTrue("SomeFun");
-
+    bool something_fun=PROFILE.ExistsAndTrue("EmptyGraphFun");
     if (something_fun && redrawtimer->isActive()) {
+
         redrawtimer->stop();
     }
 
@@ -2232,8 +2232,6 @@ void gGraphView::paintGL()
     //glClearDepth(1);
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-    if (something_fun)
-        renderSomethingFun();
 
     /*glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -2324,10 +2322,8 @@ void gGraphView::paintGL()
     QColor col=Qt::black;
     if (!numgraphs) {
         int x,y;
-        if (m_emptytext!="fun") {
-            GetTextExtent(m_emptytext,x,y,bigfont);
-            AddTextQue(m_emptytext,(width()/2)-x/2,(height()/2)+y/2,0.0,col,bigfont);
-        } else renderSomethingFun();
+        GetTextExtent(m_emptytext,x,y,bigfont);
+        AddTextQue(m_emptytext,(width()/2)-x/2,(height()/2)+y/2,0.0,col,bigfont);
     }
 
 
@@ -2361,14 +2357,17 @@ void gGraphView::paintGL()
     }
     //glDisable(GL_TEXTURE_2D);
     //glDisable(GL_DEPTH_TEST);
-    swapBuffers(); // Dump to screen.
+    if (something_fun && !numgraphs && this->isVisible()) {
+        renderSomethingFun();
 
-    if (something_fun && this->isVisible()) {
         redrawtimer->setInterval(25);
         redrawtimer->setSingleShot(true);
         redrawtimer->start();
     }
 
+    swapBuffers(); // Dump to screen.
+
+
     //qDebug() << "Graph Prep,Draw" << el << "," << time.elapsed()-el << "ms x" << thr;
 }
 
diff --git a/SleepyHeadQT.pro b/SleepyHeadQT.pro
index 935a7822..8a294d5c 100644
--- a/SleepyHeadQT.pro
+++ b/SleepyHeadQT.pro
@@ -86,13 +86,13 @@ unix:!macx:LIBS        += -lX11 -lz -lGLU
 
 macx {
   SOURCES          += qextserialport/qextserialenumerator_osx.cpp
-  LIBS             += -framework IOKit -framework CoreFoundation -lz -lGLU
+  LIBS             += -framework IOKit -framework CoreFoundation -lz
 }
 
 win32 {
   SOURCES          += qextserialport/win_qextserialport.cpp qextserialport/qextserialenumerator_win.cpp
   DEFINES          += WINVER=0x0501 # needed for mingw to pull in appropriate dbt business...probably a better way to do this
-  LIBS             += -lsetupapi -lGLU
+  LIBS             += -lsetupapi
 
 
 }
diff --git a/mainwindow.cpp b/mainwindow.cpp
index c004f183..b5e6f4f4 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -60,7 +60,6 @@ void MainWindow::Log(QString s)
     strlock.unlock();
 
     //loglock.unlock();
-
 }
 
 
@@ -165,7 +164,6 @@ MainWindow::MainWindow(QWidget *parent) :
         systray=NULL;
         systraymenu=NULL;
     }
-
 }
 extern MainWindow *mainwin;
 MainWindow::~MainWindow()
diff --git a/preferencesdialog.cpp b/preferencesdialog.cpp
index ad673927..4597d9b0 100644
--- a/preferencesdialog.cpp
+++ b/preferencesdialog.cpp
@@ -171,6 +171,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) :
     general["GraphHeight"]=Preference(p_profile,"GraphHeight",PT_Checkbox,tr("Graph Height"),tr("Default Graph Height"),160);
     general["MaskDescription"]=Preference(p_profile,"MaskDescription",PT_Checkbox,tr("Mask Description"),tr("Whatever you want to record about your mask."),QString());
     general["HighResPrinting"]=Preference(p_profile,"HighResPrinting",PT_Checkbox,tr("High Resolution Printing"),tr("Use much slower but better quality high resolution printing."),QString());
+    general["EmptyGraphFun"]=Preference(p_profile,"EmptyGraphFun",PT_Checkbox,tr("Less Boring Empty Graph Pages"),tr("Make empty graph pages more attractive."),QString());
 
     if (!(p_profile)->Exists("MaskStartDate")) {
         (PROFILE["MaskStartDate"]=PROFILE.FirstDay());
@@ -198,6 +199,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) :
     ui->skipEmptyDays->setChecked(general["SkipEmptyDays"].value().toBool());
     ui->enableMultithreading->setChecked(general["EnableMultithreading"].value().toBool());
     ui->cacheSessionData->setChecked(general["MemoryHog"].value().toBool());
+    ui->lessBoringEmptyGraphPages->setChecked(general["EmptyGraphFun"].value().toBool());
 #ifdef Q_WS_MAC
     general["HighResPrinting"].setValue(true);
     ui->highResolutionPrinting->setChecked(true);
@@ -325,6 +327,7 @@ void PreferencesDialog::Save()
     general["MemoryHog"].setValue(ui->cacheSessionData->isChecked());
     general["MaskDescription"].setValue(ui->maskDescription->text());
     general["HighResPrinting"].setValue(ui->highResolutionPrinting->isChecked());
+    general["EmptyGraphFun"].setValue(ui->lessBoringEmptyGraphPages->isChecked());
 
     (*profile)["MaskStartDate"]=ui->startedUsingMask->date();
     (*profile)["GraphHeight"]=ui->graphHeight->value();
diff --git a/preferencesdialog.ui b/preferencesdialog.ui
index 2e4ee019..da625d1e 100644
--- a/preferencesdialog.ui
+++ b/preferencesdialog.ui
@@ -38,7 +38,7 @@
    <item>
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
-      <number>0</number>
+      <number>7</number>
      </property>
      <widget class="QWidget" name="importTab">
       <attribute name="title">
@@ -1559,6 +1559,13 @@ this application to be unstable with this feature enabled.</string>
              </property>
             </widget>
            </item>
+           <item>
+            <widget class="QCheckBox" name="lessBoringEmptyGraphPages">
+             <property name="text">
+              <string>Less Boring Empty Graph Pages</string>
+             </property>
+            </widget>
+           </item>
           </layout>
          </item>
         </layout>