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 a077c434..ffee6d2a 100644 Binary files a/src/ui/i18n/i18n_ru.qm and b/src/ui/i18n/i18n_ru.qm differ 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? Удалить выбранную зону?