forked from tiiuae/vmmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rootcontext.cpp
96 lines (80 loc) · 1.9 KB
/
rootcontext.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "rootcontext.h"
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
#include <QDebug>
#include "user.h"
RootContext::RootContext()
{
}
void RootContext::mainViewRequiested()
{
m_currentView = Views::MainVMView;
emit currentViewChanged();
}
void RootContext::detailsRequested()
{
m_currentView = Views::DetailsView;
emit currentViewChanged();
}
void RootContext::settingsRequiested()
{
if (User::instance()->isLoggedIn())
m_currentView = Views::GeneralSettings;
else
{
requestedView = Views::GeneralSettings;
if (User::instance()->hasName())
m_currentView = Views::LoginView;
else
m_currentView = Views::LoginPhoneView;
}
emit currentViewChanged();
}
void RootContext::loginRequest(const QString &passwd)
{
if (User::instance()->validate(passwd))
{
m_currentView = requestedView;
emit currentViewChanged();
}
//else
}
void RootContext::pinRequest(const QString &number, bool keepLogged)
{
if (keepLogged) {
User::instance()->setName(number);
}
m_currentView = Views::LoginPinView;
dataSource.pinRequest(number);//TODO: where must be this method: data source or user class?
emit currentViewChanged();
// emit pinResult(false);
}
void RootContext::pinSubmit(const QString &code)
{
dataSource.pinSubmit(code);
//if succesfull - get the requrested view
m_currentView = requestedView;
emit currentViewChanged();
// emit pinResult(false);
}
void RootContext::updateModel()
{
dataSource.updateModel();
}
void RootContext::switchPower(bool on, QString name)
{
qDebug() << on << name;
dataSource.switchPower(on, name);
}
void RootContext::saveSettings()
{
dataSource.saveSettings();
}
void RootContext::setVmdDir(const QString &newDir)
{
dataSource.setVmdDir(newDir);
}