ClienteTFG/view_loggin.cpp

55 lines
1.5 KiB
C++
Raw Normal View History

2020-05-08 12:42:02 +02:00
#include "view_loggin.h"
2020-05-16 20:52:10 +02:00
#include "view_install.h"
#include "controller_install.h"
2020-05-08 12:42:02 +02:00
#include <gtkmm/messagedialog.h>
2020-05-16 20:52:10 +02:00
view_loggin::view_loggin(session_manager *sesi):box_user(Gtk::ORIENTATION_HORIZONTAL), box_pass(Gtk::ORIENTATION_HORIZONTAL),button("check"), box(Gtk::ORIENTATION_VERTICAL)
2020-05-08 12:42:02 +02:00
{
2020-05-13 00:56:26 +02:00
this->set_title("loggin");
2020-05-16 20:52:10 +02:00
this->sesi=sesi;
2020-05-08 12:42:02 +02:00
set_border_width(5);
this->user.set_text("user");
this->pass.set_text("pass");
this->button.signal_clicked().connect(sigc::mem_fun(this,
&view_loggin::on_button_clicked));
this->box_user.add(user);
this->box_user.add(entry_user);
this->entry_user.set_hexpand(true);
this->box_user.set_spacing(10);
this->box_pass.add(pass);
this->box_pass.add(entry_pass);
this->entry_pass.set_visibility(false);
this->entry_pass.set_hexpand(true);
this->box_pass.set_spacing(10);
this->box.add(box_user);
this->box.add(box_pass);
this->box.add(button);
this->box.set_spacing(10);
this->add(box);
show_all_children();
}
void view_loggin::on_button_clicked(){
std::string user=this->entry_user.get_text();//this->m_refTextBufferUser->get_text();
std::string pass=this->entry_pass.get_text();//this->m_refTextBufferPass->get_text();
2020-05-16 20:52:10 +02:00
if(sesi->loggin(user, pass)){
2020-05-08 12:42:02 +02:00
this->login=true;
2020-05-26 18:47:14 +02:00
this->admin=sesi->admin();
2020-05-08 12:42:02 +02:00
this->hide();
}else{
this->login=false;
2020-05-13 00:56:26 +02:00
Gtk::MessageDialog err("error", false, Gtk::MessageType::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
2020-05-08 12:42:02 +02:00
err.set_secondary_text("Bad password or username");
err.run();
}
}