This commit is contained in:
2025-12-05 12:20:47 +03:00
parent 57673d0ee4
commit 05fce073f1
450 changed files with 58 additions and 58 deletions

View File

@@ -0,0 +1,50 @@
#include "dialognewversion.h"
#include "ui_dialognewversion.h"
DialogNewVersion::DialogNewVersion(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogNewVersion),
validator(nullptr)
{
ui->setupUi(this);
validator = new QRegExpValidator(QRegExp("^[A-Za-z0-9]{20}$"));
ui->lineEdit->setValidator(validator);
setMinimumSize(200, 100);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("New version"));
}
DialogNewVersion::~DialogNewVersion()
{
delete ui;
}
void DialogNewVersion::initialize(QString prevName)
{
ui->prevVerValue->setText(prevName);
}
QString DialogNewVersion::getNewName()
{
return ui->lineEdit->text();
}
void DialogNewVersion::on_createButton_clicked()
{
if(ui->lineEdit->text() != "")
{
accept();
}
}
void DialogNewVersion::on_cancelButton_clicked()
{
close();
}
void DialogNewVersion::on_lineEdit_inputRejected()
{
QToolTip::showText(QCursor::pos(),tr("Only Latin letters and numbers"));
}

View File

@@ -0,0 +1,39 @@
#ifndef DIALOGNEWVERSION_H
#define DIALOGNEWVERSION_H
#include <QDialog>
#include <QWidget>
#include <QLineEdit>
#include <QToolTip>
#include <QRegExpValidator>
namespace Ui {
class DialogNewVersion;
}
class DialogNewVersion : public QDialog
{
Q_OBJECT
public:
explicit DialogNewVersion(QWidget *parent = nullptr);
~DialogNewVersion();
public:
void initialize(QString prevName);
QString getNewName();
private slots:
void on_createButton_clicked();
void on_cancelButton_clicked();
void on_lineEdit_inputRejected();
private:
Ui::DialogNewVersion *ui;
QRegExpValidator *validator;
};
#endif // DIALOGNEWVERSION_H

View File

@@ -0,0 +1,255 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogNewVersion</class>
<widget class="QDialog" name="DialogNewVersion">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>344</width>
<height>200</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Create copy...</string>
</property>
<property name="windowIcon">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/lms.png</normaloff>:/resources/icons/lms.png</iconset>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_Main">
<item>
<layout class="QHBoxLayout" name="baseVerLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="prevVerTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Basic version:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="prevVerValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>150</horstretch>
<verstretch>30</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="newNameLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="newNameVersionTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>99</horstretch>
<verstretch>40</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>New name version:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>150</horstretch>
<verstretch>30</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="toolTipDuration">
<number>1000</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="createButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Create</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../InstructorsAndTrainees.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,268 @@
#include "dialogsettings.h"
#include "ui_dialogsettings.h"
#include "tools.h"
#include <QFile>
#include <QXmlStreamReader>
#include <QRegExpValidator>
#include "dialogversioncontrol.h"
DialogSettings::DialogSettings(ConnectorToServer* connectorToServer, bool instructorIsLogged, QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogSettings),
settings(nullptr),
connectorToServer(nullptr),
dlgVersionControl(nullptr),
flSettingsServerChanged(false)
{
ui->setupUi(this);
ui->btnUpdateStyle->setObjectName("btnUpdateStyle");
ui->btnSetVersion->setObjectName("btnSetVersion");
ui->btnSave->setObjectName("btnSave");
ui->checkAutoStart->setObjectName("checkAutoStart");
#ifndef PROJECT_TYPE_DEBUG
ui->btnUpdateStyle->setVisible(false);
#endif
this->connectorToServer = connectorToServer;
/* Создаем строку для регулярного выражения */
QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
/* Создаем регулярное выражение с применением строки, как
* повторяющегося элемента
*/
QRegExp ipRegex ("^" + ipRange
+ "\\." + ipRange
+ "\\." + ipRange
+ "\\." + ipRange + "$");
/* Создаем Валидатор регулярного выражения с применением
* созданного регулярного выражения
*/
QRegExpValidator *ipValidator = new QRegExpValidator(ipRegex, this);
/* Устанавливаем Валидатор на QLineEdit */
ui->editAddress->setValidator(ipValidator);
settings = new ServerSettings;
//Задаём два пункта с текстом локалей в комбобоксе
ui->cmbLanguage->addItems(QStringList() << "English" << "Русский");
if(loadSettings(settings))
{
if(settings->Language == "ENG")
ui->cmbLanguage->setCurrentText("English");
else
ui->cmbLanguage->setCurrentText("Русский");
ui->editAddress->setText(settings->Address);
ui->editPort->setText(settings->Port);
ui->checkAutoStart->setChecked(settings->isAutoStart);
}
ui->btnSetVersion->setEnabled(false);
if(connectorToServer)
if(connectorToServer->getIsConnected())
{
if(instructorIsLogged)
ui->btnSetVersion->setEnabled(true);
}
ui->label_AutoStart->setVisible(false);
ui->checkAutoStart->setVisible(false);
ui->btnSave->setEnabled(false);
flSettingsServerChanged = false;
}
DialogSettings::~DialogSettings()
{
if(dlgVersionControl)
{
dlgVersionControl->close();
delete dlgVersionControl;
dlgVersionControl = nullptr;
}
delete ui;
delete settings;
}
void DialogSettings::deactivate()
{
ui->btnSetVersion->setEnabled(false);
if(dlgVersionControl)
{
dlgVersionControl->close();
delete dlgVersionControl;
dlgVersionControl = nullptr;
}
}
ServerSettings DialogSettings::getSettings()
{
return *settings;
}
bool DialogSettings::settingsServerIsChanged()
{
return flSettingsServerChanged;
}
void DialogSettings::changeEvent(QEvent *event)
{
// В случае получения события изменения языка приложения
if (event->type() == QEvent::LanguageChange)
{// переведём окно заново
ui->retranslateUi(this);
}
}
void DialogSettings::on_btnUpdateStyle_clicked()
{
emit signal_UpdateStyleSheet();
}
bool DialogSettings::loadSettings(ServerSettings *settings)
{
QFile file(settingsName);
if(! file.open(QIODevice::ReadOnly))
return false;
QXmlStreamReader xmlReader(&file);
while (!xmlReader.atEnd()){
if(xmlReader.isStartElement()){
if(xmlReader.name() == "ServerSettings")
{
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes()){
QString name = attr.name().toString();
QString value = attr.value().toString();
if(name == "Address"){
settings->Address = value;
}
if(name == "Port"){
settings->Port = value;
}
if(name == "Language"){
settings->Language = value;
}
if(name == "AutoStart"){
settings->isAutoStart = value.toInt();
}
}
}
}
xmlReader.readNext();
}
file.close();
return true;
}
bool DialogSettings::saveSettings()
{
QFile file(settingsName);
if(! file.open(QIODevice::WriteOnly))
return false;
QXmlStreamWriter xmlWriter(&file);
xmlWriter.setAutoFormatting(true);
xmlWriter.writeStartDocument();
xmlWriter.writeStartElement("ServerSettingsContainer");
xmlWriter.writeStartElement("ServerSettings");
xmlWriter.writeAttribute("Address", settings->Address);
xmlWriter.writeAttribute("Port", settings->Port);
xmlWriter.writeAttribute("Language", settings->Language);
xmlWriter.writeAttribute("AutoStart", QString::number(settings->isAutoStart));
xmlWriter.writeEndElement();
xmlWriter.writeEndElement();
xmlWriter.writeEndDocument();
file.close();
return true;
}
void DialogSettings::on_btnSave_clicked()
{
if(ui->cmbLanguage->currentText() == QStringLiteral("English"))
{
settings->Language = "ENG";
}
else
{
settings->Language = "RUS";
}
settings->Address = ui->editAddress->text();
settings->Port = ui->editPort->text();
settings->isAutoStart = ui->checkAutoStart->isChecked();
saveSettings();
this->accept();
}
void DialogSettings::on_btnSetVersion_clicked()
{
if(connectorToServer)
if(connectorToServer->getIsConnected())
{
dlgVersionControl = new DialogVersionControl(connectorToServer, this);
dlgVersionControl->initialize(connectorToServer->getLoginName());
dlgVersionControl->exec();
if(dlgVersionControl)
{
delete dlgVersionControl;
dlgVersionControl = nullptr;
}
}
}
void DialogSettings::on_cmbLanguage_currentIndexChanged(int index)
{
ui->btnSave->setEnabled(true);
}
void DialogSettings::on_editAddress_textChanged(const QString &arg1)
{
ui->btnSave->setEnabled(true);
flSettingsServerChanged = true;
}
void DialogSettings::on_editPort_textChanged(const QString &arg1)
{
ui->btnSave->setEnabled(true);
flSettingsServerChanged = true;
}
void DialogSettings::on_DialogSettings_accepted()
{
QString language;
if(settings->Language == "ENG")
language = QString("en_EN");
else
language = QString("ru_RU");
emit signal_LanguageChanged(language);
}

View File

@@ -0,0 +1,64 @@
#ifndef DIALOGSETTINGS_H
#define DIALOGSETTINGS_H
#include <QDialog>
#include <QTranslator>
#include <QEvent>
#include "Datas.h"
#include "connectortoserver.h"
#include "dialogversioncontrol.h"
namespace Ui {
class DialogSettings;
}
class DialogSettings : public QDialog
{
Q_OBJECT
public:
explicit DialogSettings(ConnectorToServer* connectorToServer, bool instructorIsLogged, QWidget *parent = nullptr);
~DialogSettings();
void deactivate();
ServerSettings getSettings();
bool settingsServerIsChanged();
static bool loadSettings(ServerSettings *settings);
protected:
void changeEvent(QEvent * event) override;
signals:
//сигнал об изменении языка интерфейса
void signal_LanguageChanged(QString language);
//сигнал об изменении стиля
void signal_UpdateStyleSheet();
private slots:
void on_btnUpdateStyle_clicked();
void on_btnSave_clicked();
void on_btnSetVersion_clicked();
void on_cmbLanguage_currentIndexChanged(int index);
void on_editAddress_textChanged(const QString &arg1);
void on_editPort_textChanged(const QString &arg1);
void on_DialogSettings_accepted();
private:
bool saveSettings();
private:
Ui::DialogSettings *ui;
QTranslator qtLanguageTranslator;
ServerSettings *settings;
ConnectorToServer* connectorToServer;
DialogVersionControl *dlgVersionControl;
bool flSettingsServerChanged;
};
#endif // DIALOGSETTINGS_H

View File

@@ -0,0 +1,376 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogSettings</class>
<widget class="QDialog" name="DialogSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<property name="windowIcon">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/lms.png</normaloff>:/resources/icons/lms.png</iconset>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_Main">
<item>
<widget class="QGroupBox" name="groupBox_Main">
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Main</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_Main">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Language">
<item>
<widget class="QLabel" name="label_Language">
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="cmbLanguage"/>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_Server">
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Server</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_Server">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Address">
<item>
<widget class="QLabel" name="label_Address">
<property name="text">
<string>Address</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_Address">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="editAddress">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Port">
<item>
<widget class="QLabel" name="label_Port">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_Port">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="editPort">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_AutoStart">
<item>
<widget class="QLabel" name="label_AutoStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Auto start</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_AutoStart">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkAutoStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Save">
<item>
<widget class="QToolButton" name="btnSave">
<property name="minimumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Save</string>
</property>
<property name="icon">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/circleGreen.png</normaloff>:/resources/icons/circleGreen.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_Additional">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Additional</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_Additional">
<item>
<widget class="QToolButton" name="btnSetVersion">
<property name="minimumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Version</string>
</property>
<property name="icon">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/updateVersion.png</normaloff>:/resources/icons/updateVersion.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnUpdateStyle">
<property name="minimumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Style</string>
</property>
<property name="icon">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/style.png</normaloff>:/resources/icons/style.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_Additional">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../InstructorsAndTrainees.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,222 @@
#include <QResizeEvent>
#include "dialogversioncontrol.h"
#include "specialmessagebox.h"
#include "ui_dialogversioncontrol.h"
DialogVersionControl::DialogVersionControl(ConnectorToServer* connectorToServer, QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogVersionControl),
connectorToServer(connectorToServer),
serverDataList(nullptr),
selectedVersion(nullptr),
versionContainer(nullptr),
waitAnimationWidget(nullptr),
dlgNewVersion(nullptr),
authorName(""),
flGetVersion(false)
{
ui->setupUi(this);
setMinimumSize(500, 300);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Version control"));
versionContainer = new VersionContainer;
waitAnimationWidget = new WaitAnimationWidget;
QMovie *movie = new QMovie(":/resources/icons/762.gif");
waitAnimationWidget->setParent(this);
waitAnimationWidget->initialize(movie,this);
}
DialogVersionControl::~DialogVersionControl()
{
if(dlgNewVersion)
{
dlgNewVersion->close();
delete dlgNewVersion;
dlgNewVersion = nullptr;
}
waitAnimationWidget->hideWithStop();
delete versionContainer;
delete waitAnimationWidget;
delete ui;
}
void DialogVersionControl::initialize(QString authorName)
{
this->authorName = authorName;
connect (connectorToServer, &ConnectorToServer::signal_SetVersion, this, &DialogVersionControl::slot_SetVersion);
connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation);
connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList);
connect(connectorToServer, &ConnectorToServer::signal_NotifyVersionControl, this, &DialogVersionControl::slot_NotifyVersionControl);
connect(this, &DialogVersionControl::sigSendSwitchVersion, connectorToServer, &ConnectorToServer::slot_SendSwitchVersion);
connect(this, &DialogVersionControl::sigSendCopyVersion, connectorToServer, &ConnectorToServer::slot_SendCopyVersion);
connect(this, &DialogVersionControl::sigSendDeleteVersion, connectorToServer, &ConnectorToServer::slot_SendDeleteVersion);
connect(this, &DialogVersionControl::signal_getVersion, connectorToServer, &ConnectorToServer::slot_getVersion);
emit signal_getVersion();
}
void DialogVersionControl::fillView(QList<StreamingVersionData *> *serverData)
{
ui->verListView->clear();
serverDataList = serverData;
ui->verValue->setText(versionContainer->getServerVersionData()->getViewName());
for(StreamingVersionData *data : *serverData)
{
ui->verListView->addItem(data->getViewName());
}
if(ui->verListView->count())
{
ui->verListView->setCurrentRow(0);
ui->verListView->itemClicked(ui->verListView->item(0));
}
}
QString DialogVersionControl::changableText(bool flag)
{
if(flag) return tr("Yes");
else return tr("No");
}
void DialogVersionControl::on_verListView_itemClicked(QListWidgetItem *item)
{
for(StreamingVersionData *data : *serverDataList)
{
if(data->getViewName() == item->text())
{
QString info = tr("Version name: ") + data->getViewName() + "\n";
info.append(tr("Created: ") + data->getCreateData().toString() + "\n");
info.append(tr("Changeable: ") + changableText(data->getIsChangeable()) + "\n");
info.append(tr("Author: ") + data->getAuthor());
ui->infoValue->setText(info);
selectedVersion = data;
}
}
}
void DialogVersionControl::sendCopyEmit(QString newName)
{
QString result = selectedVersion->getViewName() + ";" + newName + ";" + authorName;
if (selectedVersion == nullptr)
{
QString text = tr("Version not selected");
SpecMsgBox::WarningClose(this, text);
return;
}
versionContainer->setLocalVersionData(selectedVersion);
emit sigSendCopyVersion(result);
}
void DialogVersionControl::on_createDuplicateButton_clicked()
{
if (selectedVersion == nullptr)
{
QString text = tr("Version not selected");
SpecMsgBox::WarningClose(this, text);
return;
}
dlgNewVersion = new DialogNewVersion(this);
dlgNewVersion->initialize(selectedVersion->getViewName());
switch(dlgNewVersion->exec())
{
case QDialog::Accepted:
{
QString newName = dlgNewVersion->getNewName();
sendCopyEmit(newName);
break;
}
case QDialog::Rejected:
break;
default:
break;
}
if(dlgNewVersion)
{
delete dlgNewVersion;
dlgNewVersion = nullptr;
}
}
void DialogVersionControl::on_deleteVersionButton_clicked()
{
if (selectedVersion == nullptr)
{
QString text = tr("Version not selected");
SpecMsgBox::WarningClose(this, text);
return;
}
emit sigSendDeleteVersion(selectedVersion);
}
void DialogVersionControl::on_switchServerVersionButton_clicked()
{
if (selectedVersion == nullptr)
{
QString text = tr("Version not selected");
SpecMsgBox::WarningClose(this, text);
return;
}
//versionContainer->setServerVersionData(selectedVersion);
//ui->verValue->setText(selectedVersion->getViewName());
emit sigSendSwitchVersion(selectedVersion);
}
void DialogVersionControl::slot_activateLoadAnimation(bool flag)
{
if (flag)
{
waitAnimationWidget->showWithPlay();
}
else
{
waitAnimationWidget->hideWithStop();
}
}
void DialogVersionControl::slot_showServerList(QList<StreamingVersionData *> *serverList)
{
fillView(serverList);
}
void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion)
{
versionContainer->setServerVersionData(serverVersion);
ui->verValue->setText(versionContainer->getServerVersionData()->getViewName());
if(!flGetVersion)
connectorToServer->sendShowVersionSelect();
flGetVersion = true;
}
void DialogVersionControl::slot_NotifyVersionControl(QString text)
{
SpecMsgBox::WarningClose(this, text);
}
void DialogVersionControl::resizeEvent(QResizeEvent *event)
{
QSize size = event->size();
waitAnimationWidget->resize(size);
}

View File

@@ -0,0 +1,77 @@
#ifndef VERSIONSELECTWIDGET_H
#define VERSIONSELECTWIDGET_H
#include <QListWidget>
#include <QWidget>
#include <QDialog>
#include "versioncontainer.h"
#include "streamingversiondata.h"
#include "dialognewversion.h"
#include "waitanimationwidget.h"
#include "connectortoserver.h"
namespace Ui {
class DialogVersionControl;
}
class DialogVersionControl : public QDialog
{
Q_OBJECT
public:
explicit DialogVersionControl(ConnectorToServer* connectorToServer, QWidget *parent = nullptr);
~DialogVersionControl();
void initialize(QString authorName);
public:
void resizeEvent(QResizeEvent *event) override;
private slots:
void on_createDuplicateButton_clicked();
void on_deleteVersionButton_clicked();
void on_switchServerVersionButton_clicked();
void on_verListView_itemClicked(QListWidgetItem *item);
private slots:
void slot_activateLoadAnimation(bool flag);
void slot_showServerList(QList<StreamingVersionData*> *serverList);
void slot_SetVersion(StreamingVersionData* serverVersion);
void slot_NotifyVersionControl(QString text);
signals:
void sigSendDeleteVersion(StreamingVersionData *streaming);
void sigSendSwitchVersion(StreamingVersionData *selectVersion);
void sigSendCopyVersion(QString versionPair);
void signal_getVersion();
private:
QString changableText(bool flag);
void fillView(QList<StreamingVersionData*> *serverData);
void sendCopyEmit(QString newName);
private:
Ui::DialogVersionControl *ui;
ConnectorToServer* connectorToServer;
QList<StreamingVersionData*> *serverDataList;
StreamingVersionData *selectedVersion;
VersionContainer *versionContainer;
WaitAnimationWidget *waitAnimationWidget;
DialogNewVersion *dlgNewVersion;
QString authorName;
bool flGetVersion;
};
#endif // VERSIONSELECTWIDGET_H

View File

@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogVersionControl</class>
<widget class="QDialog" name="DialogVersionControl">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>580</width>
<height>277</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="windowIcon">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/lms.png</normaloff>:/resources/icons/lms.png</iconset>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_Main">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="actualServerListLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="verListTitle">
<property name="font">
<font>
<family>MS Shell Dlg 2</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::PreventContextMenu</enum>
</property>
<property name="text">
<string>Available versions on the server:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="verListView"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="infoViewTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Info:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="infoValue">
<property name="text">
<string>Double click on the version to see information...</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="ServerInfoLayout">
<item>
<widget class="QLabel" name="verTitle">
<property name="text">
<string>Current server version:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="verValue">
<property name="text">
<string>none</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="ButtonLayout" stretch="0,0,0">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="createDuplicateButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Create copy</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteVersionButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="switchServerVersionButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Change version</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../InstructorsAndTrainees.qrc"/>
</resources>
<connections/>
</ui>