Skip to content

Commit

Permalink
Refs #99. Work in progress on Test Invitation Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Dec 13, 2024
1 parent 5c3d94b commit 1cd8a1c
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 79 deletions.
6 changes: 3 additions & 3 deletions client/resources/stylesheet.qss
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,21 @@ QTreeWidget::branch:open:has-children:has-siblings {
/*
QLineEdit
*/
QLineEdit, QSpinBox, QTextEdit, QDateTimeEdit, QTimeEdit{
QLineEdit, QSpinBox, QTextEdit, QDateTimeEdit, QTimeEdit, QDateEdit{
background-color: rgba(255,255,255,70%);
color:black;
min-height: 25px;
padding-left: 5px;
}

QLineEdit:!enabled, QSpinBox:!enabled, QTextEdit:!enabled, QDateTimeEdit:!enabled, QTimeEdit:!enabled{
QLineEdit:!enabled, QSpinBox:!enabled, QTextEdit:!enabled, QDateTimeEdit:!enabled, QTimeEdit:!enabled, QDateEdit:!enabled{
background-color: rgba(0,0,0,0%);
color:rgba(255,255,255,80%);
padding-left: 0px;
}


QDateTimeEdit::down-arrow:!enabled, QDateTimeEdit::up-arrow:!enabled {
QDateTimeEdit::down-arrow:!enabled, QDateTimeEdit::up-arrow:!enabled, QDateEdit::down-arrow:!enabled, QDateEdit::up-arrow:!enabled {
image: none;
}

Expand Down
14 changes: 14 additions & 0 deletions client/src/dialogs/TestInvitationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,25 @@ TestInvitationDialog::~TestInvitationDialog()
delete ui;
}

void TestInvitationDialog::setTestTypes(const QList<TeraData> &test_types)
{
ui->cmbTestType->clear();

for (TeraData tt: test_types){
ui->cmbTestType->addItem(tt.getName(), tt.getId());
}
}

void TestInvitationDialog::initUI()
{
ui->stackedPages->setCurrentIndex(0);
ui->btnPrevious->setEnabled(false);
ui->btnOK->setEnabled(false);

ui->dateExpiration->setDate(QDate::currentDate().addDays(30));

ui->widgetInvitees->setCountLimited(false);

}

void TestInvitationDialog::on_btnCancel_clicked()
Expand Down
5 changes: 3 additions & 2 deletions client/src/dialogs/TestInvitationDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define TESTINVITATIONDIALOG_H

#include <QDialog>
#include "TeraData.h"

namespace Ui {
class TestInvitationDialog;
Expand All @@ -15,15 +16,15 @@ class TestInvitationDialog : public QDialog
explicit TestInvitationDialog(QWidget *parent = nullptr);
~TestInvitationDialog();

void setTestTypes(const QList<TeraData>& test_types);

private slots:
void on_btnCancel_clicked();

void on_stackedPages_currentChanged(int current_index);

void on_btnPrevious_clicked();

void on_btnNext_clicked();

void on_btnOK_clicked();

private:
Expand Down
66 changes: 37 additions & 29 deletions client/src/dialogs/TestInvitationDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<iconset resource="../../resources/TeraClient.qrc">
<normaloff>:/icons/test.png</normaloff>:/icons/test.png</iconset>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QStackedWidget" name="stackedPages">
Expand All @@ -27,11 +30,11 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="pageTestType">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<item row="1" column="0">
<widget class="QLabel" name="lblMaxUsage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
Expand All @@ -45,34 +48,55 @@
</font>
</property>
<property name="text">
<string>Usage maximal</string>
<string>Usage maximal (0 = illimité)</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinBox">
<item row="1" column="1">
<widget class="QSpinBox" name="numUsage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>0</height>
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::UpDownArrows</enum>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDateEdit" name="dateEdit">
<item row="2" column="1">
<widget class="QDateEdit" name="dateExpiration">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>0</height>
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::UpDownArrows</enum>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="3" column="1">
<widget class="QCheckBox" name="chkInviteEmail">
<property name="text">
<string>Envoyer les invitations automatiquement par courriel</string>
Expand Down Expand Up @@ -113,7 +137,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QLabel" name="lblExpiration">
<property name="font">
<font>
Expand All @@ -128,23 +152,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="txtDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
Expand All @@ -162,7 +170,7 @@
<widget class="QWidget" name="pageTargets">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="SessionInviteWidget" name="widget" native="true"/>
<widget class="SessionInviteWidget" name="widgetInvitees" native="true"/>
</item>
</layout>
</widget>
Expand Down
23 changes: 22 additions & 1 deletion client/src/editors/ProjectWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ProjectWidget::ProjectWidget(ComManager *comMan, const TeraData *data, QWidget *

if (!dataIsNew()){
queryServicesProject();
queryTestTypesProject();
}

}
Expand Down Expand Up @@ -135,6 +136,7 @@ void ProjectWidget::connectSignals()
void ProjectWidget::initUI()
{
ui->wdgInvitations->setComManager(m_comManager);
ui->tabNav->setTabVisible(ui->tabNav->indexOf(ui->tabInvitations), false);

// Default display
ui->tabNav->setCurrentIndex(0);
Expand Down Expand Up @@ -510,6 +512,7 @@ void ProjectWidget::updateParticipant(const TeraData *participant)
item_last_online = new TableDateWidgetItem();
item_last_online->setTextAlignment(Qt::AlignCenter);
ui->tableSummary->setItem(current_row, 5, item_last_online);

}

// Set current values
Expand Down Expand Up @@ -713,6 +716,24 @@ void ProjectWidget::queryUsers()
queryDataRequest(WEB_PROJECTACCESS_PATH, args);
}

void ProjectWidget::refreshSelectedTestTypes()
{
QList<TeraData> test_types;
for (int i=0; i<ui->lstTestTypes->count(); i++){
QListWidgetItem* item = ui->lstTestTypes->item(i);
if (item->checkState() == Qt::Checked){
TeraData tt(TeraDataTypes::TERADATA_TESTTYPE);
tt.setName(item->text());
int id_test_type = m_listTestTypes_items.key(item);
tt.setId(id_test_type);
test_types.append(tt);
}
}

ui->tabNav->setTabVisible(ui->tabNav->indexOf(ui->tabInvitations), !test_types.isEmpty());
ui->wdgInvitations->setCurrentTestTypes(test_types);
}

void ProjectWidget::processFormsReply(QString form_type, QString data)
{
if (form_type == WEB_FORMS_QUERY_PROJECT){
Expand Down Expand Up @@ -760,7 +781,6 @@ void ProjectWidget::processParticipantsReply(QList<TeraData> participants, QUrlQ
// Only update state for now...
for (int i=0; i<participants.count(); i++){
updateParticipant(&participants.at(i));

}
}

Expand Down Expand Up @@ -886,6 +906,7 @@ void ProjectWidget::processTestTypeProjectReply(QList<TeraData> ttp_list, QUrlQu
}
}
}
refreshSelectedTestTypes();
}

void ProjectWidget::processTestTypeSiteReply(QList<TeraData> tts_list, QUrlQuery reply_query)
Expand Down
6 changes: 5 additions & 1 deletion client/src/editors/ProjectWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ private slots:

QHash<int, QTableWidgetItem*> m_tableUsers_items;
QMap<int, QTableWidgetItem*> m_tableUserGroups_items;
QHash<int, QTableWidgetItem*> m_tableParticipants_items;
QHash<int, QListWidgetItem*> m_listGroups_items;

QHash<int, QTableWidgetItem*> m_tableParticipants_items;
QHash<int, TeraData> m_participants;

QHash<int, QTreeWidgetItem*> m_treeDevices_items;
QHash<int, QTreeWidgetItem*> m_treeDevicesProjects_items;

Expand Down Expand Up @@ -119,6 +121,8 @@ private slots:
void queryUserGroupsProjectAccess();
void queryUsers();

void refreshSelectedTestTypes();

void addServiceTab(const TeraData& service_project);

void updateControlsState() override;
Expand Down
6 changes: 3 additions & 3 deletions client/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ int main(int argc, char* argv[])
ClientApp app(argc, argv);

//Set application style
#ifndef WIN32 // Don't set style on Windows - it creates some issues with combobox look.
//app->setStyle("windows");
#ifdef WIN32
app.setStyle("windows"); // Force use of "windows" style, not windows 11 one if on that OS, since it has some issues right now
#endif

//WebEngine default Settings
//QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
//QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
//QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
int rval = app.exec();
qDebug() << "Bye!";
//qDebug() << "Bye!";
return rval;
}
10 changes: 8 additions & 2 deletions client/src/widgets/SessionInviteWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ bool SessionInviteWidget::isEditable() const
return m_editable;
}

void SessionInviteWidget::setCountLimited(const bool &count_limited)
{
m_countLimited = count_limited;
ui->frameCount->setVisible(m_countLimited);
}

QList<TeraData> SessionInviteWidget::getParticipantsInSession()
{
QList<TeraData> rval;
Expand Down Expand Up @@ -929,7 +935,7 @@ void SessionInviteWidget::setSearching(const bool &search)
void SessionInviteWidget::on_btnInvite_clicked()
{
// Check if we are under the allowed maximum number of invitees in a session
if (getInviteesCount() + ui->lstInvitables->selectedItems().count() > MAX_INVITEES_IN_SESSION){
if (getInviteesCount() + ui->lstInvitables->selectedItems().count() > MAX_INVITEES_IN_SESSION && m_countLimited){
GlobalMessageBox msgbox;
msgbox.showError(tr("Nombre maximal d'invités atteint"), tr("Impossible d'ajouter ces invités à la séance: le nombre maximal de participants (") + QString::number(MAX_INVITEES_IN_SESSION) + ") " + tr("serait dépassé"));
return;
Expand Down Expand Up @@ -995,7 +1001,7 @@ void SessionInviteWidget::on_treeInvitees_itemDoubleClicked(QTreeWidgetItem *ite
{
Q_UNUSED(item)
Q_UNUSED(column)
if (!item->isDisabled())
if (!item->isDisabled() && item->parent())
on_btnRemove_clicked();
}

Expand Down
2 changes: 2 additions & 0 deletions client/src/widgets/SessionInviteWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class SessionInviteWidget : public QWidget

void setEditable(const bool &editable);
bool isEditable() const;
void setCountLimited(const bool &count_limited);

QList<TeraData> getParticipantsInSession();
QList<TeraData> getUsersInSession();
Expand Down Expand Up @@ -112,6 +113,7 @@ private slots:
bool m_searching;
bool m_confirmRemove;
bool m_editable;
bool m_countLimited = true;

QHash<int, TeraData> m_users; // id, data
QHash<int, TeraData> m_participants;
Expand Down
Loading

0 comments on commit 1cd8a1c

Please sign in to comment.