Reports plugin #34

Merged
0xFEEDC0DE64 merged 7 commits from reports-plugin into devel 2017-12-19 00:18:52 +01:00
14 changed files with 109 additions and 31 deletions
Showing only changes of commit 27bc7eca80 - Show all commits

View File

@@ -2,6 +2,7 @@
#include <QLabel>
#include <QStatusBar>
#include <QMenu>
#include <QTimer>
#include <QMessageBox>
#include <QStringBuilder>
@@ -23,6 +24,8 @@ PresenceWidget::PresenceWidget(MainWindow &mainWindow) :
m_labelNotAvailable->setFrameShadow(QFrame::Sunken);
m_mainWindow.statusBar()->addWidget(m_labelNotAvailable);
m_action = m_mainWindow.menuView()->addAction(tr("Refresh presence"), this, &PresenceWidget::timeout);
auto timer = new QTimer(this);
timer->setInterval(60000);
connect(timer, &QTimer::timeout, this, &PresenceWidget::timeout);
@@ -33,15 +36,11 @@ PresenceWidget::PresenceWidget(MainWindow &mainWindow) :
void PresenceWidget::timeout()
{
if(m_reply)
{
qWarning() << "last request not finished yet!";
return;
}
m_labelAvailable->setText(tr("%0: %1").arg(tr("Available")).arg(tr("???")));
m_labelNotAvailable->setText(tr("%0: %1").arg(tr("Not available")).arg(tr("???")));
m_action->setEnabled(false);
m_reply = m_mainWindow.erfassung().doGetPresenceStatus();
connect(m_reply.get(), &ZeiterfassungReply::finished, this, &PresenceWidget::finished);
}
@@ -73,5 +72,6 @@ void PresenceWidget::finished()
}
after:
m_action->setEnabled(true);
m_reply = Q_NULLPTR;
}

View File

@@ -6,6 +6,7 @@
#include "replies/getpresencestatusreply.h"
class QLabel;
class QAction;
class MainWindow;
@@ -25,6 +26,8 @@ private:
QLabel *m_labelAvailable;
QLabel *m_labelNotAvailable;
QAction *m_action;
std::unique_ptr<GetPresenceStatusReply> m_reply;
};