From 1b436745541b17079bd42df85ac0425258c81555 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Mon, 10 Feb 2020 07:33:00 +0500 Subject: [PATCH] UI: ProgramsWindow: Improve Block Time editing. --- src/ui/form/prog/programswindow.cpp | 84 +++++++++++---- src/ui/form/prog/programswindow.h | 7 +- src/ui/form/zone/zoneswindow.cpp | 5 +- src/ui/i18n/i18n_ru.qm | Bin 20740 -> 20916 bytes src/ui/i18n/i18n_ru.ts | 152 +++++++++++++++------------- 5 files changed, 157 insertions(+), 91 deletions(-) diff --git a/src/ui/form/prog/programswindow.cpp b/src/ui/form/prog/programswindow.cpp index 201baf82..3a57d2da 100644 --- a/src/ui/form/prog/programswindow.cpp +++ b/src/ui/form/prog/programswindow.cpp @@ -1,7 +1,9 @@ #include "programswindow.h" +#include #include #include +#include #include #include #include @@ -93,6 +95,9 @@ void ProgramsWindow::onRetranslateUi() m_btAllowApp->setText(tr("Allow")); m_btBlockApp->setText(tr("Block")); + m_formAppEdit->unsetLocale(); + m_formAppEdit->setWindowTitle(tr("Edit Program")); + m_labelEditPath->setText(tr("Program Path:")); m_btSelectFile->setToolTip(tr("Select File")); m_labelEditName->setText(tr("Program Name:")); @@ -100,13 +105,15 @@ void ProgramsWindow::onRetranslateUi() m_cbUseGroupPerm->setText(tr("Use Application Group's Enabled State")); m_rbAllowApp->setText(tr("Allow")); m_rbBlockApp->setText(tr("Block")); - m_cscBlockApp->checkBox()->setText(tr("Block In:")); + m_cscBlockAppIn->checkBox()->setText(tr("Block In:")); retranslateAppBlockInHours(); + m_cbBlockAppAt->setText(tr("Block At:")); + m_dteBlockAppAt->unsetLocale(); + m_cbBlockAppNone->setText(tr("Forever")); + m_btEditOk->setText(tr("OK")); m_btEditCancel->setText(tr("Cancel")); - m_formAppEdit->setWindowTitle(tr("Edit Program")); - m_btLogOptions->setText(tr("Options")); m_cbLogBlocked->setText(tr("Show New Programs")); @@ -125,8 +132,8 @@ void ProgramsWindow::retranslateAppBlockInHours() tr("12 hours"), tr("Day"), tr("Week"), tr("Month") }; - m_cscBlockApp->setNames(list); - m_cscBlockApp->spinBox()->setSuffix(tr(" hours")); + m_cscBlockAppIn->setNames(list); + m_cscBlockAppIn->spinBox()->setSuffix(tr(" hours")); } void ProgramsWindow::setupUi() @@ -217,10 +224,23 @@ void ProgramsWindow::setupAppEditForm() allowLayout->addWidget(m_rbBlockApp, 1, Qt::AlignLeft); // Block after N hours - m_cscBlockApp = new CheckSpinCombo(); - m_cscBlockApp->spinBox()->setRange(1, 24 * 30 * 12); // ~Year - m_cscBlockApp->setValues(appBlockInHourValues); - m_cscBlockApp->setNamesByValues(); + m_cscBlockAppIn = new CheckSpinCombo(); + m_cscBlockAppIn->spinBox()->setRange(1, 24 * 30 * 12); // ~Year + m_cscBlockAppIn->setValues(appBlockInHourValues); + m_cscBlockAppIn->setNamesByValues(); + + // Block at specified date & time + auto blockAtLayout = setupCheckDateTimeEdit(); + + // Allow Forever + m_cbBlockAppNone = new QCheckBox(); + + // Eclusive End Time CheckBoxes Group + auto group = new QButtonGroup(this); + group->setExclusive(true); + group->addButton(m_cscBlockAppIn->checkBox()); + group->addButton(m_cbBlockAppAt); + group->addButton(m_cbBlockAppNone); // OK/Cancel auto buttonsLayout = new QHBoxLayout(); @@ -238,7 +258,9 @@ void ProgramsWindow::setupAppEditForm() layout->addLayout(formLayout); layout->addWidget(ControlUtil::createSeparator()); layout->addLayout(allowLayout); - layout->addWidget(m_cscBlockApp); + layout->addWidget(m_cscBlockAppIn); + layout->addLayout(blockAtLayout); + layout->addWidget(m_cbBlockAppNone); layout->addWidget(ControlUtil::createSeparator()); layout->addLayout(buttonsLayout); @@ -258,7 +280,12 @@ void ProgramsWindow::setupAppEditForm() } }); - connect(m_rbAllowApp, &QRadioButton::toggled, m_cscBlockApp, &CheckSpinCombo::setEnabled); + connect(m_rbAllowApp, &QRadioButton::toggled, [&](bool checked) { + m_cbBlockAppNone->setEnabled(checked); + m_cscBlockAppIn->setEnabled(checked); + m_cbBlockAppAt->setEnabled(checked); + m_dteBlockAppAt->setEnabled(checked); + }); connect(m_btEditOk, &QAbstractButton::clicked, [&] { if (saveAppEditForm()) { @@ -285,6 +312,21 @@ void ProgramsWindow::setupComboAppGroups() connect(confManager(), &ConfManager::confSaved, this, refreshComboAppGroups); } +QLayout *ProgramsWindow::setupCheckDateTimeEdit() +{ + m_cbBlockAppAt = new QCheckBox(); + + m_dteBlockAppAt = new QDateTimeEdit(); + m_dteBlockAppAt->setCalendarPopup(true); + + auto layout = new QHBoxLayout(); + layout->setMargin(0); + layout->addWidget(m_cbBlockAppAt, 1); + layout->addWidget(m_dteBlockAppAt); + + return layout; +} + QLayout *ProgramsWindow::setupHeader() { auto layout = new QHBoxLayout(); @@ -526,8 +568,12 @@ void ProgramsWindow::updateAppEditForm(bool editCurrentApp) m_cbUseGroupPerm->setChecked(appRow.useGroupPerm); m_rbAllowApp->setChecked(!appRow.blocked); m_rbBlockApp->setChecked(appRow.blocked); - m_cscBlockApp->setEnabled(!appRow.blocked); - m_cscBlockApp->checkBox()->setChecked(false); + m_cscBlockAppIn->checkBox()->setChecked(false); + m_cscBlockAppIn->spinBox()->setValue(1); + m_cbBlockAppAt->setChecked(!appRow.endTime.isNull()); + m_dteBlockAppAt->setDateTime(appRow.endTime); + m_dteBlockAppAt->setMinimumDateTime(QDateTime::currentDateTime()); + m_cbBlockAppNone->setChecked(appRow.endTime.isNull()); m_formAppEdit->show(); } @@ -544,11 +590,15 @@ bool ProgramsWindow::saveAppEditForm() const bool blocked = m_rbBlockApp->isChecked(); QDateTime endTime; - if (!blocked && m_cscBlockApp->checkBox()->isChecked()) { - const int hours = m_cscBlockApp->spinBox()->value(); + if (!blocked) { + if (m_cscBlockAppIn->checkBox()->isChecked()) { + const int hours = m_cscBlockAppIn->spinBox()->value(); - endTime = QDateTime::currentDateTime() - .addSecs(hours * 60 * 60); + endTime = QDateTime::currentDateTime() + .addSecs(hours * 60 * 60); + } else if (m_cbBlockAppAt->isChecked()) { + endTime = m_dteBlockAppAt->dateTime(); + } } // Add new app diff --git a/src/ui/form/prog/programswindow.h b/src/ui/form/prog/programswindow.h index c95e1914..fc932084 100644 --- a/src/ui/form/prog/programswindow.h +++ b/src/ui/form/prog/programswindow.h @@ -5,6 +5,7 @@ QT_FORWARD_DECLARE_CLASS(QCheckBox) QT_FORWARD_DECLARE_CLASS(QComboBox) +QT_FORWARD_DECLARE_CLASS(QDateTimeEdit) QT_FORWARD_DECLARE_CLASS(QDialog) QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QLineEdit) @@ -45,6 +46,7 @@ private: void setupUi(); void setupAppEditForm(); void setupComboAppGroups(); + QLayout *setupCheckDateTimeEdit(); QLayout *setupHeader(); void setupLogOptions(); void setupLogBlocked(); @@ -98,7 +100,10 @@ private: QCheckBox *m_cbUseGroupPerm = nullptr; QRadioButton *m_rbAllowApp = nullptr; QRadioButton *m_rbBlockApp = nullptr; - CheckSpinCombo *m_cscBlockApp = nullptr; + CheckSpinCombo *m_cscBlockAppIn = nullptr; + QCheckBox *m_cbBlockAppAt = nullptr; + QDateTimeEdit *m_dteBlockAppAt = nullptr; + QCheckBox *m_cbBlockAppNone = nullptr; QPushButton *m_btEditOk = nullptr; QPushButton *m_btEditCancel = nullptr; QDialog *m_formAppEdit = nullptr; diff --git a/src/ui/form/zone/zoneswindow.cpp b/src/ui/form/zone/zoneswindow.cpp index 015938e9..8df8a383 100644 --- a/src/ui/form/zone/zoneswindow.cpp +++ b/src/ui/form/zone/zoneswindow.cpp @@ -77,6 +77,9 @@ void ZonesWindow::onRetranslateUi() m_actEditZone->setText(tr("Edit")); m_actRemoveZone->setText(tr("Remove")); + m_formZoneEdit->unsetLocale(); + m_formZoneEdit->setWindowTitle(tr("Edit Zone")); + m_labelZoneName->setText(tr("Zone Name:")); m_labelSource->setText(tr("Source:")); m_cbEnabled->setText(tr("Enabled")); @@ -87,8 +90,6 @@ void ZonesWindow::onRetranslateUi() m_btEditOk->setText(tr("OK")); m_btEditCancel->setText(tr("Cancel")); - m_formZoneEdit->setWindowTitle(tr("Edit Zone")); - zoneListModel()->refresh(); this->setWindowTitle(tr("Zones")); diff --git a/src/ui/i18n/i18n_ru.qm b/src/ui/i18n/i18n_ru.qm index a077c434741fb1166d420fea5cb16876360e7a8f..ffee6d2a2536f231e3c9e69209850deed4a4e39f 100644 GIT binary patch delta 1476 zcmXApeN0nV7{;IWeiq8D1_cBZL{_9wkU~WY@=>IPMsdm_3Mh)WIfURQ#))G^rejX# z)N7s2byIN+anocXI2B!Rf}lG-7ykWdv zO8Yx|P_^$qpbcbHRZWn^mWGbpA|TC#yA|2=(K7rt{sdUC2?JmI0J;WEPT**$|xo}iQx|K;*W%w%6LS9Wh1U_YYn z)<(HU_^kddKzK2~;oO^KUJqkNDqmeq!ixy9kz`hTsi4j89y9P$wjQ>$NR`} z%U;IRXF}9oI?QxVa9?Z&k_v?;#|>c4Vn*|SjJX|xSK|Wa4hde#1Vq0ocnzT>;5(t^ zriTt)D|CE53IsO^H+(DTMD_^1)*6H$CrKFSrhtiQ!r;Ohz{etT&6IKGeYJ}-YBP4I z|8T~LSWes_ax|(Jk57~VQ)KblJF@|Qvv}u`jb!z!WKZSR4fdtF6ETed*RQ)e@*KVhDbRJVUPskuRF??zgX5xnmfA|$ zrEt==ZhhVINMQO|#;`N`_tqBy3qR0%3l*xNz50jaw4KGSR*7NJr~Q@<7f|k5ek%;Y zv`XL_oCC`(%i^)uZ$+A}fOilt+&$=n836CZ3X5O hdi|#GtQwoT(-L%khzkG! delta 1302 zcmXApdr(w$6vw~2d++XLUG5!6Vv*Mh?kup#YkA1>kjKLE$RMOp5i?$93_^uWO-UeW zBr+Ovfl?tAlu(?U2^7r$2SNlaowQ5{rlN-dQt2!;5>1D>e|_e6e~?>j33t;yj%x08$SEKK}w+`vB8UAiEbx zCm{Zp&QWReo zi7|SnV{t7IKhB)*+zxR6N%XlQG4Q^`@Vm?v4c)8Mz0OQ;S#~UsnGK-iJhw0lBg>A@ zN{mcry$(?^qx0Fy%WafK4_jv)0@iMn==ZF|WJk6|Wdyuu*cQQ+0)NW3-)N*_=dqWX z9|O*H?9hrLs>JW?aOfWDss?sqz>HNeHM7&v^g(S>D%vR1*kEx;VUTZ_5FaWGYTtb2 zTS^5GQ!KhM+7zSmYlokyBJIjwg1!KBF%lDeRo1QKV(>%avdFzEYc{zTET}e>k5VTt zsa}e5p?i;26|a%V*b1?N(fX9CE_%`sgx9LR879xdwOoMbO7gCRGd)8wbv7<4m%c}2 zh`o$^eDXV7)2sV{05x~CWfg!nu07`?>U$rF2{*akI(jbVBsZ9Mj7nnT?yZ~y{5bB% z&U3W>Ky+iZ9u~Wr&+@4J7wk^?)&Po8yT19q0GCX=f$h2U`n%%uY?!lOjXFJ^Y?JR% z7ats_3{urK-4}t7D)9{KueP3Cv7gsaOV)^!th;<&mAJ%OO-bdNvdxrUoTsK@lOA~L z6N$P`&D;6eK-90Amd!lX_>g9NfouwD70Z=64?Fve*-XkO&OS?Urc)*MIVWiTW5(@w z-K55i(2BiEL#5xBe5NaHoA2|*BRi+b&p8Qp4w diff --git a/src/ui/i18n/i18n_ru.ts b/src/ui/i18n/i18n_ru.ts index 14625cf1..e56c1fc8 100644 --- a/src/ui/i18n/i18n_ru.ts +++ b/src/ui/i18n/i18n_ru.ts @@ -246,12 +246,12 @@ ConfManager - + Configuration Error Ошибка конфигурации - + Application '%1' already exists Приложение '%1' уже существует @@ -259,42 +259,42 @@ ConfUtil - + Bad Include IP address: %1 Некорректный IP адрес для включения: %1 - + Bad Exclude IP address: %1 Некорректный IP адрес для исключения: %1 - + Too many IP addresses Слишком много IP адресов - + Number of Application Groups must be between 1 and %1 Количество групп приложений должно быть от 1 до %1 - + Too many application paths Слишком много путей приложений - + Length of Application Group's Name must be < %1 Длина наименования группы приложения должна быть < %1 - + Application '%1' already exists Приложение '%1' уже существует - + Length of Application's Path must be < %1 Длина пути приложения должна быть < %1 @@ -595,7 +595,7 @@ OptionsWindow - + Options Опции @@ -603,162 +603,172 @@ ProgramsWindow - + Add Добавить - + Edit Изменить - + Purge All Прочистить всё - - - + + + Allow Разрешить - - - + + + Block Блокировать - + Program Path: Путь программы: - + Select File Выбрать файл - + Program Name: Наименование программы: - + Application Group: Группа приложений: - + Use Application Group's Enabled State Использовать вкл. состояние Группы приложения - + Block In: Блокировать через: - + + Block At: + Блокировать в заданное время: + + + + Forever + Навсегда + + + OK OK - + Cancel Отмена - + Edit Program Редактирование программы - + Options Опции - + Show New Programs Показывать новые программы - + Are you sure to remove selected program(s)? Удалить выбранные программы? - + Copy Path Копировать путь - + Open Folder Открыть папку - + Custom Нестандартный - + 1 hour 1 час - + 6 hours 6 часов - + 12 hours 12 часов - + Day День - + Week Неделя - + Month Месяц - + hours час. - + Programs Программы - + Remove Удалить - + Are you sure to remove all non-existent programs? Удалить все несуществующие программы? - + Programs (*.exe);;All files (*.*) Программы (*.exe);;Все файлы (*.*) @@ -784,52 +794,52 @@ SchedulePage - + Run Запустить - + Abort Остановить - + Custom Нестандартный - + Hourly Каждый час - + Each 6 hours Каждые 6 часов - + Each 12 hours Каждые 12 часов - + Daily Каждый день - + Weekly Каждую неделю - + Monthly Каждый месяц - + hours час. @@ -1196,78 +1206,78 @@ ZonesWindow - + Edit Изменить - + Add Добавить - + Remove Удалить - + Zone Name: Наименование зоны: - + Source: Источник: - + Enabled Включено - + Store Text Сохранять текст - + Custom URL Нестандартная ссылка - + URL: Ссылка: - + Form Data: Данные формы: - + OK OK - + Cancel Отмена - + Edit Zone Редактирование зоны - + Zones Зоны - + Are you sure to remove selected zone? Удалить выбранную зону?