mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
styleSheet
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.11.1, 2024-12-17T12:54:17. -->
|
||||
<!-- Written by QtCreator 4.11.1, 2024-12-17T17:53:07. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -17,10 +17,10 @@ CommonView::CommonView(ConnectorToServer* connectorToServer, TypeView type, QWid
|
||||
{
|
||||
treeWidget = new QTreeWidget();
|
||||
|
||||
treeWidget->setIconSize(QSize(20, 20));
|
||||
//treeWidget->setIconSize(QSize(20, 20));
|
||||
treeWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
||||
|
||||
updateMyStyleSheet();
|
||||
//updateMyStyleSheet();
|
||||
}
|
||||
|
||||
void CommonView::setItemColorArchive(QTreeWidgetItem *item)
|
||||
@@ -45,8 +45,8 @@ void CommonView::updateMyStyleSheet()
|
||||
styleSheet = styleSheet.replace("\n", "");
|
||||
treeWidget->setStyleSheet(styleSheet);
|
||||
|
||||
QString style = treeWidget->styleSheet();
|
||||
int i = 0;
|
||||
//QString style = treeWidget->styleSheet();
|
||||
//int i = 0;
|
||||
}
|
||||
|
||||
QString CommonView::loadStyleSheet()
|
||||
|
||||
@@ -6,6 +6,11 @@ DialogAuthorizationInstructor::DialogAuthorizationInstructor(QWidget *parent) :
|
||||
ui(new Ui::DialogAuthorizationInstructor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->editLogin->setProperty("mandatoryField", true);
|
||||
ui->editPassword->setProperty("mandatoryField", true);
|
||||
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
}
|
||||
|
||||
DialogAuthorizationInstructor::~DialogAuthorizationInstructor()
|
||||
|
||||
@@ -9,6 +9,10 @@ DialogEditInstructor::DialogEditInstructor(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
|
||||
ui->editName->setProperty("mandatoryField", true);
|
||||
ui->editLogin->setProperty("mandatoryField", true);
|
||||
ui->editPassword->setProperty("mandatoryField", true);
|
||||
}
|
||||
|
||||
DialogEditInstructor::~DialogEditInstructor()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "ui_editorinstructors.h"
|
||||
|
||||
EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
|
||||
InstructorsView(connectorToServer, CommonView::TypeView::control, parent),
|
||||
InstructorsView(connectorToServer, CommonView::TypeView::control, parent),
|
||||
ui(new Ui::EditorInstructors)
|
||||
{
|
||||
ui->setupUi((QDialog*)this);
|
||||
|
||||
@@ -38,235 +38,208 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(180, 180, 180);</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnNewInstructor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New instructor</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/addInstructor.png</normaloff>:/icons/addInstructor.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="btnDeleteInstructor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete instructor</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/deleteInstructor.png</normaloff>:/icons/deleteInstructor.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="btnToOrFromArchive">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>To archive</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/instructorArchive.png</normaloff>:/icons/instructorArchive.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="btnEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/edit.png</normaloff>:/icons/edit.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">
|
||||
<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>
|
||||
<widget class="QToolButton" name="btnArchive">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show archive</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/archive.png</normaloff>:/icons/archive.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnNewInstructor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New instructor</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/addInstructor.png</normaloff>:/icons/addInstructor.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="btnDeleteInstructor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete instructor</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/deleteInstructor.png</normaloff>:/icons/deleteInstructor.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="btnToOrFromArchive">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>To archive</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/instructorArchive.png</normaloff>:/icons/instructorArchive.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="btnEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/edit.png</normaloff>:/icons/edit.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">
|
||||
<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>
|
||||
<widget class="QToolButton" name="btnArchive">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show archive</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/archive.png</normaloff>:/icons/archive.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
@@ -18,6 +18,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->btnUpdateStyleSheet->setObjectName("btnUpdateStyleSheet");
|
||||
|
||||
qRegisterMetaType<PacketType>("PacketType");
|
||||
qRegisterMetaType<QList<Instructor>>("QList<Instructor>");
|
||||
qRegisterMetaType<QList<Trainee>>("QList<Trainee>");
|
||||
@@ -53,15 +55,20 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
|
||||
docTasksWidget = new DocTasksWidget(this);
|
||||
|
||||
ui->verticalLayout_1->addWidget(viewerTrainees);
|
||||
ui->verticalLayout_1->addWidget(viewerInstructors);
|
||||
ui->verticalLayout_1->addWidget(messangerWidget);
|
||||
ui->horizontalLayout_3->addWidget(viewerTrainees);
|
||||
ui->horizontalLayout_3->addWidget(messangerWidget);
|
||||
|
||||
ui->verticalLayout_1->addWidget(viewerInstructors);
|
||||
ui->verticalLayout_2->addWidget(docTasksWidget);
|
||||
|
||||
viewerTrainees->setMinimumSize(1600, 600);
|
||||
viewerInstructors->setMinimumSize(1600, 300);
|
||||
viewerTrainees->setMinimumHeight(800);
|
||||
viewerInstructors->setMinimumSize(1800, 300);
|
||||
messangerWidget->setMinimumSize(400, 600);
|
||||
messangerWidget->setMaximumWidth(400);
|
||||
|
||||
ui->btnAuthorizationInstructor->setEnabled(false);
|
||||
|
||||
updateMyStyleSheet();
|
||||
}
|
||||
|
||||
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||
@@ -100,6 +107,33 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::updateMyStyleSheet()
|
||||
{
|
||||
QString styleSheet = loadStyleSheet();
|
||||
styleSheet = styleSheet.replace("\n", "");
|
||||
|
||||
this->setStyleSheet(styleSheet);
|
||||
}
|
||||
|
||||
QString InstructorsAndTraineesWidget::loadStyleSheet()
|
||||
{
|
||||
QString fileName = "./styleSheetMain.css";
|
||||
QFile styleSheetFile(fileName);
|
||||
if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Attention!"), tr("The file could not be opened ") + fileName);
|
||||
return QStringLiteral("");
|
||||
}
|
||||
else
|
||||
{
|
||||
QByteArray byteArray = styleSheetFile.readAll();
|
||||
styleSheetFile.close();
|
||||
|
||||
QString style = byteArray;
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::slot_LanguageChanged(QString language)
|
||||
{
|
||||
qtLanguageTranslator.load(QString(QStringLiteral("translations/InstructorsAndTraineesWidget_")) + language, QStringLiteral("."));
|
||||
@@ -328,6 +362,11 @@ void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(QString login,
|
||||
|
||||
void InstructorsAndTraineesWidget::on_btnUpdateStyleSheet_clicked()
|
||||
{
|
||||
/*
|
||||
viewerTrainees->updateMyStyleSheet();
|
||||
viewerInstructors->updateMyStyleSheet();
|
||||
messangerWidget->updateMyStyleSheet();
|
||||
*/
|
||||
|
||||
updateMyStyleSheet();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ public:
|
||||
private:
|
||||
void changeEvent(QEvent * event) override;
|
||||
|
||||
public:
|
||||
void updateMyStyleSheet();
|
||||
private:
|
||||
QString loadStyleSheet();
|
||||
|
||||
public Q_SLOTS:
|
||||
//Слот обработки смены языка
|
||||
void slot_LanguageChanged(QString language);
|
||||
|
||||
@@ -37,7 +37,11 @@
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1"/>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <QKeyEvent>
|
||||
#include "messangerwidget.h"
|
||||
#include "ui_messangerwidget.h"
|
||||
#include <QAbstractScrollArea>
|
||||
#include <QMessageBox>
|
||||
|
||||
MessangerWidget::MessangerWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -13,9 +15,14 @@ MessangerWidget::MessangerWidget(QWidget *parent) :
|
||||
ui->tabWidget->removeTab(1);
|
||||
ui->tabWidget->removeTab(0);
|
||||
|
||||
ui->btnSend->setObjectName("btnSend");
|
||||
|
||||
/*
|
||||
ui->tabWidget->setStyleSheet("QTabBar::tab:selected "
|
||||
"{background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);"
|
||||
"color: #ffffff;}");
|
||||
"color: #ffffff;}");*/
|
||||
|
||||
//updateMyStyleSheet();
|
||||
}
|
||||
|
||||
MessangerWidget::~MessangerWidget()
|
||||
@@ -23,42 +30,46 @@ MessangerWidget::~MessangerWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MessangerWidget::addMsg(QString login, QString name, QString text, MessangerWidget::ETypeMsg typeMsg)
|
||||
void MessangerWidget::addMsg(Trainee trainee, QString text, MessangerWidget::ETypeMsg typeMsg)
|
||||
{
|
||||
addDialogTab(login, name);
|
||||
addTabDialogMessenger(trainee);
|
||||
|
||||
QString prefix = (typeMsg == MessangerWidget::ETypeMsg::fromClient)? ">> " : "<< ";
|
||||
|
||||
//Ищем нужный диалог
|
||||
foreach(DialogMsg dialogMsg, listDialogMsg)
|
||||
foreach(TabDialogMessenger dialogMsg, listTabDialogMessenger)
|
||||
{
|
||||
if(dialogMsg.getLogin() == login)
|
||||
if(dialogMsg.getLogin() == trainee.getLogin())
|
||||
{
|
||||
//Добавляем в существующую вкладку
|
||||
ui->tabWidget->setCurrentIndex(dialogMsg.getIndexTab());
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem(QIcon(":/icons/trainee.png"), prefix + text);
|
||||
item->setBackground(QBrush(QColor(200, 200, 255)));
|
||||
//item->setTextAlignment(Qt::AlignBaseline);
|
||||
//QString style = QStringLiteral("QListView::item { color: red; }");
|
||||
//dialogMsg.getListWidget()->setStyleSheet(style);
|
||||
|
||||
//item->setBackground(QBrush(QColor(200, 200, 255)));
|
||||
dialogMsg.getListWidget()->addItem(item);
|
||||
|
||||
currLogin = login;
|
||||
currLogin = trainee.getLogin();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessangerWidget::addDialogTab(QString login, QString name)
|
||||
void MessangerWidget::addTabDialogMessenger(Trainee trainee)
|
||||
{
|
||||
if(listDialogMsg.count() == 0)
|
||||
if(listTabDialogMessenger.count() == 0)
|
||||
{
|
||||
currLogin = login;
|
||||
currLogin = trainee.getLogin();
|
||||
emit signal_tabMessengerChanged(currLogin);
|
||||
}
|
||||
|
||||
//Проверяем наличие диалога с этим клиентом
|
||||
foreach(DialogMsg dialogMsg, listDialogMsg)
|
||||
foreach(TabDialogMessenger dialogMsg, listTabDialogMessenger)
|
||||
{
|
||||
if(dialogMsg.getLogin() == login)
|
||||
if(dialogMsg.getLogin() == trainee.getLogin())
|
||||
{//Диалог для этого клиента уже существует
|
||||
return;
|
||||
}
|
||||
@@ -66,16 +77,51 @@ void MessangerWidget::addDialogTab(QString login, QString name)
|
||||
|
||||
//Добавляем новую вкладку диалога
|
||||
QListWidget* listWidget = new QListWidget();
|
||||
int index = ui->tabWidget->addTab(listWidget, /*login + ": " +*/ name);
|
||||
listWidget->setWordWrap(true);
|
||||
listWidget->setItemAlignment(Qt::AlignmentFlag::AlignTop);
|
||||
int index = ui->tabWidget->addTab(listWidget, /*login + ": " +*/ trainee.getName());
|
||||
|
||||
if(trainee.getLoggedIn())
|
||||
ui->tabWidget->setTabIcon(index, QIcon(":/icons/circleGreen.png"));
|
||||
else
|
||||
ui->tabWidget->setTabIcon(index, QIcon(":/icons/circleGray.png"));
|
||||
|
||||
//Помещаем новый диалог в список диалогов
|
||||
DialogMsg dialogMsg(index, listWidget, login);
|
||||
listDialogMsg.append(dialogMsg);
|
||||
TabDialogMessenger dialogMsg(index, listWidget, trainee.getLogin());
|
||||
listTabDialogMessenger.append(dialogMsg);
|
||||
}
|
||||
|
||||
void MessangerWidget::updateMyStyleSheet()
|
||||
{
|
||||
QString styleSheet = loadStyleSheet();
|
||||
styleSheet = styleSheet.replace("\n", "");
|
||||
|
||||
foreach(TabDialogMessenger dialogMsg, listTabDialogMessenger)
|
||||
dialogMsg.getListWidget()->setStyleSheet(styleSheet);
|
||||
}
|
||||
|
||||
QString MessangerWidget::loadStyleSheet()
|
||||
{
|
||||
QString fileName = "./styleSheetListWidget.css";
|
||||
QFile styleSheetFile(fileName);
|
||||
if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Attention!"), tr("The file could not be opened ") + fileName);
|
||||
return QStringLiteral("");
|
||||
}
|
||||
else
|
||||
{
|
||||
QByteArray byteArray = styleSheetFile.readAll();
|
||||
styleSheetFile.close();
|
||||
|
||||
QString style = byteArray;
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
void MessangerWidget::on_btnSend_clicked()
|
||||
{
|
||||
QString text = ui->editMsg->text();
|
||||
QString text = ui->editMsg->toPlainText();
|
||||
|
||||
emit signal_msgToClientReady(currLogin, text);
|
||||
|
||||
@@ -84,7 +130,7 @@ void MessangerWidget::on_btnSend_clicked()
|
||||
QString prefix = "<< ";
|
||||
|
||||
//Ищем нужный диалог
|
||||
foreach(DialogMsg dialogMsg, listDialogMsg)
|
||||
foreach(TabDialogMessenger dialogMsg, listTabDialogMessenger)
|
||||
{
|
||||
if(dialogMsg.getLogin() == currLogin)
|
||||
{
|
||||
@@ -103,7 +149,7 @@ void MessangerWidget::on_btnSend_clicked()
|
||||
void MessangerWidget::on_tabWidget_currentChanged(int index)
|
||||
{
|
||||
//Ищем нужный диалог
|
||||
foreach(DialogMsg dialogMsg, listDialogMsg)
|
||||
foreach(TabDialogMessenger dialogMsg, listTabDialogMessenger)
|
||||
{
|
||||
if(dialogMsg.getIndexTab() == index)
|
||||
{
|
||||
@@ -117,7 +163,7 @@ void MessangerWidget::on_tabWidget_currentChanged(int index)
|
||||
void MessangerWidget::slot_traineeSelected(QString login)
|
||||
{
|
||||
//Ищем нужный диалог
|
||||
foreach(DialogMsg dialogMsg, listDialogMsg)
|
||||
foreach(TabDialogMessenger dialogMsg, listTabDialogMessenger)
|
||||
{
|
||||
if(dialogMsg.getLogin() == login)
|
||||
{
|
||||
@@ -136,16 +182,22 @@ void MessangerWidget::slot_LanguageChanged(QString language)
|
||||
|
||||
void MessangerWidget::slot_InitMessanger(QList<Trainee> listTrainees)
|
||||
{
|
||||
this->listTrainees = listTrainees;
|
||||
|
||||
for(Trainee trainee: listTrainees)
|
||||
{
|
||||
if(! trainee.getArchived())
|
||||
this->addDialogTab(trainee.getLogin(), trainee.getName());
|
||||
this->addTabDialogMessenger(trainee);
|
||||
}
|
||||
}
|
||||
|
||||
void MessangerWidget::slot_msgFromClientReady(QString login, QString text)
|
||||
{
|
||||
addMsg(login, "name", text, MessangerWidget::ETypeMsg::fromClient);
|
||||
for(Trainee trainee: listTrainees)
|
||||
{
|
||||
if(trainee.getLogin() == login)
|
||||
addMsg(trainee, text, MessangerWidget::ETypeMsg::fromClient);
|
||||
}
|
||||
}
|
||||
|
||||
void MessangerWidget::keyPressEvent(QKeyEvent *event)
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <trainee.h>
|
||||
#include "Datas.h"
|
||||
|
||||
class DialogMsg
|
||||
class TabDialogMessenger
|
||||
{
|
||||
public:
|
||||
DialogMsg();
|
||||
DialogMsg(int indexTab, QListWidget* listWidget, QString login)
|
||||
TabDialogMessenger();
|
||||
TabDialogMessenger(int indexTab, QListWidget* listWidget, QString login)
|
||||
{
|
||||
this->indexTab = indexTab;
|
||||
this->listWidget = listWidget;
|
||||
@@ -48,8 +48,13 @@ protected:
|
||||
public:
|
||||
enum ETypeMsg{fromClient, toClient};
|
||||
|
||||
void addMsg(QString login, QString name, QString text, ETypeMsg typeMsg);
|
||||
void addDialogTab(QString login, QString name);
|
||||
void addMsg(Trainee trainee, QString text, ETypeMsg typeMsg);
|
||||
void addTabDialogMessenger(Trainee trainee);
|
||||
|
||||
public:
|
||||
void updateMyStyleSheet();
|
||||
private:
|
||||
QString loadStyleSheet();
|
||||
|
||||
private slots:
|
||||
void on_btnSend_clicked();
|
||||
@@ -58,25 +63,26 @@ private slots:
|
||||
signals:
|
||||
//сигнал о готовности нового сообщения на отправку клиенту
|
||||
void signal_msgToClientReady(QString login, QString text);
|
||||
//сигнал об изменении вкладки диалога
|
||||
//сигнал об изменении вкладки диалога (TabDialogMessenger)
|
||||
void signal_tabMessengerChanged(QString login);
|
||||
|
||||
public slots:
|
||||
//слот обработки сигнала о выборе обучаемого
|
||||
void slot_traineeSelected(QString login);
|
||||
//слот обработки сигнала о смене языка
|
||||
void slot_LanguageChanged(QString language);
|
||||
//слот обработки сигнала об инициализации мессенджера
|
||||
void slot_InitMessanger(QList<Trainee> listTrainees);
|
||||
//слот обработки сигнала о выборе обучаемого
|
||||
void slot_traineeSelected(QString login);
|
||||
//слот о приходе нового сообщения от клиента
|
||||
void slot_msgFromClientReady(QString login, QString text);
|
||||
|
||||
private:
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
private:
|
||||
QList <DialogMsg> listDialogMsg;
|
||||
|
||||
QList <TabDialogMessenger> listTabDialogMessenger;
|
||||
QList<Trainee> listTrainees;
|
||||
QString currLogin = "";
|
||||
|
||||
Ui::MessangerWidget *ui;
|
||||
QTranslator qtLanguageTranslator;
|
||||
};
|
||||
|
||||
@@ -28,10 +28,90 @@
|
||||
<string>Messenger</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="editMsg">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>1000</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnSend">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>65</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1000</width>
|
||||
<height>1000</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/sendMsg.png</normaloff>:/icons/sendMsg.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>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
@@ -49,39 +129,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editMsg"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnSend">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/sendMsg.png</normaloff>:/icons/sendMsg.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -9,6 +9,8 @@ DialogEditGroup::DialogEditGroup(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
|
||||
ui->editName->setProperty("mandatoryField", true);
|
||||
}
|
||||
|
||||
DialogEditGroup::~DialogEditGroup()
|
||||
|
||||
@@ -9,6 +9,10 @@ DialogEditTrainee::DialogEditTrainee(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
|
||||
ui->editName->setProperty("mandatoryField", true);
|
||||
ui->editLogin->setProperty("mandatoryField", true);
|
||||
ui->editPassword->setProperty("mandatoryField", true);
|
||||
}
|
||||
|
||||
DialogEditTrainee::~DialogEditTrainee()
|
||||
|
||||
Reference in New Issue
Block a user