fix meeting setup ui + force meeting end before midnight

This commit is contained in:
Gaelle Braud 2024-08-12 12:56:12 +02:00
parent c843829920
commit 8cffd73df5
5 changed files with 354 additions and 319 deletions

View file

@ -1294,6 +1294,11 @@ QDateTime Utils::addYears(QDateTime date, int years) {
return date;
}
int Utils::timeOffset(QDateTime start, QDateTime end) {
qDebug() << "offset between times" << start.msecsTo(end);
return start.msecsTo(end);
}
int Utils::getYear(const QDate &date) {
return date.year();
}

View file

@ -112,6 +112,7 @@ public:
Q_INVOKABLE static int secsTo(const QString &start, const QString &end);
Q_INVOKABLE static QDateTime addSecs(QDateTime date, int secs);
Q_INVOKABLE static QDateTime addYears(QDateTime date, int years);
Q_INVOKABLE static int timeOffset(QDateTime start, QDateTime end);
Q_INVOKABLE static QString interpretUrl(const QString &uri);
Q_INVOKABLE static bool isValidSIPAddress(const QString &uri);
Q_INVOKABLE static bool isValidIPAddress(const QString &host);

View file

@ -7,6 +7,7 @@ import Linphone
ComboBox {
id: mainItem
readonly property var selectedDate: calendar.selectedDate
onSelectedDateChanged: popupItem.close()
property alias calendar: calendar
property alias contentText: contentText
contentItem: Text {

View file

@ -14,6 +14,7 @@ FocusScope{
signal returnRequested()
signal saveSucceed(bool isCreation)
ColumnLayout {
Connections {
target: mainItem.conferenceInfoGui.core
function onSchedulerStateChanged() {
@ -111,41 +112,18 @@ FocusScope{
Layout.topMargin: 10 * DefaultStyle.dp
content: [
RowLayout {
spacing: 8 * DefaultStyle.dp
EffectImage {
imageSource: AppIcons.clock
colorizationColor: DefaultStyle.main2_600
Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp
colorizationColor: DefaultStyle.main2_600
}
Text {
text: qsTr("Toute la journée")
font {
pixelSize: 14 * DefaultStyle.dp
weight: 700 * DefaultStyle.dp
}
}
Item{Layout.fillWidth: true}
Switch {
id: allDaySwitch
readonly property bool isAllDay: position === 1
KeyNavigation.up: confTitle
KeyNavigation.down: startDate
onPositionChanged: if (position === 1) {
mainItem.conferenceInfoGui.core.dateTime = UtilsCpp.createDateTime(startDate.selectedDate, 0, 0)
mainItem.conferenceInfoGui.core.endDateTime = UtilsCpp.createDateTime(endDate.selectedDate, 23, 59)
}
Component.onCompleted: if (mainItem.conferenceInfoGui.core.isAllDayConf()) toggle
}
},
RowLayout {
spacing: 8 * DefaultStyle.dp
CalendarComboBox {
id: startDate
background.visible: mainItem.isCreation
indicator.visible: mainItem.isCreation
contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp
Layout.preferredWidth: 200 * DefaultStyle.dp
Layout.fillWidth: true
Layout.preferredHeight: 30 * DefaultStyle.dp
KeyNavigation.up: allDaySwitch
KeyNavigation.down: endDate
@ -161,7 +139,14 @@ FocusScope{
}
}
}
Item{Layout.fillWidth: true}
},
RowLayout {
Item {
Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp
}
RowLayout {
visible: allDaySwitch.position === 0
TimeComboBox {
id: startHour
visible: allDaySwitch.position === 0
@ -175,31 +160,14 @@ FocusScope{
KeyNavigation.down: endDate
KeyNavigation.left: startDate
KeyNavigation.right: startDate
onSelectedHourChanged: {
mainItem.conferenceInfoGui.core.dateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin)
onSelectedDateTimeChanged: {
endHour.minTime = selectedDateTime
endHour.maxTime = UtilsCpp.createDateTime(selectedDateTime, 23, 59)
mainItem.conferenceInfoGui.core.dateTime = selectedDateTime
endDate.calendar.selectedDate = UtilsCpp.addSecs(selectedDateTime, 3600)
endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)//Qt.formatDateTime(UtilsCpp.createDateTime(new Date(), selectedHour == 23 ? 23 : selectedHour + 1, selectedHour == 23 ? 59 : selectedMin), "hh:mm")
}
onSelectedMinChanged: {
mainItem.conferenceInfoGui.core.dateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin)
endDate.calendar.selectedDate = UtilsCpp.addSecs(selectedDateTime, 3600)
endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)//UtilsCpp.createDateTime(selectedDateTime, selectedHour == 23 ? 23 : selectedHour + 1, selectedHour == 23 ? 59 : selectedMin)
endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)
}
}
},
RowLayout {
spacing: 8 * DefaultStyle.dp
CalendarComboBox {
id: endDate
background.visible: mainItem.isCreation
indicator.visible: mainItem.isCreation
// Layout.fillWidth: true
Layout.preferredWidth: 200 * DefaultStyle.dp
Layout.preferredHeight: 30 * DefaultStyle.dp
contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp
onSelectedDateChanged: if (selectedDate) mainItem.conferenceInfoGui.core.endDateTime = UtilsCpp.createDateTime(selectedDate, endHour.selectedHour, endHour.selectedMin)
}
Item{Layout.fillWidth: true}
TimeComboBox {
id: endHour
visible: allDaySwitch.position === 0
@ -208,10 +176,55 @@ FocusScope{
Layout.preferredHeight: 30 * DefaultStyle.dp
background.visible: mainItem.isCreation
contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp
onSelectedHourChanged: mainItem.conferenceInfoGui.core.endDateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin)
onSelectedMinChanged: mainItem.conferenceInfoGui.core.endDateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin)
onSelectedDateTimeChanged: mainItem.conferenceInfoGui.core.endDateTime = selectedDateTime
}
Item {
Layout.fillWidth: true
}
Text {
property int durationSec: UtilsCpp.secsTo(startHour.selectedTime, endHour.selectedTime)
property int hour: durationSec/3600
property int min: (durationSec - hour*3600)/60
text: (hour > 0 ? hour + "h" : "") + (min > 0 ? min + "mn" : "")
font {
pixelSize: 14 * DefaultStyle.dp
weight: 700 * DefaultStyle.dp
}
}
}
CalendarComboBox {
id: endDate
visible: allDaySwitch.position === 1
background.visible: mainItem.isCreation
indicator.visible: mainItem.isCreation
Layout.fillWidth: true
Layout.preferredHeight: 30 * DefaultStyle.dp
contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp
onSelectedDateChanged: if (selectedDate) mainItem.conferenceInfoGui.core.endDateTime = UtilsCpp.createDateTime(selectedDate, endHour.selectedHour, endHour.selectedMin)
}
},
RowLayout {
Item {
Layout.preferredWidth: 24 * DefaultStyle.dp
Layout.preferredHeight: 24 * DefaultStyle.dp
}
RowLayout {
Switch {
id: allDaySwitch
text: qsTr("Toute la journée")
onPositionChanged: {
if (position == 1) {
mainItem.conferenceInfoGui.core.dateTime = UtilsCpp.createDateTime(startDate.selectedDate, 0, 0)
mainItem.conferenceInfoGui.core.endDateTime = UtilsCpp.createDateTime(endDate.selectedDate, 23, 59)
} else {
mainItem.conferenceInfoGui.core.dateTime = UtilsCpp.createDateTime(startDate.selectedDate, startHour.selectedHour, startHour.selectedMin)
mainItem.conferenceInfoGui.core.endDateTime = UtilsCpp.createDateTime(endDate.selectedDate, endHour.selectedHour, endHour.selectedMin)
}
}
}
}
},
ComboBox {
id: timeZoneCbox
@ -360,3 +373,4 @@ FocusScope{
Layout.minimumHeight: 1 * DefaultStyle.dp
}
}
}

View file

@ -5,13 +5,25 @@ import UtilsCpp 1.0
ComboBox {
id: mainItem
property var selectedDateTime
onSelectedDateTimeChanged: {
if (minTime != undefined) {
if (UtilsCpp.timeOffset(minTime, selectedDateTime) < 0)
selectedDateTime = minTime
}
if (maxTime != undefined) {
if (UtilsCpp.timeOffset(maxTime, selectedDateTime) > 0)
selectedDateTime = maxTime
}
}
readonly property string selectedTimeString: Qt.formatDateTime(selectedDateTime, "hh:mm")
property int selectedHour: input.hour*1
property int selectedMin: input.min*1
property alias contentText: input
property var minTime
property var maxTime
popup.width: 73 * DefaultStyle.dp
listView.model: 48
listView.implicitHeight: 204 * DefaultStyle.dp
listView.height: Math.min(204 * DefaultStyle.dp, listView.implicitHeight)
editable: true
popup.closePolicy: Popup.PressOutsideParent | Popup.CloseOnPressOutside
onCurrentTextChanged: input.text = currentText
@ -48,18 +60,20 @@ ComboBox {
focus = false
}
}
onEditingFinished: {
console.log("set time", hour, min)
onFocusChanged: if (!focus) {
mainItem.selectedDateTime = UtilsCpp.createDateTime(mainItem.selectedDateTime, hour, min)
console.log("set time", hour, min)
}
}
listView.delegate: Text {
id: hourDelegate
property int hour: modelData /2
property int min: modelData%2 === 0 ? 0 : 30
text: Qt.formatDateTime(UtilsCpp.createDateTime(new Date(), hour, min), "hh:mm")
property var currentDateTime: UtilsCpp.createDateTime(new Date(), hour, min)
text: Qt.formatDateTime(currentDateTime, "hh:mm")
width: mainItem.width
height: 25 * DefaultStyle.dp
visible: mainItem.minTime == undefined || UtilsCpp.timeOffset(mainItem.minTime, currentDateTime) > 0
height: visible ? 25 * DefaultStyle.dp : 0
verticalAlignment: TextInput.AlignVCenter
horizontalAlignment: TextInput.AlignHCenter
font {