Add dependencies locally
This commit is contained in:
6
deps/WinToast/examples/qt-gui-example/CMakeLists.txt
vendored
Normal file
6
deps/WinToast/examples/qt-gui-example/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
find_package(Qt6 REQUIRED COMPONENTS Widgets)
|
||||
qt_standard_project_setup()
|
||||
|
||||
add_executable(WinToastGuiExample mainwindow.ui mainwindow.cpp main.cpp)
|
||||
target_link_libraries(WinToastGuiExample PRIVATE WinToast Qt6::Widgets)
|
||||
set_target_properties(WinToastGuiExample PROPERTIES WIN32_EXECUTABLE ON)
|
10
deps/WinToast/examples/qt-gui-example/main.cpp
vendored
Normal file
10
deps/WinToast/examples/qt-gui-example/main.cpp
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
116
deps/WinToast/examples/qt-gui-example/mainwindow.cpp
vendored
Normal file
116
deps/WinToast/examples/qt-gui-example/mainwindow.cpp
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QDebug>
|
||||
#include <qfiledialog.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
#include "wintoastlib.h"
|
||||
|
||||
using namespace WinToastLib;
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->toastType->addItem("ImageAndText01", WinToastTemplate::ImageAndText01);
|
||||
ui->toastType->addItem("ImageAndText02", WinToastTemplate::ImageAndText02);
|
||||
ui->toastType->addItem("ImageAndText03", WinToastTemplate::ImageAndText03);
|
||||
ui->toastType->addItem("ImageAndText04", WinToastTemplate::ImageAndText04);
|
||||
ui->toastType->addItem("Text01", WinToastTemplate::Text01);
|
||||
ui->toastType->addItem("Text02", WinToastTemplate::Text02);
|
||||
ui->toastType->addItem("Text03", WinToastTemplate::Text03);
|
||||
ui->toastType->addItem("Text04", WinToastTemplate::Text04);
|
||||
|
||||
ui->audioMode->addItem("Default", WinToastTemplate::AudioOption::Default);
|
||||
ui->audioMode->addItem("Loop", WinToastTemplate::AudioOption::Loop);
|
||||
ui->audioMode->addItem("Silence", WinToastTemplate::AudioOption::Silent);
|
||||
|
||||
ui->audioSystemFile->addItem("Default", WinToastTemplate::AudioSystemFile::DefaultSound);
|
||||
ui->audioSystemFile->addItem("Mail", WinToastTemplate::AudioSystemFile::Mail);
|
||||
ui->audioSystemFile->addItem("SMS", WinToastTemplate::AudioSystemFile::SMS);
|
||||
ui->audioSystemFile->addItem("Alarm", WinToastTemplate::AudioSystemFile::Alarm);
|
||||
|
||||
ui->cropHint->addItem("Square", WinToastTemplate::CropHint::Square);
|
||||
ui->cropHint->addItem("Circle", WinToastTemplate::CropHint::Circle);
|
||||
|
||||
WinToast::instance()->setAppName(L"WinToastExample");
|
||||
WinToast::instance()->setAppUserModelId(WinToast::configureAUMI(L"mohabouje", L"wintoast", L"wintoastexample", L"20161006"));
|
||||
if (!WinToast::instance()->initialize()) {
|
||||
qDebug() << "Error, your system in not compatible!";
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::on_imagePathSelector_clicked() {
|
||||
const QString fileName = QFileDialog::getOpenFileName(this, "Select an image", QDir::currentPath(), "*.png");
|
||||
if (fileName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ui->imagePath->setText(QDir::toNativeSeparators(fileName));
|
||||
}
|
||||
|
||||
void MainWindow::on_heroPathSelector_clicked() {
|
||||
const QString fileName = QFileDialog::getOpenFileName(this, "Select an image", QDir::currentPath(), "*.png");
|
||||
if (fileName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ui->heroPath->setText(QDir::toNativeSeparators(fileName));
|
||||
}
|
||||
|
||||
class CustomHandler : public IWinToastHandler {
|
||||
public:
|
||||
void toastActivated() const {
|
||||
std::wcout << L"The user clicked in this toast" << std::endl;
|
||||
}
|
||||
|
||||
void toastActivated(int actionIndex) const {
|
||||
std::wcout << L"The user clicked on button #" << actionIndex << L" in this toast" << std::endl;
|
||||
}
|
||||
|
||||
void toastFailed() const {
|
||||
std::wcout << L"Error showing current toast" << std::endl;
|
||||
}
|
||||
void toastDismissed(WinToastDismissalReason state) const {
|
||||
switch (state) {
|
||||
case UserCanceled:
|
||||
std::wcout << L"The user dismissed this toast" << std::endl;
|
||||
break;
|
||||
case ApplicationHidden:
|
||||
std::wcout << L"The application hid the toast using ToastNotifier.hide()" << std::endl;
|
||||
break;
|
||||
case TimedOut:
|
||||
std::wcout << L"The toast has timed out" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::wcout << L"Toast not activated" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void MainWindow::on_showToast_clicked() {
|
||||
auto const type = static_cast<WinToastTemplate::WinToastTemplateType>(ui->toastType->currentData().toInt());
|
||||
WinToastTemplate templ = WinToastTemplate(type);
|
||||
templ.setImagePath(ui->imagePath->text().toStdWString(), static_cast<WinToastTemplate::CropHint>(ui->cropHint->currentData().toInt()));
|
||||
templ.setHeroImagePath(ui->heroPath->text().toStdWString(), ui->inlineHeroImage->isChecked());
|
||||
templ.setTextField(ui->firstLine->text().toStdWString(), WinToastTemplate::FirstLine);
|
||||
templ.setTextField(ui->secondLine->text().toStdWString(), WinToastTemplate::SecondLine);
|
||||
templ.setTextField(ui->thirdLine->text().toStdWString(), WinToastTemplate::ThirdLine);
|
||||
templ.setExpiration(ui->spinBox->value() * 1000);
|
||||
templ.setAudioPath(static_cast<WinToastTemplate::AudioSystemFile>(ui->audioSystemFile->currentData().toInt()));
|
||||
templ.setAudioOption(static_cast<WinToastTemplate::AudioOption>(ui->audioMode->currentData().toInt()));
|
||||
|
||||
if (ui->addYes->isChecked()) {
|
||||
templ.addAction(L"Yes");
|
||||
}
|
||||
|
||||
if (ui->addNo->isChecked()) {
|
||||
templ.addAction(L"No");
|
||||
}
|
||||
|
||||
if (WinToast::instance()->showToast(templ, new CustomHandler()) < 0) {
|
||||
QMessageBox::warning(this, "Error", "Could not launch your toast notification!");
|
||||
}
|
||||
}
|
26
deps/WinToast/examples/qt-gui-example/mainwindow.h
vendored
Normal file
26
deps/WinToast/examples/qt-gui-example/mainwindow.h
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget* parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_imagePathSelector_clicked();
|
||||
void on_showToast_clicked();
|
||||
void on_heroPathSelector_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
252
deps/WinToast/examples/qt-gui-example/mainwindow.ui
vendored
Normal file
252
deps/WinToast/examples/qt-gui-example/mainwindow.ui
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>670</width>
|
||||
<height>353</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>WinToast Example</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="11" column="0">
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Toast Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>First Line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Hero Path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLineEdit" name="thirdLine"/>
|
||||
</item>
|
||||
<item row="9" column="2">
|
||||
<widget class="QComboBox" name="audioMode"/>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="imagePath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="imagePathSelector">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Audio Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QCheckBox" name="addNo">
|
||||
<property name="text">
|
||||
<string>Add No Action</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Expiration time (secs)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="2">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="showToast">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Toast</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<widget class="QComboBox" name="audioSystemFile"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Second Line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLineEdit" name="secondLine"/>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QCheckBox" name="addYes">
|
||||
<property name="text">
|
||||
<string>Add Yes Action</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Audio System File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="firstLine"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Image Path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QComboBox" name="cropHint"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Third Line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="toastType"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Crop Hint</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="heroPath">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="heroPathSelector">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QCheckBox" name="inlineHeroImage">
|
||||
<property name="text">
|
||||
<string>Inline Hero Image</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Reference in New Issue
Block a user