diff options
-rwxr-xr-x | snap_launcher/bin/whatsie | bin | 1522576 -> 1531840 bytes | |||
-rw-r--r-- | src/mainwindow.cpp | 73 | ||||
-rw-r--r-- | src/settingswidget.cpp | 11 | ||||
-rw-r--r-- | src/settingswidget.h | 5 | ||||
-rw-r--r-- | src/settingswidget.ui | 254 |
5 files changed, 219 insertions, 124 deletions
diff --git a/snap_launcher/bin/whatsie b/snap_launcher/bin/whatsie Binary files differindex 3e23a7f..266d216 100755 --- a/snap_launcher/bin/whatsie +++ b/snap_launcher/bin/whatsie 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 <QRegularExpression> #include <QStyleHints> - - +#include <QWebEngineNotification> 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: <i>" +QByteArray::fromBase64(settings.value("asdfg").toString().toUtf8())+"</i>"); @@ -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 @@ <rect> <x>0</x> <y>0</y> - <width>527</width> - <height>590</height> + <width>533</width> + <height>628</height> </rect> </property> <property name="windowTitle"> @@ -104,7 +104,7 @@ background:transparent; <string>General settings</string> </property> <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> + <item row="1" column="0"> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="1"> <widget class="Line" name="line_3"> @@ -175,53 +175,31 @@ background:transparent; </item> </layout> </item> - <item row="1" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <item> - <widget class="QCheckBox" name="enableSpellCheck"> - <property name="text"> - <string>Enable Spell Checker</string> - </property> - </widget> - </item> + <item row="4" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <property name="topMargin"> + <number>0</number> + </property> <item> - <widget class="Line" name="line"> - <property name="minimumSize"> - <size> - <width>1</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>1</width> - <height>16777215</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true">background-color: rgba(63, 129, 216, 48);</string> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> + <widget class="QCheckBox" name="applock_checkbox"> + <property name="toolTip"> + <string><html><head/><body><p>Enable application lock screen.</p></body></html></string> </property> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <property name="text"> + <string>Enable App Lock on Start</string> </property> </widget> </item> <item> - <widget class="QLabel" name="label_8"> + <widget class="QLabel" name="current_password"> <property name="text"> - <string>SpellChecker Language</string> + <string>Current Password:</string> </property> </widget> </item> - <item> - <widget class="QComboBox" name="dictComboBox"/> - </item> </layout> </item> - <item row="4" column="0"> + <item row="5" column="0"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QLabel" name="label"> @@ -247,52 +225,102 @@ background:transparent; </layout> </item> <item row="3" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <property name="topMargin"> - <number>0</number> + <widget class="Line" name="line_2"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>1</height> + </size> </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>1</height> + </size> + </property> + <property name="styleSheet"> + <string notr="true">background-color: rgba(63, 129, 216, 48);</string> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="8" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <widget class="QCheckBox" name="applock_checkbox"> - <property name="toolTip"> - <string><html><head/><body><p>Enable application lock screen.</p></body></html></string> - </property> + <widget class="QLabel" name="label_2"> <property name="text"> - <string>Enable App Lock on Start</string> + <string>Theme</string> </property> </widget> </item> <item> - <widget class="QLabel" name="current_password"> - <property name="text"> - <string>Current Password:</string> - </property> + <widget class="QComboBox" name="themeComboBox"> + <item> + <property name="text"> + <string>Dark</string> + </property> + </item> + <item> + <property name="text"> + <string>Light</string> + </property> + </item> </widget> </item> </layout> </item> - <item row="5" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_5"> <item> - <widget class="QLabel" name="label_9"> + <widget class="QCheckBox" name="enableSpellCheck"> <property name="text"> - <string>Global App shortcuts</string> + <string>Enable Spell Checker</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="showShortcutsButton"> - <property name="text"> - <string>Show shortcuts</string> + <widget class="Line" name="line"> + <property name="minimumSize"> + <size> + <width>1</width> + <height>0</height> + </size> </property> - <property name="icon"> - <iconset resource="icons.qrc"> - <normaloff>:/icons/eye-line.png</normaloff>:/icons/eye-line.png</iconset> + <property name="maximumSize"> + <size> + <width>1</width> + <height>16777215</height> + </size> + </property> + <property name="styleSheet"> + <string notr="true">background-color: rgba(63, 129, 216, 48);</string> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>SpellChecker Language</string> </property> </widget> </item> + <item> + <widget class="QComboBox" name="dictComboBox"/> + </item> </layout> </item> - <item row="8" column="0"> + <item row="9" column="0"> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> <widget class="QLabel" name="label_4"> @@ -329,71 +357,43 @@ background:transparent; </layout> </item> <item row="7" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <property name="topMargin"> + <number>0</number> + </property> <item> - <widget class="QLabel" name="label_2"> + <widget class="QLabel" name="label_10"> <property name="text"> - <string>Theme</string> + <string>App permissions</string> </property> </widget> </item> <item> - <widget class="QComboBox" name="themeComboBox"> - <item> - <property name="text"> - <string>Dark</string> - </property> - </item> - <item> - <property name="text"> - <string>Light</string> - </property> - </item> + <widget class="QPushButton" name="showPermissionsButton"> + <property name="text"> + <string>Show permissions</string> + </property> + <property name="icon"> + <iconset resource="icons.qrc"> + <normaloff>:/icons/eye-line.png</normaloff>:/icons/eye-line.png</iconset> + </property> </widget> </item> </layout> </item> - <item row="2" column="0"> - <widget class="Line" name="line_2"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>1</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>1</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true">background-color: rgba(63, 129, 216, 48);</string> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> <item row="6" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <property name="topMargin"> - <number>0</number> - </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> <item> - <widget class="QLabel" name="label_10"> + <widget class="QLabel" name="label_9"> <property name="text"> - <string>App permissions</string> + <string>Global App shortcuts</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="showPermissionsButton"> + <widget class="QPushButton" name="showShortcutsButton"> <property name="text"> - <string>Show permissions</string> + <string>Show shortcuts</string> </property> <property name="icon"> <iconset resource="icons.qrc"> @@ -403,6 +403,44 @@ background:transparent; </item> </layout> </item> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <item> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string>Notification type</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="notificationCombo"> + <item> + <property name="text"> + <string>Native notification</string> + </property> + </item> + <item> + <property name="text"> + <string>Customized notification</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QPushButton" name="tryNotification"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Try</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item> |