annotate src/core/session.cc @ 327:b5d6c27c308f

anime: refactor Anime::SeriesSeason to Season class ToLocalString has also been altered to take in both season and year because lots of locales actually treat formatting seasons differently! most notably is Russian which adds a suffix at the end to notate seasons(??)
author Paper <paper@paper.us.eu.org>
date Thu, 13 Jun 2024 01:49:18 -0400
parents d928ec7b6a0d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
315
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
1 #include "core/session.h"
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
2 #include "core/strings.h"
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
3 #include "core/config.h"
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
4 #include "gui/window.h"
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
5 #include "gui/locale.h"
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
6
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
7 #include <QElapsedTimer>
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
8 #include <QStatusBar>
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
9
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
10 #include "semver/semver.hpp"
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
11
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
12 #include <atomic>
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
13
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
14 Session session;
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
15
319
d928ec7b6a0d services/kitsu: implement GetAnimeList()
Paper <paper@paper.us.eu.org>
parents: 315
diff changeset
16 Session::Session() : gen(Time::GetSystemTime()) {
315
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
17 timer_.start();
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
18 }
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
19
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
20 void Session::SetMainWindow(MainWindow* window) {
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
21 disconnect();
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
22 window_ = window;
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
23 connect(this, &Session::StatusBarChange, window_, &MainWindow::SetStatusMessage);
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
24 }
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
25
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
26 void Session::SetStatusBar(const std::string& message) {
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
27 emit StatusBarChange(message);
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
28 }
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
29
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
30 void Session::IncrementRequests() {
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
31 requests_++;
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
32 };
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
33
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
34 unsigned int Session::GetRequests() {
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
35 return requests_;
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
36 };
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
37
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
38 int Session::uptime() {
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
39 return timer_.elapsed();
34347fd2a2de session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff changeset
40 }