Add dependencies locally

This commit is contained in:
Ahrimdon
2024-02-27 03:09:30 -05:00
parent 1679ef60cc
commit 70e8a8502b
5698 changed files with 2770161 additions and 12 deletions

1
deps/WinToast vendored

Submodule deps/WinToast deleted from 821c4818ad

240
deps/WinToast/.clang-format vendored Normal file
View File

@ -0,0 +1,240 @@
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Left
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlinesLeft: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
- __cold
- __hot
- __noinline
- __naked
- __noreturn
- __packed
- __pure
- __section
- __unused
- __used
BasedOnStyle: InheritParentConfig
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeConceptDeclarations: Always
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 140
CommentPragmas: ''
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: False
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- Q_FOREACH
- foreach
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 2
CaseSensitive: True
- Regex: '^((<|")(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 2
CaseSensitive: True
- Regex: '<[[:alnum:].]+>'
Priority: 4
SortPriority: 4
CaseSensitive: True
- Regex: '.*'
Priority: 1
SortPriority: 1
CaseSensitive: True
IncludeIsMainRegex: '(_test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertBraces: true
InsertTrailingCommas: None
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
NamespaceMacros:
PPIndentWidth: 4
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
QualifierAlignment: Custom
QualifierOrder: ['inline', 'constexpr', 'static', 'type', 'const', 'volatile']
RawStringFormats:
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: JavaScript
Delimiters:
- 'json'
- 'js'
EnclosingFunctions:
- 'json'
BasedOnStyle: google
ReferenceAlignment: Left
ReflowComments: false
RemoveBracesLLVM: false
RequiresClausePosition: OwnLine
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: Never
SortUsingDeclarations: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: true
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
TypenameMacros:
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME

5
deps/WinToast/.editorconfig vendored Normal file
View File

@ -0,0 +1,5 @@
[*.{cpp,h}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
charset = utf-8

63
deps/WinToast/.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

2
deps/WinToast/.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,2 @@
patreon: mohabouje
custom: https://paypal.me/mohabouje

View File

@ -0,0 +1,56 @@
name: Build with CMake
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
BUILD_TYPE: Release
QT_VERSION: 6.6.0
jobs:
build:
strategy:
matrix:
include:
# With Qt examples
- with-qt: true
with-examples: true
# Examples without Qt
- with-qt: false
with-examples: true
# No examples
- with-qt: false
with-examples: false
name: 'Examples: ${{ matrix.with-examples }}, Qt: ${{ matrix.with-qt }}'
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.12.1
- name: Install Qt
if: matrix.with-qt
uses: jurplel/install-qt-action@v3.3.0
with:
cache: true
cache-key-prefix: QtCache-${{ env.QT_VERSION }}
version: ${{ env.QT_VERSION }}
- name: Configure CMake
run: >
cmake
-B build
-G Ninja
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
-DWINTOASTLIB_BUILD_EXAMPLES=${{ matrix.with-examples && 'On' || 'Off' }}
-DWINTOASTLIB_QT_ENABLED=${{ matrix.with-qt && 'On' || 'Off' }}
- name: Build
working-directory: build
run: ninja all

44
deps/WinToast/.gitignore vendored Normal file
View File

@ -0,0 +1,44 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
*.ipch
*.exp
*.opensdf
# Visual Studio
*.VC.db
*.VC.VC.opendb
.vs/
Debug/
Release/
enc_temp_folder/
/example/qt-gui-example/build-WinToastExample-Desktop_Qt_5_9_2_MSVC2015_32bit-Debug
build/
cmake-build-*
CMakeLists.txt.user

19
deps/WinToast/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.4...3.27)
project(wintoastlib VERSION 1.3.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(WINTOASTLIB_BUILD_EXAMPLES "Compile the examples" ON)
option(WINTOASTLIB_QT_ENABLED "Enable Qt support to build the GUI examples" OFF)
set(WINTOASTLIB_LIBNAME WinToast)
set(WINTOASTLIB_HEADERS ${CMAKE_CURRENT_LIST_DIR}/include/wintoastlib.h)
set(WINTOASTLIB_SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/wintoastlib.cpp)
add_library(${WINTOASTLIB_LIBNAME} STATIC ${WINTOASTLIB_HEADERS} ${WINTOASTLIB_SOURCES})
target_include_directories(${WINTOASTLIB_LIBNAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(${WINTOASTLIB_LIBNAME} psapi)
if (${WINTOASTLIB_BUILD_EXAMPLES})
add_subdirectory(examples)
endif()

21
deps/WinToast/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (C) 2016-2023 WinToast v1.3.0 - Mohammed Boujemaoui <mohabouje@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

319
deps/WinToast/README.md vendored Normal file
View File

@ -0,0 +1,319 @@
![license](https://img.shields.io/github/license/mohabouje/WinToast?style=flat-square)
![GitHub contributors](https://img.shields.io/github/contributors/mohabouje/WinToast?style=flat-square)
![releases](https://img.shields.io/github/v/release/mohabouje/WinToast?style=flat-square)
[![GitHub stars](https://img.shields.io/github/stars/mohabouje/WinToast?style=flat-square)]()
[![GitHub forks](https://img.shields.io/github/forks/mohabouje/WinToast?style=flat-square)]()
[![GitHub watchers](https://img.shields.io/github/watchers/mohabouje/WinToast?style=flat-square)]()
![issues](https://img.shields.io/github/issues/mohabouje/WinToast?style=flat-square)
WinToast
===================
WinToast is a lightly library written in C++ which brings a complete integration of the modern **toast notifications** of **Windows 8**, **Windows 10** and **Windows 11**.
Toast notifications allows your app to inform the users about relevant information and timely events that they should see and take action upon inside your app, such as a new instant message, a new friend request, breaking news, or a calendar event.
- [WinToast](#wintoast)
- [Toast Templates](#toast-templates)
- [Event Handler](#event-handler)
- [Notification Content](#notification-content)
- [Error Handling](#error-handling)
- [Example of Usage](#example-of-usage)
- [Installation](#installation)
- [Toast configuration on Windows 10](#toast-configuration-on-windows-10)
- [Projects using WinToast](#projects-using-wintoast)
## Toast Templates
WinToast integrates all standard templates available in the [ToastTemplateType enumeration](https://msdn.microsoft.com/en-us/library/windows/apps/br208660.aspx).
| Template | Description | Example |
| :------- | ----: | :---: |
| `ImageAndText01` | A large image and a single string wrapped across three lines of text. | ![enter image description here](assets/images/Toast_6.png) |
| `ImageAndText02` | A large image, one string of bold text on the first line, one string of regular text wrapped across the second and third lines. | ![12](assets/images/Toast_7.png) |
| `ImageAndText03` | A large image, one string of bold text wrapped across the first two lines, one string of regular text on the third line. | ![enter image description here](assets/images/Toast_8.png) |
| `ImageAndText04` | A large image, one string of bold text on the first line, one string of regular text on the second line, one string of regular text on the third line. | ![enter image description here](assets/images/ToastImageAndText04.png) |
| `Text01` | Single string wrapped across three lines of text. | ![enter image description here](assets/images/Toast_1.png)|
| `Text02` | One string of bold text on the first line, one string of regular text wrapped across the second and third lines. | ![enter image description here](assets/images/Toast_2.png) |
| `Text03` | One string of bold text wrapped across the first two lines, one string of regular text on the third line. | ![enter image description here](assets/images/Toast_4.png)|
| `Text04` | One string of bold text on the first line, one string of regular text on the second line, one string of regular text on the third line. | ![enter image description here](assets/images/Toast_5.png) |
Example of a `ImageAndText02` template:
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
templ.setTextField(L"title", WinToastTemplate::FirstLine);
templ.setTextField(L"subtitle", WinToastTemplate::SecondLine);
templ.setImagePath(L"C:/example.png");
```
**Note:** The user can use the default system sound or specify a sound to play when a toast notification is displayed. Same behavior for the toast notification image, by default Windows try to use the app icon.*
## Event Handler
WinToast handle different events:
- **Activated**: Occurs when user activates a toast notification through a click or touch. Apps that are running subscribe to this event
- **Dismissed**: Occurs when a toast notification leaves the screen, either by expiring or being explicitly dismissed by the user.
* Application Hidden: The application hid the toast using ToastNotifier.hide.
* User Canceled: The user dismissed the toast.
* Timed Out: The toast has expired
- **Failed**: Occurs when an error is caused when Windows attempts to raise a toast notification.
Create your custom handler to interact with the user actions by subclassing the interface `IWinToastHandler`:
```cpp
class WinToastHandlerExample : public IWinToastHandler {
public:
WinToastHandlerExample();
// Public interfaces
void toastActivated() const override;
void toastDismissed(WinToastDismissalReason state) const override;
void toastFailed() const override;
};
```
## Notification Content
The full documentation of the notification content [here](https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=appsdk).
### Scenario
To create important notifications, alarms, reminders, and incoming call notifications, you simply use a normal app notification with a Scenario value assigned to it. The scenario adjusts a few behaviors to create a consistent and unified user experience. There are four possible Scenario values:
- Reminder
- Alarm
- IncomingCall
- Urgent
### Expiration Time
Set the time after which a toast notification is no longer considered current or valid and should not be displayed. Windows attempts to raise toast notifications immediately after you call Show, so this property is rarely used.
> For Windows 8.x app, this property also causes the toast notification to be removed from the
> Action Center once the specified data and time is reached.
**Note:** Default Windows behavior is to hide notification automatically after time set in Windows Ease of Access Settings.
If you need to preserve notification in Windows Action Center for longer period of time, you have to call `WinToastTemplate::setExpiration` method.
### Hint Crop
Microsoft style guidelines recommend representing profile pictures with a circular image to provide a consistent representation of people across apps and the shell. Set the HintCrop property to Circle to render the image with a circular crop.
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
templ.setTextField(L"Matt sent you a friend request", WinToastTemplate::FirstLine);
templ.setTextField(L"Hey, wanna dress up as wizards and ride around on hoverboards?", WinToastTemplate::SecondLine);
templ.setImagePath(L"C:/example.png");
templ.setHintCrop(WinToastTemplate::Circle);
```
!["Toast with hero image"](assets/images/hint-crop.png)
### Hero Image
The hero image is a large image that appears at the top of a toast notification. The hero image is optional and can be used to provide additional context to the user.
**Note:** The hero image is not supported on Windows 8.1 and Windows Phone 8.1.
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
templ.setTextField(L"Mary Anne", WinToastTemplate::FirstLine);
templ.setTextField(L"Check out where we camped last night!", WinToastTemplate::SecondLine);
templ.setHeroImagePath(L"C:/example.png");
```
!["Toast with hero image"](assets/images/hero-image.png)
The hero image is specified by calling the `WinToastTemplate::setHeroImagePath` method. The image path can be a local file path or a URI.
### Inline Image
The second parameter of the method `WinToastTemplate::setHeroImagePath` is a boolean value that specifies whether the image should be inlined in the toast notification.
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText01);
templ.setTextField(L"Feature image of the day", WinToastTemplate::FirstLine);
templ.setHeroImagePath(L"C:/example.png", true);
```
!["Toast with inlined hero image"](assets/images/inline-image.png)
### Actions
You can add your own actions, this fact allow you to interact with user in a different way:
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText01);
templ.setTextField(L"New product in stock", WinToastTemplate::FirstLine);
std::vector<std::wstring> actions;
actions.push_back(L"See more details");
actions.push_back(L"Remind me later");
// ...
for (auto const &action : actions) {
templ.addAction(action);
}
WinToast::instance()->showToast(templ, handler)
```
!["Toast with some actions"](assets/images/image-actions.png)
### Attribution text
New in Anniversary Update: If you need to reference the source of your content, you can use attribution text. This text is always displayed below any text elements, but above inline images. The text uses a slightly smaller size than standard text elements to help to distinguish from regular text elements.
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::Text02);
templ.setTextField(L"Mary Anne", WinToastTemplate::FirstLine);
templ.setTextField(L"Check out where we camped last night!", WinToastTemplate::SecondLine);
templ.setHeroImagePath(L"C:/example.png");
templ.setAttributionText(L"Via SMS");
```
!["Toast with some actions"](assets/images/attribution-text.png)
### Duration
The amount of time the toast should display. This attribute can have one of the following values:
- *System*: default system configuration.
- *Short*: default system short time configuration.
- *Long*: default system long time configuration.
### Audio Properties
You can modify the different behaviors of the sound:
- *Default*: plays the audio file just one time.
- *Silent*: turn off the sound.
- *Loop*: plays the given sound in a loop during the toast existence.
> WinToast allows the modification of the default audio file. Add
> the given file in to your projects resources (*must be ms-appx:// or
> ms-appdata:// path*) and define it by calling: `WinToastTemplate::setAudioPath`
***By default, WinToast checks if your systems support the features, ignoring the not supported ones.***
## Error Handling
There are several reasons WinToast can fail that's why the library notifies caller about fail reason. Those are the code for each failure:
| WinToastError | Error Code | Error message |
|--|--|--|
| `NoError` | 0x00 | No error. The process was executed correctly |
| `NotInitialized` | 0x01 | The library has not been initialized |
| `SystemNotSupported` | 0x02 | The OS does not support WinToast |
| `ShellLinkNotCreated` | 0x03 | The library was not able to create a Shell Link for the app |
| `InvalidAppUserModelID` | 0x04 | The AUMI is not a valid one |
| `InvalidParameters` | 0x05 | The parameters used to configure the library are not valid normally because an invalid AUMI or App Name |
| `NotDisplayed` | 0x06 | The toast was created correctly but WinToast was not able to display the toast |
| `UnknownError` | 0x07 | Unknown error |
A common example of usage is to check while initializing the library or showing a toast notification the possible failure code:
```cpp
WinToast::WinToastError error;
const auto succedded = WinToast::instance()->initialize(&error);
if (!succedded) {
std::wcout << L"Error, could not initialize the lib. Error number: "
<< error << std::endl;
}
...
// Configure the template
...
const auto toast_id = WinToast::instance()->showToast(templ, handler, &error);
if (toast_id < 0) {
std::wcout << L"Error: Could not launch your toast notification. Error: "
<< error << std::endl;
}
```
## Example of Usage
*For an easy usage, you can just use the available singleton instance.*
First step, Import the header file wintoastlib.h to your project. You should check if your Windows Version is supported by the library.
```cpp
using namespace WinToastLib;
....
if (!WinToast::isCompatible()) {
std::wcout << L"Error, your system in not supported!" << std::endl;
}
```
Configure your [App User Model Id](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459%28v=vs.85%29.aspx), this can be done by using the existing helper:
```cpp
WinToast::instance()->setAppName(L"WinToastExample");
const auto aumi = WinToast::configureAUMI(L"mohabouje", L"wintoast", L"wintoastexample", L"20161006");
WinToast::instance()->setAppUserModelId(aumi);
```
Initialize all the dependencies and check if WinToast has been initialized successfully in your system:
```cpp
if (!WinToast::instance()->initialize()) {
std::wcout << L"Error, could not initialize the lib!" << std::endl;
}
```
Implement your own action handler by subclassing the interface `IWinToastHandler` and custom your template:
```cpp
WinToastHandlerExample* handler = new WinToastHandlerExample;
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
templ.setImagePath(L"C:/example.png");
templ.setTextField(L"title", WinToastTemplate::FirstLine);
templ.setTextField(L"subtitle", WinToastTemplate::SecondLine);
```
Finally show the results:
```cpp
const auto toast_id = WinToast::instance()->showToast(templ, handler, &error);
if (toast_id < 0) {
std::wcout << L"Error: Could not launch your toast notification!" << std::endl;
}
```
Shao Voon Wong wrote an excellent article about the usage of WinToast. You can find it [here](https://www.codeproject.com/Articles/5286393/Cplusplus-Windows-Toast-Notification).
## Installation
If you are using a package manager, there is a port for [vcpkg](https://github.com/microsoft/vcpkg/). Otherwise, the easiest way is to copy the source files as external dependencies.
## Toast configuration on Windows 10
Windows allows the configuration of the default behavior of a toast notification. This can be done in the *Ease of Access* configuration by modifying the *Other options* tab.
The system configuration helps you to define how long you want notifications to appear for (5 seconds to 5 minutes) as turning on visual notifications for sound.
![Ease of Access configuration](https://camo.githubusercontent.com/56c8edd1a7a4a43be07ba211d9d828478fdbad39/68747470733a2f2f7777772e686f77746f6765656b2e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031362f30332f656173655f6f665f6163636573732e706e67)
## Projects using WinToast
- [Git for Windows](https://github.com/git-for-windows/git): A fork of Git containing Windows-specific patches.
- [Firefox](https://hg.mozilla.org/mozilla-central/file/tip/third_party/WinToast/wintoastlib.cpp): A free and open source web browser.
- [Waterfox](https://github.com/WaterfoxCo/Waterfox): Fast and Private Web Browser
- [QGIS](https://github.com/qgis/QGIS): QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
- [Synergy Core](https://github.com/symless/synergy-core): Share one mouse and keyboard between multiple computers
- [Siv3D](https://github.com/Siv3D/OpenSiv3D): A C++20 cross-platform library for creative coding
- [MEGAsync](https://github.com/meganz/MEGAsync): Easy automated syncing between your computers and your MEGA Cloud Drive
- [chatterino2](https://github.com/Chatterino/chatterino2): Chat client for twitch.tv
- [nheko](https://github.com/Nheko-Reborn/nheko): Desktop client for the Matrix protocol.
- [EDPathFinder](https://github.com/neotron/EDPathFinder): A program that creates an optimal route that passes through two or more systems in Elite.
- [IW6X-Client](https://github.com/XLabsProject/iw6x-client): IW6x is a free, open-source, community-driven project aiming to recreate the multiplayer experience of Call of Duty: Modern Warfare 3.
- [H1-Mod](https://github.com/h1-mod/h1-mod): A client for Call of Duty: Modern Warfare Remastered.
- [AntiExploit](https://github.com/Empier/Anti-Exploit): antiexploit utility for Windows.
- [Zroya](https://github.com/malja/zroya): Python extension for creating native Windows notifications..
- [PidginWinToastNotifications](https://github.com/ChristianGalla/PidginWinToastNotifications): Windows Toast Notification Plugin for Pidgin.
- [Dnai-Editor](https://github.com/Nicolas-Constanty/Dnai.Editor): Visual Scripting, node editor.
- [Spectral](https://gitlab.com/b0/spectral): A glossy client for Matrix, written in QtQuick Controls 2 and C++.

1
deps/WinToast/_config.yml vendored Normal file
View File

@ -0,0 +1 @@
theme: jekyll-theme-architect

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
deps/WinToast/assets/images/Toast_1.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
deps/WinToast/assets/images/Toast_2.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
deps/WinToast/assets/images/Toast_4.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
deps/WinToast/assets/images/Toast_5.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
deps/WinToast/assets/images/Toast_6.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
deps/WinToast/assets/images/Toast_7.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
deps/WinToast/assets/images/Toast_8.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

1
deps/WinToast/docs/_config.yml vendored Normal file
View File

@ -0,0 +1 @@
theme: jekyll-theme-leap-day

299
deps/WinToast/docs/index.md vendored Normal file
View File

@ -0,0 +1,299 @@
WinToast
===================
WinToast is a lightly library written in C++ which brings a complete integration of the modern **toast notifications** of **Windows 8**, **Windows 10** and **Windows 11**.
Toast notifications allows your app to inform the users about relevant information and timely events that they should see and take action upon inside your app, such as a new instant message, a new friend request, breaking news, or a calendar event.
- [WinToast](#wintoast)
- [Toast Templates](#toast-templates)
- [Event Handler](#event-handler)
- [Notification Content](#notification-content)
- [Error Handling](#error-handling)
- [Example of Usage](#example-of-usage)
- [Installation](#installation)
- [Toast configuration on Windows 10](#toast-configuration-on-windows-10)
- [Projects using WinToast](#projects-using-wintoast)
## Toast Templates
WinToast integrates all standard templates available in the [ToastTemplateType enumeration](https://msdn.microsoft.com/en-us/library/windows/apps/br208660.aspx).
| Template | Description | Example |
| :------- | ----: | :---: |
| `ImageAndText01` | A large image and a single string wrapped across three lines of text. | ![enter image description here](assets/images/Toast_6.png) |
| `ImageAndText02` | A large image, one string of bold text on the first line, one string of regular text wrapped across the second and third lines. | ![12](assets/images/Toast_7.png) |
| `ImageAndText03` | A large image, one string of bold text wrapped across the first two lines, one string of regular text on the third line. | ![enter image description here](assets/images/Toast_8.png) |
| `ImageAndText04` | A large image, one string of bold text on the first line, one string of regular text on the second line, one string of regular text on the third line. | ![enter image description here](assets/images/ToastImageAndText04.png) |
| `Text01` | Single string wrapped across three lines of text. | ![enter image description here](assets/images/Toast_1.png)|
| `Text02` | One string of bold text on the first line, one string of regular text wrapped across the second and third lines. | ![enter image description here](assets/images/Toast_2.png) |
| `Text03` | One string of bold text wrapped across the first two lines, one string of regular text on the third line. | ![enter image description here](assets/images/Toast_4.png)|
| `Text04` | One string of bold text on the first line, one string of regular text on the second line, one string of regular text on the third line. | ![enter image description here](assets/images/Toast_5.png) |
Example of a `ImageAndText02` template:
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
templ.setTextField(L"title", WinToastTemplate::FirstLine);
templ.setTextField(L"subtitle", WinToastTemplate::SecondLine);
templ.setImagePath(L"C:/example.png");
```
**Note:** The user can use the default system sound or specify a sound to play when a toast notification is displayed. Same behavior for the toast notification image, by default Windows try to use the app icon.*
## Event Handler
WinToast handle different events:
- **Activated**: Occurs when user activates a toast notification through a click or touch. Apps that are running subscribe to this event
- **Dismissed**: Occurs when a toast notification leaves the screen, either by expiring or being explicitly dismissed by the user.
* Application Hidden: The application hid the toast using ToastNotifier.hide.
* User Canceled: The user dismissed the toast.
* Timed Out: The toast has expired
- **Failed**: Occurs when an error is caused when Windows attempts to raise a toast notification.
Create your custom handler to interact with the user actions by subclassing the interface `IWinToastHandler`:
```cpp
class WinToastHandlerExample : public IWinToastHandler {
public:
WinToastHandlerExample();
// Public interfaces
void toastActivated() const override;
void toastDismissed(WinToastDismissalReason state) const override;
void toastFailed() const override;
};
```
## Notification Content
The full documentation of the notification content [here](https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=appsdk).
### Expiration Time
Set the time after which a toast notification is no longer considered current or valid and should not be displayed. Windows attempts to raise toast notifications immediately after you call Show, so this property is rarely used.
> For Windows 8.x app, this property also causes the toast notification to be removed from the
> Action Center once the specified data and time is reached.
**Note:** Default Windows behavior is to hide notification automatically after time set in Windows Ease of Access Settings.
If you need to preserve notification in Windows Action Center for longer period of time, you have to call `WinToastTemplate::setExpiration` method.
### Hint Crop
Microsoft style guidelines recommend representing profile pictures with a circular image to provide a consistent representation of people across apps and the shell. Set the HintCrop property to Circle to render the image with a circular crop.
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
templ.setTextField(L"Matt sent you a friend request", WinToastTemplate::FirstLine);
templ.setTextField(L"Hey, wanna dress up as wizards and ride around on hoverboards?", WinToastTemplate::SecondLine);
templ.setImagePath(L"C:/example.png");
templ.setHintCrop(WinToastTemplate::Circle);
```
!["Toast with hero image"](assets/images/hint-crop.png)
### Hero Image
The hero image is a large image that appears at the top of a toast notification. The hero image is optional and can be used to provide additional context to the user.
**Note:** The hero image is not supported on Windows 8.1 and Windows Phone 8.1.
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
templ.setTextField(L"Mary Anne", WinToastTemplate::FirstLine);
templ.setTextField(L"Check out where we camped last night!", WinToastTemplate::SecondLine);
templ.setHeroImagePath(L"C:/example.png");
```
!["Toast with hero image"](assets/images/hero-image.png)
The hero image is specified by calling the `WinToastTemplate::setHeroImagePath` method. The image path can be a local file path or a URI.
### Inline Image
The second parameter of the method `WinToastTemplate::setHeroImagePath` is a boolean value that specifies whether the image should be inlined in the toast notification.
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText01);
templ.setTextField(L"Feature image of the day", WinToastTemplate::FirstLine);
templ.setHeroImagePath(L"C:/example.png", true);
```
!["Toast with inlined hero image"](assets/images/inline-image.png)
### Actions
You can add your own actions, this fact allow you to interact with user in a different way:
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText01);
templ.setTextField(L"New product in stock", WinToastTemplate::FirstLine);
std::vector<std::wstring> actions;
actions.push_back(L"See more details");
actions.push_back(L"Remind me later");
// ...
for (auto const &action : actions) {
templ.addAction(action);
}
WinToast::instance()->showToast(templ, handler)
```
!["Toast with some actions"](assets/images/image-actions.png)
### Attribution text
New in Anniversary Update: If you need to reference the source of your content, you can use attribution text. This text is always displayed below any text elements, but above inline images. The text uses a slightly smaller size than standard text elements to help to distinguish from regular text elements.
```cpp
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::Text02);
templ.setTextField(L"Mary Anne", WinToastTemplate::FirstLine);
templ.setTextField(L"Check out where we camped last night!", WinToastTemplate::SecondLine);
templ.setHeroImagePath(L"C:/example.png");
templ.setAttributionText(L"Via SMS");
```
!["Toast with some actions"](assets/images/attribution-text.png)
### Duration
The amount of time the toast should display. This attribute can have one of the following values:
- *System*: default system configuration.
- *Short*: default system short time configuration.
- *Long*: default system long time configuration.
### Audio Properties
You can modify the different behaviors of the sound:
- *Default*: plays the audio file just one time.
- *Silent*: turn off the sound.
- *Loop*: plays the given sound in a loop during the toast existence.
> WinToast allows the modification of the default audio file. Add
> the given file in to your projects resources (*must be ms-appx:// or
> ms-appdata:// path*) and define it by calling: `WinToastTemplate::setAudioPath`
***By default, WinToast checks if your systems support the features, ignoring the not supported ones.***
## Error Handling
There are several reasons WinToast can fail that's why the library notifies caller about fail reason. Those are the code for each failure:
| WinToastError | Error Code | Error message |
|--|--|--|
| `NoError` | 0x00 | No error. The process was executed correctly |
| `NotInitialized` | 0x01 | The library has not been initialized |
| `SystemNotSupported` | 0x02 | The OS does not support WinToast |
| `ShellLinkNotCreated` | 0x03 | The library was not able to create a Shell Link for the app |
| `InvalidAppUserModelID` | 0x04 | The AUMI is not a valid one |
| `InvalidParameters` | 0x05 | The parameters used to configure the library are not valid normally because an invalid AUMI or App Name |
| `NotDisplayed` | 0x06 | The toast was created correctly but WinToast was not able to display the toast |
| `UnknownError` | 0x07 | Unknown error |
A common example of usage is to check while initializing the library or showing a toast notification the possible failure code:
```cpp
WinToast::WinToastError error;
const bool succedded = WinToast::instance()->initialize(&error);
if (!succedded) {
std::wcout << L"Error, could not initialize the lib. Error number: "
<< error << std::endl;
}
...
// Configure the template
...
const bool launched = WinToast::instance()->showToast(templ, handler, &error);
if (!launched) {
std::wcout << L"Error: Could not launch your toast notification. Error: "
<< error << std::endl;
}
```
## Example of Usage
*For an easy usage, you can just use the available singleton instance.*
First step, Import the header file wintoastlib.h to your project. You should check if your Windows Version is supported by the library.
```cpp
using namespace WinToastLib;
....
if (!WinToast::isCompatible()) {
std::wcout << L"Error, your system in not supported!" << std::endl;
}
```
Configure your [App User Model Id](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459%28v=vs.85%29.aspx), this can be done by using the existing helper:
```cpp
WinToast::instance()->setAppName(L"WinToastExample");
const auto aumi = WinToast::configureAUMI(L"mohabouje", L"wintoast", L"wintoastexample", L"20161006");
WinToast::instance()->setAppUserModelId(aumi);
```
Initialize all the dependencies and check if WinToast has been initialized successfully in your system:
```cpp
if (!WinToast::instance()->initialize()) {
std::wcout << L"Error, could not initialize the lib!" << std::endl;
}
```
Implement your own action handler by subclassing the interface `IWinToastHandler` and custom your template:
```cpp
WinToastHandlerExample* handler = new WinToastHandlerExample;
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02);
templ.setImagePath(L"C:/example.png");
templ.setTextField(L"title", WinToastTemplate::FirstLine);
templ.setTextField(L"subtitle", WinToastTemplate::SecondLine);
```
Finally show the results:
```cpp
if (!WinToast::instance()->showToast(templ, handler)) {
std::wcout << L"Error: Could not launch your toast notification!" << std::endl;
}
```
Shao Voon Wong wrote an excellent article about the usage of WinToast. You can find it [here](https://www.codeproject.com/Articles/1151733/WinToast-Toast-Notification-Library-for-Windows-10).
## Installation
If you are using a package manager, there is a port for [vcpkg](https://github.com/microsoft/vcpkg/). Otherwise, the easiest way is to copy the source files as external dependencies.
## Toast configuration on Windows 10
Windows allows the configuration of the default behavior of a toast notification. This can be done in the *Ease of Access* configuration by modifying the *Other options* tab.
The system configuration helps you to define how long you want notifications to appear for (5 seconds to 5 minutes) as turning on visual notifications for sound.
![Ease of Access configuration](https://camo.githubusercontent.com/56c8edd1a7a4a43be07ba211d9d828478fdbad39/68747470733a2f2f7777772e686f77746f6765656b2e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031362f30332f656173655f6f665f6163636573732e706e67)
## Projects using WinToast
- [Git for Windows](https://github.com/git-for-windows/git): A fork of Git containing Windows-specific patches.
- [Firefox](https://hg.mozilla.org/mozilla-central/file/tip/third_party/WinToast/wintoastlib.cpp): A free and open source web browser.
- [QGIS](https://github.com/qgis/QGIS): QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
- [Synergy Core](https://github.com/symless/synergy-core): Share one mouse and keyboard between multiple computers
- [Siv3D](https://github.com/Siv3D/OpenSiv3D): A C++20 cross-platform library for creative coding
- [MEGAsync](https://github.com/meganz/MEGAsync): Easy automated syncing between your computers and your MEGA Cloud Drive
- [chatterino2](https://github.com/Chatterino/chatterino2): Chat client for twitch.tv
- [nheko](https://github.com/Nheko-Reborn/nheko): Desktop client for the Matrix protocol.
- [EDPathFinder](https://github.com/neotron/EDPathFinder): A program that creates an optimal route that passes through two or more systems in Elite.
- [IW6X-Client](https://github.com/XLabsProject/iw6x-client): IW6x is a free, open-source, community-driven project aiming to recreate the multiplayer experience of Call of Duty: Modern Warfare 3.
- [H1-Mod](https://github.com/h1-mod/h1-mod): A client for Call of Duty: Modern Warfare Remastered.
- [AntiExploit](https://github.com/Empier/Anti-Exploit): antiexploit utility for Windows.
- [Zroya](https://github.com/malja/zroya): Python extension for creating native Windows notifications..
- [PidginWinToastNotifications](https://github.com/ChristianGalla/PidginWinToastNotifications): Windows Toast Notification Plugin for Pidgin.
- [Dnai-Editor](https://github.com/Nicolas-Constanty/Dnai.Editor): Visual Scripting, node editor.
- [Spectral](https://gitlab.com/b0/spectral): A glossy client for Matrix, written in QtQuick Controls 2 and C++.

4
deps/WinToast/examples/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,4 @@
add_subdirectory(console-example)
if (${WINTOASTLIB_QT_ENABLED})
add_subdirectory(qt-gui-example)
endif()

View File

@ -0,0 +1,4 @@
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:wmainCRTStartup")
add_executable(WinToastTuiExample WIN32 main.cpp)
target_link_libraries(WinToastTuiExample PRIVATE WinToast)
set_target_properties(WinToastTuiExample PROPERTIES WIN32_EXECUTABLE ON)

View File

@ -0,0 +1,20 @@
WinToast Console Example!
===================
WinToast Contole Example [OPTIONS]
--action : Set the actions in buttons
--aumi : Set the App User Model Id
--appname : Set the default appname
--appid : Set the App Id
--expirems : Set the default expiration time
--text : Set the text for the notifications
--image : set the image path
--help : Print the help description
Example:
"WinToast Contole Example.exe" --appname "Yolo" --aumi "My.Console.Example" --image "if_terminal_298878.png" --expirems 10000 --action Yes --action No --text "Do you want to try to take over the world?"

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinToast Console Example", "WinToast Console Example.vcxproj", "{7C5AC60D-8668-47B6-9D05-FB363F854065}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7C5AC60D-8668-47B6-9D05-FB363F854065}.Debug|x64.ActiveCfg = Debug|Win32
{7C5AC60D-8668-47B6-9D05-FB363F854065}.Debug|x64.Build.0 = Debug|Win32
{7C5AC60D-8668-47B6-9D05-FB363F854065}.Debug|x86.ActiveCfg = Debug|Win32
{7C5AC60D-8668-47B6-9D05-FB363F854065}.Debug|x86.Build.0 = Debug|Win32
{7C5AC60D-8668-47B6-9D05-FB363F854065}.Release|x64.ActiveCfg = Release|x64
{7C5AC60D-8668-47B6-9D05-FB363F854065}.Release|x64.Build.0 = Release|x64
{7C5AC60D-8668-47B6-9D05-FB363F854065}.Release|x86.ActiveCfg = Release|Win32
{7C5AC60D-8668-47B6-9D05-FB363F854065}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ABA98BF8-B665-455B-A51E-B36DD616139C}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{7C5AC60D-8668-47B6-9D05-FB363F854065}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(ProjectDir)\..\..\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(ProjectDir)\..\..\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(ProjectDir)\..\..\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(ProjectDir)\..\..\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>WIN32;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<Link>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
<Link>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<Optimization>MinSpace</Optimization>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\wintoastlib.cpp" />
<ClCompile Include="main.cpp">
<AdditionalIncludeDirectories>..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\wintoastlib.h" />
</ItemGroup>
<ItemGroup>
<Image Include="if_terminal_298878.png" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\.editorconfig" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\wintoastlib.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\wintoastlib.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="if_terminal_298878.png">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<None Include="..\..\.editorconfig" />
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,182 @@
#include "wintoastlib.h"
#include <string>
#include <windows.h>
using namespace WinToastLib;
class CustomHandler : public IWinToastHandler {
public:
void toastActivated() const {
std::wcout << L"The user clicked in this toast" << std::endl;
exit(0);
}
void toastActivated(int actionIndex) const {
std::wcout << L"The user clicked on action #" << actionIndex << std::endl;
exit(16 + actionIndex);
}
void toastDismissed(WinToastDismissalReason state) const {
switch (state) {
case UserCanceled:
std::wcout << L"The user dismissed this toast" << std::endl;
exit(1);
break;
case TimedOut:
std::wcout << L"The toast has timed out" << std::endl;
exit(2);
break;
case ApplicationHidden:
std::wcout << L"The application hid the toast using ToastNotifier.hide()" << std::endl;
exit(3);
break;
default:
std::wcout << L"Toast not activated" << std::endl;
exit(4);
break;
}
}
void toastFailed() const {
std::wcout << L"Error showing current toast" << std::endl;
exit(5);
}
};
enum Results {
ToastClicked, // user clicked on the toast
ToastDismissed, // user dismissed the toast
ToastTimeOut, // toast timed out
ToastHided, // application hid the toast
ToastNotActivated, // toast was not activated
ToastFailed, // toast failed
SystemNotSupported, // system does not support toasts
UnhandledOption, // unhandled option
MultipleTextNotSupported, // multiple texts were provided
InitializationFailure, // toast notification manager initialization failure
ToastNotLaunched // toast could not be launched
};
#define COMMAND_ACTION L"--action"
#define COMMAND_AUMI L"--aumi"
#define COMMAND_APPNAME L"--appname"
#define COMMAND_APPID L"--appid"
#define COMMAND_EXPIREMS L"--expirems"
#define COMMAND_TEXT L"--text"
#define COMMAND_HELP L"--help"
#define COMMAND_IMAGE L"--image"
#define COMMAND_SHORTCUT L"--only-create-shortcut"
#define COMMAND_AUDIOSTATE L"--audio-state"
#define COMMAND_ATTRIBUTE L"--attribute"
void print_help() {
std::wcout << "WinToast Console Example [OPTIONS]" << std::endl;
std::wcout << "\t" << COMMAND_ACTION << L" : Set the actions in buttons" << std::endl;
std::wcout << "\t" << COMMAND_AUMI << L" : Set the App User Model Id" << std::endl;
std::wcout << "\t" << COMMAND_APPNAME << L" : Set the default appname" << std::endl;
std::wcout << "\t" << COMMAND_APPID << L" : Set the App Id" << std::endl;
std::wcout << "\t" << COMMAND_EXPIREMS << L" : Set the default expiration time" << std::endl;
std::wcout << "\t" << COMMAND_TEXT << L" : Set the text for the notifications" << std::endl;
std::wcout << "\t" << COMMAND_IMAGE << L" : set the image path" << std::endl;
std::wcout << "\t" << COMMAND_ATTRIBUTE << L" : set the attribute for the notification" << std::endl;
std::wcout << "\t" << COMMAND_SHORTCUT << L" : create the shortcut for the app" << std::endl;
std::wcout << "\t" << COMMAND_AUDIOSTATE << L" : set the audio state: Default = 0, Silent = 1, Loop = 2" << std::endl;
std::wcout << "\t" << COMMAND_HELP << L" : Print the help description" << std::endl;
}
int wmain(int argc, LPWSTR* argv) {
if (argc == 1) {
print_help();
return 0;
}
if (!WinToast::isCompatible()) {
std::wcerr << L"Error, your system in not supported!" << std::endl;
return Results::SystemNotSupported;
}
std::wstring appName = L"Console WinToast Example";
std::wstring appUserModelID = L"WinToast Console Example";
std::wstring text = L"";
std::wstring imagePath = L"";
std::wstring attribute = L"default";
std::vector<std::wstring> actions;
INT64 expiration = 0;
bool onlyCreateShortcut = false;
WinToastTemplate::AudioOption audioOption = WinToastTemplate::AudioOption::Default;
int i;
for (i = 1; i < argc; i++) {
if (!wcscmp(COMMAND_IMAGE, argv[i])) {
imagePath = argv[++i];
} else if (!wcscmp(COMMAND_ACTION, argv[i])) {
actions.push_back(argv[++i]);
} else if (!wcscmp(COMMAND_EXPIREMS, argv[i])) {
expiration = wcstol(argv[++i], NULL, 10);
} else if (!wcscmp(COMMAND_APPNAME, argv[i])) {
appName = argv[++i];
} else if (!wcscmp(COMMAND_AUMI, argv[i]) || !wcscmp(COMMAND_APPID, argv[i])) {
appUserModelID = argv[++i];
} else if (!wcscmp(COMMAND_TEXT, argv[i])) {
text = argv[++i];
} else if (!wcscmp(COMMAND_ATTRIBUTE, argv[i])) {
attribute = argv[++i];
} else if (!wcscmp(COMMAND_SHORTCUT, argv[i])) {
onlyCreateShortcut = true;
} else if (!wcscmp(COMMAND_AUDIOSTATE, argv[i])) {
audioOption = static_cast<WinToastTemplate::AudioOption>(std::stoi(argv[++i]));
} else if (!wcscmp(COMMAND_HELP, argv[i])) {
print_help();
return 0;
} else {
std::wcerr << L"Option not recognized: " << argv[i] << std::endl;
return Results::UnhandledOption;
}
}
WinToast::instance()->setAppName(appName);
WinToast::instance()->setAppUserModelId(appUserModelID);
if (onlyCreateShortcut) {
if (!imagePath.empty() || !text.empty() || actions.size() > 0 || expiration) {
std::wcerr << L"--only-create-shortcut does not accept images/text/actions/expiration" << std::endl;
return 9;
}
enum WinToast::ShortcutResult result = WinToast::instance()->createShortcut();
return result ? 16 + result : 0;
}
if (text.empty()) {
text = L"Hello, world!";
}
if (!WinToast::instance()->initialize()) {
std::wcerr << L"Error, your system in not compatible!" << std::endl;
return Results::InitializationFailure;
}
WinToastTemplate templ(!imagePath.empty() ? WinToastTemplate::ImageAndText02 : WinToastTemplate::Text02);
templ.setTextField(text, WinToastTemplate::FirstLine);
templ.setAudioOption(audioOption);
templ.setAttributionText(attribute);
templ.setImagePath(imagePath);
for (auto const& action : actions) {
templ.addAction(action);
}
if (expiration) {
templ.setExpiration(expiration);
}
if (WinToast::instance()->showToast(templ, new CustomHandler()) < 0) {
std::wcerr << L"Could not launch your toast notification!";
return Results::ToastFailed;
}
// Give the handler a chance for 15 seconds (or the expiration plus 1 second)
Sleep(expiration ? (DWORD) expiration + 1000 : 15000);
exit(2);
}

View 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)

View 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();
}

View 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!");
}
}

View 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

View 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>

310
deps/WinToast/include/wintoastlib.h vendored Normal file
View File

@ -0,0 +1,310 @@
/**
* MIT License
*
* Copyright (C) 2016-2023 WinToast v1.3.0 - Mohammed Boujemaoui <mohabouje@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef WINTOASTLIB_H
#define WINTOASTLIB_H
#include <Windows.h>
#include <sdkddkver.h>
#include <WinUser.h>
#include <ShObjIdl.h>
#include <wrl/implements.h>
#include <wrl/event.h>
#include <windows.ui.notifications.h>
#include <strsafe.h>
#include <Psapi.h>
#include <ShlObj.h>
#include <roapi.h>
#include <propvarutil.h>
#include <functiondiscoverykeys.h>
#include <iostream>
#include <winstring.h>
#include <string.h>
#include <vector>
#include <map>
#include <memory>
using namespace Microsoft::WRL;
using namespace ABI::Windows::Data::Xml::Dom;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::Notifications;
using namespace Windows::Foundation;
namespace WinToastLib {
class IWinToastHandler {
public:
enum WinToastDismissalReason {
UserCanceled = ToastDismissalReason::ToastDismissalReason_UserCanceled,
ApplicationHidden = ToastDismissalReason::ToastDismissalReason_ApplicationHidden,
TimedOut = ToastDismissalReason::ToastDismissalReason_TimedOut
};
virtual ~IWinToastHandler() = default;
virtual void toastActivated() const = 0;
virtual void toastActivated(int actionIndex) const = 0;
virtual void toastDismissed(WinToastDismissalReason state) const = 0;
virtual void toastFailed() const = 0;
};
class WinToastTemplate {
public:
enum class Scenario { Default, Alarm, IncomingCall, Reminder };
enum Duration { System, Short, Long };
enum AudioOption { Default = 0, Silent, Loop };
enum TextField { FirstLine = 0, SecondLine, ThirdLine };
enum WinToastTemplateType {
ImageAndText01 = ToastTemplateType::ToastTemplateType_ToastImageAndText01,
ImageAndText02 = ToastTemplateType::ToastTemplateType_ToastImageAndText02,
ImageAndText03 = ToastTemplateType::ToastTemplateType_ToastImageAndText03,
ImageAndText04 = ToastTemplateType::ToastTemplateType_ToastImageAndText04,
Text01 = ToastTemplateType::ToastTemplateType_ToastText01,
Text02 = ToastTemplateType::ToastTemplateType_ToastText02,
Text03 = ToastTemplateType::ToastTemplateType_ToastText03,
Text04 = ToastTemplateType::ToastTemplateType_ToastText04
};
enum AudioSystemFile {
DefaultSound,
IM,
Mail,
Reminder,
SMS,
Alarm,
Alarm2,
Alarm3,
Alarm4,
Alarm5,
Alarm6,
Alarm7,
Alarm8,
Alarm9,
Alarm10,
Call,
Call1,
Call2,
Call3,
Call4,
Call5,
Call6,
Call7,
Call8,
Call9,
Call10,
};
enum CropHint {
Square,
Circle,
};
WinToastTemplate(_In_ WinToastTemplateType type = WinToastTemplateType::ImageAndText02);
~WinToastTemplate();
void setFirstLine(_In_ std::wstring const& text);
void setSecondLine(_In_ std::wstring const& text);
void setThirdLine(_In_ std::wstring const& text);
void setTextField(_In_ std::wstring const& txt, _In_ TextField pos);
void setAttributionText(_In_ std::wstring const& attributionText);
void setImagePath(_In_ std::wstring const& imgPath, _In_ CropHint cropHint = CropHint::Square);
void setHeroImagePath(_In_ std::wstring const& imgPath, _In_ bool inlineImage = false);
void setAudioPath(_In_ WinToastTemplate::AudioSystemFile audio);
void setAudioPath(_In_ std::wstring const& audioPath);
void setAudioOption(_In_ WinToastTemplate::AudioOption audioOption);
void setDuration(_In_ Duration duration);
void setExpiration(_In_ INT64 millisecondsFromNow);
void setScenario(_In_ Scenario scenario);
void addAction(_In_ std::wstring const& label);
std::size_t textFieldsCount() const;
std::size_t actionsCount() const;
bool hasImage() const;
bool hasHeroImage() const;
std::vector<std::wstring> const& textFields() const;
std::wstring const& textField(_In_ TextField pos) const;
std::wstring const& actionLabel(_In_ std::size_t pos) const;
std::wstring const& imagePath() const;
std::wstring const& heroImagePath() const;
std::wstring const& audioPath() const;
std::wstring const& attributionText() const;
std::wstring const& scenario() const;
INT64 expiration() const;
WinToastTemplateType type() const;
WinToastTemplate::AudioOption audioOption() const;
Duration duration() const;
bool isToastGeneric() const;
bool isInlineHeroImage() const;
bool isCropHintCircle() const;
private:
std::vector<std::wstring> _textFields{};
std::vector<std::wstring> _actions{};
std::wstring _imagePath{};
std::wstring _heroImagePath{};
bool _inlineHeroImage{false};
std::wstring _audioPath{};
std::wstring _attributionText{};
std::wstring _scenario{L"Default"};
INT64 _expiration{0};
AudioOption _audioOption{WinToastTemplate::AudioOption::Default};
WinToastTemplateType _type{WinToastTemplateType::Text01};
Duration _duration{Duration::System};
CropHint _cropHint{CropHint::Square};
};
class WinToast {
public:
enum WinToastError {
NoError = 0,
NotInitialized,
SystemNotSupported,
ShellLinkNotCreated,
InvalidAppUserModelID,
InvalidParameters,
InvalidHandler,
NotDisplayed,
UnknownError
};
enum ShortcutResult {
SHORTCUT_UNCHANGED = 0,
SHORTCUT_WAS_CHANGED = 1,
SHORTCUT_WAS_CREATED = 2,
SHORTCUT_MISSING_PARAMETERS = -1,
SHORTCUT_INCOMPATIBLE_OS = -2,
SHORTCUT_COM_INIT_FAILURE = -3,
SHORTCUT_CREATE_FAILED = -4
};
enum ShortcutPolicy {
/* Don't check, create, or modify a shortcut. */
SHORTCUT_POLICY_IGNORE = 0,
/* Require a shortcut with matching AUMI, don't create or modify an existing one. */
SHORTCUT_POLICY_REQUIRE_NO_CREATE = 1,
/* Require a shortcut with matching AUMI, create if missing, modify if not matching. This is the default. */
SHORTCUT_POLICY_REQUIRE_CREATE = 2,
};
WinToast(void);
virtual ~WinToast();
static WinToast* instance();
static bool isCompatible();
static bool isSupportingModernFeatures();
static bool isWin10AnniversaryOrHigher();
static std::wstring configureAUMI(_In_ std::wstring const& companyName, _In_ std::wstring const& productName,
_In_ std::wstring const& subProduct = std::wstring(),
_In_ std::wstring const& versionInformation = std::wstring());
static std::wstring const& strerror(_In_ WinToastError error);
virtual bool initialize(_Out_opt_ WinToastError* error = nullptr);
virtual bool isInitialized() const;
virtual bool hideToast(_In_ INT64 id);
virtual INT64 showToast(_In_ WinToastTemplate const& toast, _In_ IWinToastHandler* eventHandler,
_Out_opt_ WinToastError* error = nullptr);
virtual void clear();
virtual enum ShortcutResult createShortcut();
std::wstring const& appName() const;
std::wstring const& appUserModelId() const;
void setAppUserModelId(_In_ std::wstring const& aumi);
void setAppName(_In_ std::wstring const& appName);
void setShortcutPolicy(_In_ ShortcutPolicy policy);
protected:
struct NotifyData {
NotifyData(){};
NotifyData(_In_ ComPtr<IToastNotification> notify, _In_ EventRegistrationToken activatedToken,
_In_ EventRegistrationToken dismissedToken, _In_ EventRegistrationToken failedToken) :
_notify(notify), _activatedToken(activatedToken), _dismissedToken(dismissedToken), _failedToken(failedToken) {}
~NotifyData() {
RemoveTokens();
}
void RemoveTokens() {
if (!_readyForDeletion) {
return;
}
if (_previouslyTokenRemoved) {
return;
}
if (!_notify.Get()) {
return;
}
_notify->remove_Activated(_activatedToken);
_notify->remove_Dismissed(_dismissedToken);
_notify->remove_Failed(_failedToken);
_previouslyTokenRemoved = true;
}
void markAsReadyForDeletion() {
_readyForDeletion = true;
}
bool isReadyForDeletion() const {
return _readyForDeletion;
}
IToastNotification* notification() {
return _notify.Get();
}
private:
ComPtr<IToastNotification> _notify{nullptr};
EventRegistrationToken _activatedToken{};
EventRegistrationToken _dismissedToken{};
EventRegistrationToken _failedToken{};
bool _readyForDeletion{false};
bool _previouslyTokenRemoved{false};
};
bool _isInitialized{false};
bool _hasCoInitialized{false};
ShortcutPolicy _shortcutPolicy{SHORTCUT_POLICY_REQUIRE_CREATE};
std::wstring _appName{};
std::wstring _aumi{};
std::map<INT64, NotifyData> _buffer{};
void markAsReadyForDeletion(_In_ INT64 id);
HRESULT validateShellLinkHelper(_Out_ bool& wasChanged);
HRESULT createShellLinkHelper();
HRESULT setImageFieldHelper(_In_ IXmlDocument* xml, _In_ std::wstring const& path, _In_ bool isToastGeneric, bool isCropHintCircle);
HRESULT setHeroImageHelper(_In_ IXmlDocument* xml, _In_ std::wstring const& path, _In_ bool isInlineImage);
HRESULT setBindToastGenericHelper(_In_ IXmlDocument* xml);
HRESULT
setAudioFieldHelper(_In_ IXmlDocument* xml, _In_ std::wstring const& path,
_In_opt_ WinToastTemplate::AudioOption option = WinToastTemplate::AudioOption::Default);
HRESULT setTextFieldHelper(_In_ IXmlDocument* xml, _In_ std::wstring const& text, _In_ UINT32 pos);
HRESULT setAttributionTextFieldHelper(_In_ IXmlDocument* xml, _In_ std::wstring const& text);
HRESULT addActionHelper(_In_ IXmlDocument* xml, _In_ std::wstring const& action, _In_ std::wstring const& arguments);
HRESULT addDurationHelper(_In_ IXmlDocument* xml, _In_ std::wstring const& duration);
HRESULT addScenarioHelper(_In_ IXmlDocument* xml, _In_ std::wstring const& scenario);
ComPtr<IToastNotifier> notifier(_In_ bool* succeded) const;
void setError(_Out_opt_ WinToastError* error, _In_ WinToastError value);
};
} // namespace WinToastLib
#endif // WINTOASTLIB_H

15
deps/WinToast/request.md vendored Normal file
View File

@ -0,0 +1,15 @@
# Feature Request
Planned features for each specific version
## Version 1.4.0
- Fire notifications from non-admin accounts in elevated context [#54](https://github.com/mohabouje/WinToast/issues/54)
- Fire notifications from the ActionCenter [#35](https://github.com/mohabouje/WinToast/issues/35)
- Adding the ability to reuse the AUMID of the current process [#80](https://github.com/mohabouje/WinToast/issues/80)
- Change the arguments of specific actions (Buttons) [#72](https://github.com/mohabouje/WinToast/issues/72)
- Support for Input Text (LineEdit) [#42](https://github.com/mohabouje/WinToast/issues/42)
- Support for Input Selection (Combobox)
- Support for ProgressBar [#42](https://github.com/mohabouje/WinToast/issues/42)
- Support for Scheduling notifications at specific times [[#66](https://github.com/mohabouje/WinToast/issues/66)

1362
deps/WinToast/src/wintoastlib.cpp vendored Normal file

File diff suppressed because it is too large Load Diff