UI: Options: Add "Auto-Show Alert Window for New Programs" & "Alert Window is Always on top" flags

This commit is contained in:
Nodir Temirkhodjaev 2024-02-01 12:51:23 +03:00
parent cedb00d6ad
commit c0914b3890
5 changed files with 39 additions and 6 deletions

View File

@ -169,6 +169,8 @@ void OptionsPage::onRetranslateUi()
m_cbLogBlocked->setText(tr("Collect New Programs")); m_cbLogBlocked->setText(tr("Collect New Programs"));
m_cbAppNotifyMessage->setText(tr("Use System Notifications for New Programs")); m_cbAppNotifyMessage->setText(tr("Use System Notifications for New Programs"));
m_cbAppAlertAutoShow->setText(tr("Auto-Show Alert Window for New Programs"));
m_cbAppAlertAlwaysOnTop->setText(tr("Alert Window is Always on top"));
m_cbPurgeOnStart->setText(tr("Purge Obsolete on startup")); m_cbPurgeOnStart->setText(tr("Purge Obsolete on startup"));
m_cbPurgeOnMounted->setText(tr("Purge Obsolete only on mounted drives")); m_cbPurgeOnMounted->setText(tr("Purge Obsolete only on mounted drives"));
@ -525,6 +527,18 @@ void OptionsPage::setupProgBox()
ctrl()->setIniUserEdited(); ctrl()->setIniUserEdited();
}); });
m_cbAppAlertAutoShow =
ControlUtil::createCheckBox(iniUser()->progAlertWindowAutoShow(), [&](bool checked) {
iniUser()->setProgAlertWindowAutoShow(checked);
ctrl()->setIniUserEdited();
});
m_cbAppAlertAlwaysOnTop =
ControlUtil::createCheckBox(iniUser()->progAlertWindowAlwaysOnTop(), [&](bool checked) {
iniUser()->setProgAlertWindowAlwaysOnTop(checked);
ctrl()->setIniUserEdited();
});
m_cbPurgeOnStart = ControlUtil::createCheckBox(ini()->progPurgeOnStart(), [&](bool checked) { m_cbPurgeOnStart = ControlUtil::createCheckBox(ini()->progPurgeOnStart(), [&](bool checked) {
if (ini()->progPurgeOnStart() != checked) { if (ini()->progPurgeOnStart() != checked) {
ini()->setProgPurgeOnStart(checked); ini()->setProgPurgeOnStart(checked);
@ -541,8 +555,9 @@ void OptionsPage::setupProgBox()
}); });
// Layout // Layout
auto layout = ControlUtil::createVLayoutByWidgets({ m_cbLogBlocked, m_cbAppNotifyMessage, auto layout = ControlUtil::createVLayoutByWidgets(
ControlUtil::createSeparator(), m_cbPurgeOnStart, m_cbPurgeOnMounted }); { m_cbLogBlocked, m_cbAppNotifyMessage, m_cbAppAlertAutoShow, m_cbAppAlertAlwaysOnTop,
ControlUtil::createSeparator(), m_cbPurgeOnStart, m_cbPurgeOnMounted });
m_gbProg = new QGroupBox(); m_gbProg = new QGroupBox();
m_gbProg->setLayout(layout); m_gbProg->setLayout(layout);

View File

@ -99,6 +99,8 @@ private:
QToolButton *m_btPasswordLock = nullptr; QToolButton *m_btPasswordLock = nullptr;
QCheckBox *m_cbLogBlocked = nullptr; QCheckBox *m_cbLogBlocked = nullptr;
QCheckBox *m_cbAppNotifyMessage = nullptr; QCheckBox *m_cbAppNotifyMessage = nullptr;
QCheckBox *m_cbAppAlertAutoShow = nullptr;
QCheckBox *m_cbAppAlertAlwaysOnTop = nullptr;
QCheckBox *m_cbPurgeOnStart = nullptr; QCheckBox *m_cbPurgeOnStart = nullptr;
QCheckBox *m_cbPurgeOnMounted = nullptr; QCheckBox *m_cbPurgeOnMounted = nullptr;

View File

@ -9,7 +9,7 @@
#include "programscontroller.h" #include "programscontroller.h"
ProgramAlertWindow::ProgramAlertWindow(QWidget *parent) : ProgramAlertWindow::ProgramAlertWindow(QWidget *parent) :
ProgramEditDialog(new ProgramsController(/*this*/), parent, Qt::Window), ProgramEditDialog(new ProgramsController(/*this*/), parent),
m_stateWatcher(new WidgetWindowStateWatcher(this)) m_stateWatcher(new WidgetWindowStateWatcher(this))
{ {
setupUi(); setupUi();
@ -71,6 +71,9 @@ void ProgramAlertWindow::setupUi()
// Modality // Modality
this->setWindowModality(Qt::NonModal); this->setWindowModality(Qt::NonModal);
// Top Window
this->setWindowFlag(Qt::WindowStaysOnTopHint, iniUser()->progAlertWindowAlwaysOnTop());
// Icon // Icon
this->setWindowIcon(GuiUtil::overlayIcon(":/icons/fort.png", ":/icons/error.png")); this->setWindowIcon(GuiUtil::overlayIcon(":/icons/fort.png", ":/icons/error.png"));
} }

View File

@ -555,10 +555,14 @@ void TrayIcon::updateAppGroupActions()
void TrayIcon::sendAlertMessage() void TrayIcon::sendAlertMessage()
{ {
if (!iniUser()->progNotifyMessage()) if (iniUser()->progNotifyMessage()) {
return; windowManager()->showTrayMessage(
tr("New program detected!"), WindowManager::TrayMessageAlert);
}
windowManager()->showTrayMessage(tr("New program detected!"), WindowManager::TrayMessageAlert); if (iniUser()->progAlertWindowAutoShow()) {
windowManager()->showProgramAlertWindow();
}
} }
void TrayIcon::updateAlertTimer() void TrayIcon::updateAlertTimer()

View File

@ -101,6 +101,15 @@ public:
bool progAlertWindowMaximized() const { return valueBool("progAlertWindow/maximized"); } bool progAlertWindowMaximized() const { return valueBool("progAlertWindow/maximized"); }
void setProgAlertWindowMaximized(bool on) { setValue("progAlertWindow/maximized", on); } void setProgAlertWindowMaximized(bool on) { setValue("progAlertWindow/maximized", on); }
bool progAlertWindowAutoShow() const { return valueBool("progAlertWindow/autoShow", true); }
void setProgAlertWindowAutoShow(bool on) { setValue("progAlertWindow/autoShow", on); }
bool progAlertWindowAlwaysOnTop() const
{
return valueBool("progAlertWindow/alwaysOnTop", true);
}
void setProgAlertWindowAlwaysOnTop(bool on) { setValue("progAlertWindow/alwaysOnTop", on); }
QRect optWindowGeometry() const { return value("optWindow/geometry").toRect(); } QRect optWindowGeometry() const { return value("optWindow/geometry").toRect(); }
void setOptWindowGeometry(const QRect &v) { setValue("optWindow/geometry", v); } void setOptWindowGeometry(const QRect &v) { setValue("optWindow/geometry", v); }