ADD: base auth widget

This commit is contained in:
Andrey Kutin 2026-10-15 11:45:41 +03:00
parent 7e51e67ce8
commit 385f284047
7 changed files with 255 additions and 0 deletions

82
.gitignore vendored Normal file
View File

@ -0,0 +1,82 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
*.qbs.user*
CMakeLists.txt.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
# Directories with generated files
.moc/
.obj/
.pch/
.rcc/
.uic/
/build*/

72
CMakeLists.txt Normal file
View File

@ -0,0 +1,72 @@
cmake_minimum_required(VERSION 3.16)
project(mysitenews VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Sql)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Sql)
set(PROJECT_SOURCES
main.cpp
widget.cpp
widget.h
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(mysitenews
MANUAL_FINALIZATION
${PROJECT_SOURCES}
auth.h auth.cpp
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET mysitenews APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(mysitenews SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(mysitenews
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(mysitenews PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
Qt6::Sql
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.mysitenews)
endif()
set_target_properties(mysitenews PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
include(GNUInstallDirs)
install(TARGETS mysitenews
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(mysitenews)
endif()

36
auth.cpp Normal file
View File

@ -0,0 +1,36 @@
#include "auth.h"
auth::auth (QWidget *parent)
: QWidget{ parent }, _nicknameLabel (new QLabel ("nickname:")),
_nicknameEdit (new QLineEdit ()),
_passwordLabel (new QLabel ("passwprd:")),
_passwordEdit (new QLineEdit ()),
_addressLabel (new QLabel ("address:")), _addressEdit (new QLineEdit ()),
_portLabel (new QLabel ("port:")), _portEdit (new QLineEdit ()),
_okButton (new QPushButton ("&OK")),
_quitButton (new QPushButton ("&QUIT")), _vbox (new QVBoxLayout (parent))
{
_nicknameLabel->setAlignment (Qt::AlignHCenter);
_passwordLabel->setAlignment (Qt::AlignHCenter);
_addressLabel->setAlignment (Qt::AlignHCenter);
_portLabel->setAlignment (Qt::AlignHCenter);
_passwordEdit->setEchoMode (QLineEdit::Password);
_vbox->addWidget (_nicknameLabel);
_vbox->addWidget (_nicknameEdit);
_vbox->addWidget (_passwordLabel);
_vbox->addWidget (_passwordEdit);
_vbox->addWidget (_addressLabel);
_vbox->addWidget (_addressEdit);
_vbox->addWidget (_portLabel);
_vbox->addWidget (_portEdit);
_vbox->addWidget (_okButton);
_vbox->addWidget (_quitButton);
connect (_okButton, &QPushButton::clicked, this, &auth::onAuth);
connect (_quitButton, &QPushButton::clicked, this, &auth::close);
setLayout (_vbox);
}
void
auth::onAuth ()
{
}

33
auth.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef AUTH_H
#define AUTH_H
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
class auth : public QWidget
{
Q_OBJECT
public:
explicit auth (QWidget *parent = nullptr);
private:
QLabel *_nicknameLabel = nullptr;
QLineEdit *_nicknameEdit = nullptr;
QLabel *_passwordLabel = nullptr;
QLineEdit *_passwordEdit = nullptr;
QLabel *_addressLabel = nullptr;
QLineEdit *_addressEdit = nullptr;
QLabel *_portLabel = nullptr;
QLineEdit *_portEdit = nullptr;
QPushButton *_okButton = nullptr;
QPushButton *_quitButton = nullptr;
QVBoxLayout *_vbox = nullptr;
public slots:
void onAuth ();
signals:
};
#endif // AUTH_H

13
main.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "auth.h"
#include "widget.h"
#include <QApplication>
int
main (int argc, char *argv[])
{
QApplication app (argc, argv);
auth a;
a.show ();
return app.exec ();
}

5
widget.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "widget.h"
Widget::Widget (QWidget *parent) : QWidget (parent) {}
Widget::~Widget () {}

14
widget.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget (QWidget *parent = nullptr);
~Widget ();
};
#endif // WIDGET_H