Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
user-client
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a7659a8f
authored
Jun 20, 2017
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added error handling and basic config options
parent
56e78d3b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
63 deletions
+56
-63
mainwindow.cpp
+41
-2
mainwindow.h
+5
-0
mainwindow.ui
+10
-61
No files found.
mainwindow.cpp
View file @
a7659a8f
...
...
@@ -101,8 +101,8 @@ void MainWindow::loadVMData(std::string id){
* \brief Login Button handler, connects to server, if authentication is succesful enables all tabs, and loads all data
*/
void
MainWindow
::
on_bLogin_clicked
()
{
std
::
string
serverUrl
=
ui
->
iCloudServer
->
text
().
toStdString
()
;
{
try
{
std
::
string
serverUrl
=
parseConfig
();
//"https://vm.ik.bme.hu:9366/occi/"
;
myController
.
connect
(
serverUrl
);
std
::
string
username
=
ui
->
iUsername
->
text
().
toStdString
();
std
::
string
password
=
ui
->
iPassword
->
text
().
toStdString
();
...
...
@@ -114,6 +114,28 @@ void MainWindow::on_bLogin_clicked()
ui
->
tabWidget
->
setTabEnabled
(
2
,
true
);
loadAllData
();
ui
->
tabWidget
->
setCurrentIndex
(
1
);
}
catch
(
std
::
logic_error
e
){
QMessageBox
msgBox
;
msgBox
.
setText
(
e
.
what
());
msgBox
.
exec
();
}
}
std
::
string
MainWindow
::
parseConfig
(){
std
::
string
line
;
std
::
ifstream
myfile
(
"config.txt"
);
if
(
myfile
.
is_open
())
{
while
(
getline
(
myfile
,
line
)
)
{
return
line
;
}
myfile
.
close
();
}
else
throw
std
::
logic_error
(
"Unable to configure client. Please add a config.txt with the cloud server's url!"
);
return
""
;
}
/// Tab 1 - Virtual Machines
...
...
@@ -133,6 +155,7 @@ void MainWindow::renewClicked(std::string id){
* \param id
*/
void
MainWindow
::
startshutdownClicked
(
std
::
string
id
){
try
{
std
::
string
state
=
myController
.
getState
(
id
);
if
(
state
==
"inactive"
){
myController
.
startByID
(
id
);
...
...
@@ -143,6 +166,10 @@ void MainWindow::startshutdownClicked(std::string id){
emit
stateChanged
(
myController
.
getState
(
id
),
id
);
loadVMData
(
id
);
ui
->
listWidget
->
item
(
std
::
stoi
(
id
))
->
setSelected
(
true
);
}
catch
(
std
::
logic_error
e
){
showErrorMessage
(
e
.
what
());
}
}
/*!
...
...
@@ -150,6 +177,7 @@ void MainWindow::startshutdownClicked(std::string id){
* \param id
*/
void
MainWindow
::
wakeupsleepClicked
(
std
::
string
id
){
try
{
std
::
string
state
=
myController
.
getState
(
id
);
if
(
state
==
"active"
){
//sleep
myController
.
sleepByID
(
id
);
...
...
@@ -163,6 +191,17 @@ void MainWindow::wakeupsleepClicked(std::string id){
emit
stateChanged
(
myController
.
getState
(
id
),
id
);
loadVMData
(
id
);
ui
->
listWidget
->
item
(
std
::
stoi
(
id
))
->
setSelected
(
true
);
}
catch
(
std
::
logic_error
e
){
showErrorMessage
(
e
.
what
());
}
}
void
MainWindow
::
showErrorMessage
(
std
::
string
errorMsg
){
QMessageBox
msgBox
;
msgBox
.
setWindowTitle
(
"Error!"
);
msgBox
.
setText
(
errorMsg
.
c_str
());
msgBox
.
exec
();
}
/*!
...
...
mainwindow.h
View file @
a7659a8f
...
...
@@ -10,6 +10,9 @@
#include "controller.h"
#include "vmchooserdialog.h"
#include <qtermwidget5/qtermwidget.h>
#include <iostream>
#include <fstream>
#include <string>
namespace
Ui
{
class
MainWindow
;
...
...
@@ -25,6 +28,8 @@ public:
void
addVM
(
std
::
string
id
,
std
::
string
name
);
void
loadAllData
();
void
loadVMData
(
std
::
string
id
);
std
::
string
parseConfig
();
void
showErrorMessage
(
std
::
string
errorMsg
);
signals
:
void
stateChanged
(
std
::
string
state
,
std
::
string
id
);
...
...
mainwindow.ui
View file @
a7659a8f
...
...
@@ -95,7 +95,7 @@
<enum>
QTabWidget::Rounded
</enum>
</property>
<property
name=
"currentIndex"
>
<number>
1
</number>
<number>
0
</number>
</property>
<property
name=
"iconSize"
>
<size>
...
...
@@ -108,7 +108,7 @@
<string>
Welcome
</string>
</attribute>
<layout
class=
"QGridLayout"
name=
"gridLayout_4"
>
<item
row=
"
10
"
column=
"1"
>
<item
row=
"
8
"
column=
"1"
>
<widget
class=
"QPushButton"
name=
"bLogin"
>
<property
name=
"toolTip"
>
<string>
<
html
><
head/
><
body
><
p
>
Log in
<
/p
><
/body
><
/html
>
</string>
...
...
@@ -121,7 +121,7 @@
</property>
</widget>
</item>
<item
row=
"
9
"
column=
"1"
>
<item
row=
"
7
"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"iPassword"
>
<property
name=
"palette"
>
<palette>
...
...
@@ -171,7 +171,7 @@
</property>
</widget>
</item>
<item
row=
"3"
column=
"2"
rowspan=
"
10
"
>
<item
row=
"3"
column=
"2"
rowspan=
"
8
"
>
<spacer
name=
"horizontalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
...
...
@@ -187,7 +187,7 @@
</property>
</spacer>
</item>
<item
row=
"3"
column=
"0"
rowspan=
"
10
"
>
<item
row=
"3"
column=
"0"
rowspan=
"
8
"
>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
...
...
@@ -203,7 +203,7 @@
</property>
</spacer>
</item>
<item
row=
"1
2
"
column=
"1"
>
<item
row=
"1
0
"
column=
"1"
>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
@@ -219,14 +219,14 @@
</property>
</spacer>
</item>
<item
row=
"
8
"
column=
"1"
>
<item
row=
"
6
"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lPassword"
>
<property
name=
"text"
>
<string>
Password
</string>
</property>
</widget>
</item>
<item
row=
"
7
"
column=
"1"
>
<item
row=
"
5
"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"iUsername"
>
<property
name=
"palette"
>
<palette>
...
...
@@ -283,7 +283,7 @@
</property>
</spacer>
</item>
<item
row=
"
6
"
column=
"1"
>
<item
row=
"
4
"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lUsername"
>
<property
name=
"text"
>
<string>
Username
</string>
...
...
@@ -313,7 +313,7 @@
</property>
</widget>
</item>
<item
row=
"
11
"
column=
"1"
>
<item
row=
"
9
"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lInfo"
>
<property
name=
"palette"
>
<palette>
...
...
@@ -360,57 +360,6 @@
</property>
</widget>
</item>
<item
row=
"4"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lCloudServer"
>
<property
name=
"text"
>
<string>
Cloud Server:
</string>
</property>
</widget>
</item>
<item
row=
"5"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"iCloudServer"
>
<property
name=
"palette"
>
<palette>
<active>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
255
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
255
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
240
</red>
<green>
240
</green>
<blue>
240
</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property
name=
"text"
>
<string>
https://vm.ik.bme.hu:9366/occi/
</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QWidget"
name=
"tVM"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment