diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp index 3ced9311..47c1c6f9 100644 --- a/sleepyhead/Graphs/gGraphView.cpp +++ b/sleepyhead/Graphs/gGraphView.cpp @@ -37,7 +37,6 @@ extern MainWindow *mainwin; #include - MyLabel::MyLabel(QWidget * parent): QWidget(parent) { @@ -301,7 +300,7 @@ gGraphView::gGraphView(QWidget *parent, gGraphView *shared) vertScrollTime.start(); this->setMouseTracking(true); - m_emptytext = QObject::tr("No Data"); + m_emptytext = STR_Empty_NoData; InitGraphGlobals(); // FIXME: sstangl: handle error return. #ifdef ENABLE_THREADED_DRAWING m_idealthreads = QThread::idealThreadCount(); @@ -1192,6 +1191,7 @@ bool gGraphView::renderGraphs(QPainter &painter) return numgraphs > 0; } +#include "version.h" #ifdef BROKEN_OPENGL_BUILD void gGraphView::paintEvent(QPaintEvent *) #else @@ -1235,22 +1235,34 @@ void gGraphView::paintGL() graphs_drawn = renderGraphs(painter); - if (!graphs_drawn) { // No graphs drawn? - int x, y; - GetTextExtent(m_emptytext, x, y, bigfont); - int tp; + if (!graphs_drawn) { // No graphs drawn? show something useful :) + QString txt = QObject::tr("SleepyHead is proudly brought to you by JediMark.").arg(VersionString); - if (render_cube && this->isVisible()) { -// renderCube(painter); + int x2, y2; + GetTextExtent(m_emptytext, x2, y2, bigfont); + int tp2, tp1; + + if (!m_emptyimage.isNull()) { + painter.drawPixmap(width() /2 - m_emptyimage.width() /2, height() /2 - m_emptyimage.height() /2 , m_emptyimage); + tp2 = height() /2 + m_emptyimage.height()/2 + y2; - tp = height() - (y / 2); } else { - tp = height() / 2 + y / 2; - } - // Then display the empty text message + tp2 = height() / 2 + y2; + } QColor col = Qt::black; - AddTextQue(m_emptytext, (width() / 2) - x / 2, tp, 0.0, col, bigfont); + painter.setPen(col); + + painter.setFont(*bigfont); + painter.drawText((width() / 2) - x2 / 2, tp2, m_emptytext); + + QRectF rec(0,0,width(),0); + painter.setFont(*defaultfont); + rec = painter.boundingRect(rec, Qt::AlignHCenter | Qt::AlignBottom, txt); + rec.moveBottom(height()-5); + + painter.drawText(rec, Qt::AlignHCenter | Qt::AlignBottom, txt); + } DrawTextQue(painter); diff --git a/sleepyhead/Graphs/gGraphView.h b/sleepyhead/Graphs/gGraphView.h index 69ae7db2..247b5ae5 100644 --- a/sleepyhead/Graphs/gGraphView.h +++ b/sleepyhead/Graphs/gGraphView.h @@ -30,6 +30,9 @@ enum FlagType { FT_Bar, FT_Dot, FT_Span }; + +void setEmptyImage(QString text, QPixmap pixmap); + class MyLabel:public QWidget { public: @@ -383,6 +386,9 @@ class gGraphView //! \brief Sets the message displayed when there are no graphs to draw void setEmptyText(QString s) { m_emptytext = s; } + //! \brief Sets the message displayed when there are no graphs to draw + void setEmptyImage(QPixmap pm) { m_emptyimage = pm; } + inline const float &devicePixelRatio() { return m_dpr; } void setDevicePixelRatio(float dpr) { m_dpr = dpr; } @@ -550,6 +556,8 @@ class gGraphView int m_lastxpos, m_lastypos; QString m_emptytext; + QPixmap m_emptyimage; + bool m_showsplitter; qint64 m_minx, m_maxx; diff --git a/sleepyhead/SleepLib/common.cpp b/sleepyhead/SleepLib/common.cpp index ceadaefb..f2daa4fd 100644 --- a/sleepyhead/SleepLib/common.cpp +++ b/sleepyhead/SleepLib/common.cpp @@ -161,6 +161,12 @@ QString STR_MessageBox_Cancel; QString STR_MessageBox_Destroy; QString STR_MessageBox_Save; +QString STR_Empty_NoData; +QString STR_Empty_Brick; +QString STR_Empty_NoGraphs; +QString STR_Empty_SummaryOnly; +QString STR_Empty_NoSessions; + QString STR_TR_BMI; // Short form of Body Mass Index QString STR_TR_Weight; @@ -265,7 +271,6 @@ QString STR_TR_Usage; QString STR_TR_Sessions; QString STR_TR_PrRelief; // Pressure Relief -QString STR_TR_NoData; QString STR_TR_Bookmarks; QString STR_TR_SleepyHead; @@ -343,6 +348,13 @@ void initializeStrings() STR_MessageBox_Busy = QObject::tr("Busy"); STR_MessageBox_PleaseNote = QObject::tr("Please Note"); + STR_Empty_NoData = QObject::tr(""); + STR_Empty_Brick = QObject::tr("Compliance Only :("); + STR_Empty_NoGraphs = QObject::tr("Graphs Switched Off!"); + STR_Empty_SummaryOnly = QObject::tr("Summary Only :("); + STR_Empty_NoSessions = QObject::tr("Sessions Switched Off!"); + + // Dialog box options STR_MessageBox_Yes = QObject::tr("&Yes"); STR_MessageBox_No = QObject::tr("&No"); @@ -447,7 +459,6 @@ void initializeStrings() STR_TR_Sessions = QObject::tr("Sessions"); STR_TR_PrRelief = QObject::tr("Pr. Relief"); // Pressure Relief - STR_TR_NoData = QObject::tr("No Data Available"); STR_TR_Bookmarks = QObject::tr("Bookmarks"); STR_TR_SleepyHead = QObject::tr("SleepyHead"); diff --git a/sleepyhead/SleepLib/common.h b/sleepyhead/SleepLib/common.h index 89e0f967..dd6468f3 100644 --- a/sleepyhead/SleepLib/common.h +++ b/sleepyhead/SleepLib/common.h @@ -147,6 +147,13 @@ extern QString STR_MessageBox_Cancel; extern QString STR_MessageBox_Destroy; extern QString STR_MessageBox_Save; +extern QString STR_Empty_NoData; +extern QString STR_Empty_NoSessions; +extern QString STR_Empty_Brick; +extern QString STR_Empty_NoGraphs; +extern QString STR_Empty_SummaryOnly; + + extern QString STR_TR_BMI; // Short form of Body Mass Index extern QString STR_TR_Weight; @@ -249,7 +256,6 @@ extern QString STR_TR_Sessions; extern QString STR_TR_PrRelief; // Pressure Relief extern QString STR_TR_SensAwake; -extern QString STR_TR_NoData; extern QString STR_TR_Bookmarks; extern QString STR_TR_SleepyHead; diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index 6033f3d7..df129b0a 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -473,7 +473,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared) ui->weightSpinBox->setDecimals(3); ui->weightSpinBox->setSuffix(STR_UNIT_KG); } - GraphView->setEmptyText(STR_TR_NoData); + GraphView->setEmptyText(STR_Empty_NoData); previous_date=QDate(); ui->calButton->setChecked(p_profile->appearance->calendarVisible() ? Qt::Checked : Qt::Unchecked); @@ -484,6 +484,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared) connect(GraphView, SIGNAL(updateCurrentTime(double)), this, SLOT(on_LineCursorUpdate(double))); connect(GraphView, SIGNAL(updateRange(double,double)), this, SLOT(on_RangeUpdate(double,double))); + + GraphView->setEmptyImage(QPixmap(":/docs/sheep.png")); } @@ -1500,7 +1502,7 @@ void Daily::Load(QDate date) float hours=day->hours(MT_CPAP); if (GraphView->isEmpty() && (hours>0)) { if (!p_profile->hasChannel(CPAP_Obstructive) && !p_profile->hasChannel(CPAP_Hypopnea)) { - GraphView->setEmptyText(tr("No Graphs :(")); + GraphView->setEmptyText(STR_Empty_NoGraphs); isBrick=true; } @@ -1618,6 +1620,7 @@ void Daily::Load(QDate date) html+=""+tr("Sessions all off!")+""; html+=""; html+=""+tr("Sessions exist for this day but are switched off.")+"\n"; + GraphView->setEmptyText(STR_Empty_NoSessions); } else { html+="

"+tr("Impossibly short session")+"

"; html+=""+tr("Zero hours??")+"\n"; @@ -2465,15 +2468,15 @@ void Daily::updateCube() if (ui->graphCombo->count() > 0) { - GraphView->setEmptyText(tr("No Graphs On!")); + GraphView->setEmptyText(STR_Empty_NoGraphs); } else { if (!p_profile->GetGoodDay(getDate(), MT_CPAP) && !p_profile->GetGoodDay(getDate(), MT_OXIMETER) && !p_profile->GetGoodDay(getDate(), MT_SLEEPSTAGE) && !p_profile->GetGoodDay(getDate(), MT_POSITION)) { - GraphView->setEmptyText(STR_TR_NoData); + GraphView->setEmptyText(STR_Empty_NoData); } else { - GraphView->setEmptyText(tr("Summary Only :(")); + GraphView->setEmptyText(STR_Empty_SummaryOnly); } } } else { diff --git a/sleepyhead/overview.cpp b/sleepyhead/overview.cpp index bb4a7c01..9b21289e 100644 --- a/sleepyhead/overview.cpp +++ b/sleepyhead/overview.cpp @@ -87,7 +87,7 @@ Overview::Overview(QWidget *parent, gGraphView *shared) : GraphView = new gGraphView(ui->graphArea, m_shared); GraphView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - GraphView->setEmptyText(STR_TR_NoData); + GraphView->setEmptyText(STR_Empty_NoData); // Create the custom scrollbar and attach to GraphView scrollbar = new MyScrollBar(ui->graphArea); @@ -313,6 +313,9 @@ Overview::Overview(QWidget *parent, gGraphView *shared) : GraphView->resetLayout(); GraphView->LoadSettings("Overview"); //no trans + + GraphView->setEmptyImage(QPixmap(":/docs/sheep.png")); + } Overview::~Overview() { @@ -636,10 +639,10 @@ void Overview::updateCube() ui->toggleVisibility->blockSignals(false); if (ui->graphCombo->count() > 0) { - GraphView->setEmptyText(tr("No Graphs On!")); + GraphView->setEmptyText(STR_Empty_NoGraphs); } else { - GraphView->setEmptyText(STR_TR_NoData); + GraphView->setEmptyText(STR_Empty_NoData); } } else { ui->toggleVisibility->setArrowType(Qt::DownArrow);