Mercurial > minori
annotate src/core/session.cc @ 318:3b355fa948c7
config: use TOML instead of INI
unfortunately, INI is not enough, and causes some paths including
semicolons to break with our current storage of the library folders.
so, I decided to switch to TOML which does support real arrays...
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 12 Jun 2024 05:25:41 -0400 |
parents | 34347fd2a2de |
children | d928ec7b6a0d |
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 |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
diff
changeset
|
16 Session::Session() { |
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 } |