ORE Studio 0.0.4
Loading...
Searching...
No Matches
SignUpDialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 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_SIGNUP_DIALOG_HPP
21#define ORES_QT_SIGNUP_DIALOG_HPP
22
23#include <QWidget>
24#include <QKeyEvent>
25#include <QLineEdit>
26#include <QPushButton>
27#include <QLabel>
28#include <QCheckBox>
29#include <QSpinBox>
30#include "ores.qt/ClientManager.hpp"
31#include "ores.logging/make_logger.hpp"
32
33namespace ores::qt {
34
41class SignUpDialog : public QWidget {
42 Q_OBJECT
43
44private:
45 inline static std::string_view logger_name = "ores.qt.signup_dialog";
46
47 [[nodiscard]] static auto& lg() {
48 using namespace ores::logging;
49 static auto instance = make_logger(logger_name);
50 return instance;
51 }
52
53public:
54 explicit SignUpDialog(QWidget* parent = nullptr);
55 ~SignUpDialog() override;
56
57 QSize sizeHint() const override;
58
62 void setServer(const QString& server);
63
67 void setPort(int port);
68
72 QString getServer() const;
73
77 int getPort() const;
78
82 void setClientManager(ClientManager* clientManager);
83
87 QString getRegisteredUsername() const;
88
89protected:
90 void keyPressEvent(QKeyEvent* event) override;
91
92signals:
96 void loginSucceeded(const QString& username);
97
101 void signupSucceeded(const QString& username);
102
106 void signupFailed(const QString& errorMessage);
107
112
117
118private slots:
119 void onSignUpClicked();
120 void onLoginClicked();
121 void onShowPasswordToggled(bool checked);
122 void onSignUpResult(const SignupResult& result);
123 void onLoginResult(const LoginResult& result);
124 void updatePasswordMatchIndicator();
125
126private:
127 void setupUI();
128 void setupPanel(QWidget* parent);
129 void enableForm(bool enabled);
130 bool validateInput();
131
132 // UI elements
133 QLabel* titleLabel_;
134 QLineEdit* usernameEdit_;
135 QLineEdit* emailEdit_;
136 QLineEdit* passwordEdit_;
137 QLineEdit* confirmPasswordEdit_;
138 QCheckBox* showPasswordCheck_;
139 QPushButton* signUpButton_;
140 QPushButton* loginButton_;
141 QLabel* loginLabel_;
142 QLabel* statusLabel_;
143
144 // Server fields
145 QLineEdit* hostEdit_;
146 QSpinBox* portSpinBox_;
147
148 // Dependencies
149 ClientManager* clientManager_{nullptr};
150
151 // Result tracking
152 QString registeredUsername_;
153};
154
155}
156
157#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Result of a login attempt.
Definition ClientManager.hpp:58
Result of a signup attempt.
Definition ClientManager.hpp:69
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Sign up dialog with dark theme.
Definition SignUpDialog.hpp:41
void loginSucceeded(const QString &username)
Emitted when signup and auto-login succeed.
QString getRegisteredUsername() const
Get the username that was registered.
Definition SignUpDialog.cpp:94
QString getServer() const
Get the current server/host field value.
Definition SignUpDialog.cpp:82
void setClientManager(ClientManager *clientManager)
Set the client manager for performing signup.
Definition SignUpDialog.cpp:90
void signupSucceeded(const QString &username)
Emitted when signup succeeds (before auto-login).
void signupFailed(const QString &errorMessage)
Emitted when signup fails.
int getPort() const
Get the current port field value.
Definition SignUpDialog.cpp:86
void closeRequested()
Emitted when the widget should be closed.
void loginRequested()
Emitted when user wants to go back to login.
void setPort(int port)
Set the port field value.
Definition SignUpDialog.cpp:78
void setServer(const QString &server)
Set the server/host field value.
Definition SignUpDialog.cpp:74