ORE Studio 0.0.4
Loading...
Searching...
No Matches
LoginDialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2024 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_LOGINDIALOG_HPP
21#define ORES_QT_LOGINDIALOG_HPP
22
23#include <QLabel>
24#include <QDialog>
25#include <QLineEdit>
26#include <QSpinBox>
27#include <QPushButton>
28#include "ores.qt/ClientManager.hpp"
29
30namespace ores::qt {
31
38class LoginDialog : public QDialog {
39 Q_OBJECT
40
41private:
42 inline static std::string_view logger_name = "ores.qt.login_dialog";
43
44 static auto& lg() {
45 using namespace ores::utility::log;
46 static auto instance = make_logger(logger_name);
47 return instance;
48 }
49
50public:
56 explicit LoginDialog(ClientManager* clientManager, QWidget* parent = nullptr);
57 ~LoginDialog() override;
58
63 std::string getUsername() const { return username_edit_->text().toStdString(); }
64
65private slots:
66 void onLoginClicked();
67 void onLoginResult(const LoginResult& result);
68
69signals:
70 void loginCompleted(const LoginResult& result);
71
72private:
73 void setupUI();
74 void enableForm(bool enabled);
75
76private:
77 // UI components
78 QLineEdit* username_edit_;
79 QLineEdit* password_edit_;
80 QLineEdit* host_edit_;
81 QSpinBox* port_spinbox_;
82 QPushButton* login_button_;
83 QPushButton* cancel_button_;
84 QLabel* status_label_;
85
86 // Dependencies
87 ClientManager* clientManager_;
88};
89
90}
91
92#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Result of a login attempt.
Definition ClientManager.hpp:43
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:56
Dialog for user authentication and server connection.
Definition LoginDialog.hpp:38
std::string getUsername() const
Get the logged-in username.
Definition LoginDialog.hpp:63