1// Aseprite
2// Copyright (C) 2020 Igara Studio S.A.
3// Copyright (C) 2001-2016 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifdef HAVE_CONFIG_H
9#include "config.h"
10#endif
11
12#include "app/ui/backup_indicator.h"
13
14#include "app/ui/status_bar.h"
15#include "ui/manager.h"
16
17namespace app {
18
19BackupIndicator::BackupIndicator()
20 : m_timer(100)
21 , m_small(false)
22 , m_running(false)
23{
24 m_timer.Tick.connect([this]{ onTick(); });
25}
26
27BackupIndicator::~BackupIndicator()
28{
29 m_timer.stop();
30}
31
32void BackupIndicator::start()
33{
34 m_running = true;
35 m_timer.start();
36}
37
38void BackupIndicator::stop()
39{
40 m_running = false;
41}
42
43void BackupIndicator::onTick()
44{
45 if (!m_running) {
46 StatusBar::instance()->showBackupIcon(StatusBar::BackupIcon::None);
47 m_timer.stop();
48 return;
49 }
50
51 StatusBar::instance()->showBackupIcon(
52 m_small ? StatusBar::BackupIcon::Small:
53 StatusBar::BackupIcon::Normal);
54
55 m_small = !m_small;
56}
57
58} // namespace app
59