From bd0e6cb3c7e8f827e07cca4f3bd3c8bd05c75dbb Mon Sep 17 00:00:00 2001 From: keshavbhatt Date: Sun, 18 Apr 2021 13:16:28 +0530 Subject: added option to change notification type. - added ability to switch b/w native notification and customized notifications --- snap_launcher/bin/whatsie | Bin 1522576 -> 1531840 bytes src/mainwindow.cpp | 73 ++++++++++--- src/settingswidget.cpp | 11 ++ src/settingswidget.h | 5 + src/settingswidget.ui | 254 ++++++++++++++++++++++++++-------------------- 5 files changed, 219 insertions(+), 124 deletions(-) diff --git a/snap_launcher/bin/whatsie b/snap_launcher/bin/whatsie index 3e23a7f..266d216 100755 Binary files a/snap_launcher/bin/whatsie and b/snap_launcher/bin/whatsie differ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3dfe4e6..fb9ccce 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2,8 +2,7 @@ #include #include - - +#include extern QString defaultUserAgentStr; @@ -192,6 +191,11 @@ void MainWindow::init_settingWidget() setNotificationPresenter(this->webEngine->page()->profile()); }); + connect(settingsWidget,&SettingsWidget::notify,[=](QString message) + { + notify("",message); + }); + settingsWidget->appLockSetChecked(settings.value("lockscreen",false).toBool()); //spell checker @@ -203,6 +207,9 @@ void MainWindow::init_settingWidget() void MainWindow::lockApp() { + if(lockWidget->isLocked) + return; + if(settings.value("asdfg").isValid() && settings.value("lockscreen").toBool()==false){ QMessageBox::critical(this,QApplication::applicationName()+"| Error", "Unable to lock App, Enable AppLock in settings First."); @@ -295,21 +302,39 @@ void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::notify(QString title,QString message) { + if(settings.value("disableNotificationPopups",false).toBool() == true){ return; } - auto popup = new NotificationPopup(webEngine); - connect(popup,&NotificationPopup::notification_clicked,[=](){ - if(windowState()==Qt::WindowMinimized || windowState()!=Qt::WindowActive){ - activateWindow(); - raise(); - showNormal(); - } - }); - popup->style()->polish(qApp); - popup->setMinimumWidth(300); - popup->adjustSize(); - popup->present(title,message,QPixmap(":/icons/app/icon-64.png")); + + if(title.isEmpty()) title = QApplication::applicationName(); + + if(settings.value("notificationCombo",1).toInt() == 0 && trayIcon != nullptr) + { + trayIcon->showMessage(title,message,QIcon(":/icons/app/icon-64.png"),100); + trayIcon->disconnect(trayIcon,SIGNAL(messageClicked())); + connect(trayIcon,&QSystemTrayIcon::messageClicked,[=](){ + if(windowState()==Qt::WindowMinimized || windowState()!=Qt::WindowActive){ + activateWindow(); + raise(); + showNormal(); + } + }); + } + else{ + auto popup = new NotificationPopup(webEngine); + connect(popup,&NotificationPopup::notification_clicked,[=](){ + if(windowState()==Qt::WindowMinimized || windowState()!=Qt::WindowActive){ + activateWindow(); + raise(); + showNormal(); + } + }); + popup->style()->polish(qApp); + popup->setMinimumWidth(300); + popup->adjustSize(); + popup->present(title,message,QPixmap(":/icons/app/icon-64.png")); + } } void MainWindow::createActions() @@ -585,8 +610,24 @@ void MainWindow::setNotificationPresenter(QWebEngineProfile* profile) if(settings.value("disableNotificationPopups",false).toBool() == true){ return; } - popup->setMinimumWidth(300); - popup->present(notification); + if(settings.value("notificationCombo",1).toInt() == 0 && trayIcon != nullptr) + { + QIcon icon(QPixmap::fromImage(notification->icon())); + trayIcon->showMessage(notification->title(),notification->message(),icon,100); + trayIcon->disconnect(trayIcon,SIGNAL(messageClicked())); + connect(trayIcon,&QSystemTrayIcon::messageClicked,[=](){ + if(windowState()==Qt::WindowMinimized || windowState()!=Qt::WindowActive){ + activateWindow(); + raise(); + showNormal(); + } + }); + + }else{ + popup->setMinimumWidth(300); + popup->present(notification); + } + }); } diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp index 2b23845..dc8cda3 100644 --- a/src/settingswidget.cpp +++ b/src/settingswidget.cpp @@ -23,6 +23,7 @@ SettingsWidget::SettingsWidget(QWidget *parent, QString engineCachePath, QString ui->userAgentLineEdit->setText(settings.value("useragent",defaultUserAgentStr).toString()); ui->enableSpellCheck->setChecked(settings.value("sc_enabled",true).toBool()); ui->notificationTimeOutspinBox->setValue(settings.value("notificationTimeOut",9000).toInt()/1000); + ui->notificationCombo->setCurrentIndex(settings.value("notificationCombo",1).toInt()); this->setCurrentPasswordText("Current Password: " +QByteArray::fromBase64(settings.value("asdfg").toString().toUtf8())+""); @@ -306,3 +307,13 @@ void SettingsWidget::on_notificationTimeOutspinBox_valueChanged(int arg1) settings.setValue("notificationTimeOut",arg1*1000); emit notificationPopupTimeOutChanged(); } + +void SettingsWidget::on_notificationCombo_currentIndexChanged(int index) +{ + settings.setValue("notificationCombo",index); +} + +void SettingsWidget::on_tryNotification_clicked() +{ + emit notify("Test Notification"); +} diff --git a/src/settingswidget.h b/src/settingswidget.h index ff33b04..b952d2d 100644 --- a/src/settingswidget.h +++ b/src/settingswidget.h @@ -27,6 +27,7 @@ signals: void dictChanged(QString dict); void spellCheckChanged(bool checked); void notificationPopupTimeOutChanged(); + void notify(QString message); public: explicit SettingsWidget(QWidget *parent = nullptr,QString engineCachePath = "", @@ -77,6 +78,10 @@ private slots: void on_notificationTimeOutspinBox_valueChanged(int arg1); + void on_notificationCombo_currentIndexChanged(int index); + + void on_tryNotification_clicked(); + private: Ui::SettingsWidget *ui; QString engineCachePath,enginePersistentStoragePath; diff --git a/src/settingswidget.ui b/src/settingswidget.ui index e5fcea3..9aeedb8 100644 --- a/src/settingswidget.ui +++ b/src/settingswidget.ui @@ -6,8 +6,8 @@ 0 0 - 527 - 590 + 533 + 628 @@ -104,7 +104,7 @@ background:transparent; General settings - + @@ -175,53 +175,31 @@ background:transparent; - - - - - - Enable Spell Checker - - - + + + + 0 + - - - - 1 - 0 - - - - - 1 - 16777215 - - - - background-color: rgba(63, 129, 216, 48); - - - QFrame::Raised + + + <html><head/><body><p>Enable application lock screen.</p></body></html> - - Qt::Vertical + + Enable App Lock on Start - + - SpellChecker Language + Current Password: - - - - + @@ -247,52 +225,102 @@ background:transparent; - - - 0 + + + + 0 + 1 + + + + 16777215 + 1 + + + + background-color: rgba(63, 129, 216, 48); + + + QFrame::Raised + + + Qt::Horizontal + + + + + - - - <html><head/><body><p>Enable application lock screen.</p></body></html> - + - Enable App Lock on Start + Theme - - - Current Password: - + + + + Dark + + + + + Light + + - - + + - + - Global App shortcuts + Enable Spell Checker - - - Show shortcuts + + + + 1 + 0 + - - - :/icons/eye-line.png:/icons/eye-line.png + + + 1 + 16777215 + + + + background-color: rgba(63, 129, 216, 48); + + + QFrame::Raised + + + Qt::Vertical + + + + + + + SpellChecker Language + + + - + @@ -329,71 +357,43 @@ background:transparent; - + + + 0 + - + - Theme + App permissions - - - - Dark - - - - - Light - - + + + Show permissions + + + + :/icons/eye-line.png:/icons/eye-line.png + - - - - - 0 - 1 - - - - - 16777215 - 1 - - - - background-color: rgba(63, 129, 216, 48); - - - QFrame::Raised - - - Qt::Horizontal - - - - - - 0 - + - + - App permissions + Global App shortcuts - + - Show permissions + Show shortcuts @@ -403,6 +403,44 @@ background:transparent; + + + + + + Notification type + + + + + + + + Native notification + + + + + Customized notification + + + + + + + + + 0 + 0 + + + + Try + + + + + -- cgit v1.2.3