Skip to content

Commit

Permalink
Adding support to the QT GUI app to generate HERO images
Browse files Browse the repository at this point in the history
  • Loading branch information
mohabouje committed Apr 8, 2023
1 parent c3c5558 commit d3fb4b0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 19 deletions.
9 changes: 9 additions & 0 deletions examples/qt-gui-example/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ void MainWindow::on_imagePathSelector_clicked() {
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 {
Expand Down Expand Up @@ -86,6 +94,7 @@ 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);
Expand Down
2 changes: 1 addition & 1 deletion examples/qt-gui-example/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class MainWindow : public QMainWindow {

private slots:
void on_imagePathSelector_clicked();

void on_showToast_clicked();
void on_heroPathSelector_clicked();

private:
Ui::MainWindow* ui;
Expand Down
68 changes: 50 additions & 18 deletions examples/qt-gui-example/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<x>0</x>
<y>0</y>
<width>670</width>
<height>228</height>
<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="10" column="0">
<item row="11" column="0">
<widget class="QSpinBox" name="spinBox">
<property name="maximum">
<number>10</number>
Expand All @@ -25,17 +25,31 @@
</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="8" column="2">
<item row="9" column="2">
<widget class="QComboBox" name="audioMode"/>
</item>
<item row="5" column="2">
Expand Down Expand Up @@ -82,28 +96,28 @@
</layout>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Audio Mode</string>
</property>
</widget>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QCheckBox" name="addNo">
<property name="text">
<string>Add No Action</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Expiration time (secs)</string>
</property>
</widget>
</item>
<item row="14" column="2">
<item row="15" column="2">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
Expand Down Expand Up @@ -147,7 +161,7 @@
</layout>
</widget>
</item>
<item row="7" column="2">
<item row="8" column="2">
<widget class="QComboBox" name="audioSystemFile"/>
</item>
<item row="3" column="0">
Expand All @@ -160,14 +174,14 @@
<item row="3" column="2">
<widget class="QLineEdit" name="secondLine"/>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QCheckBox" name="addYes">
<property name="text">
<string>Add Yes Action</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Audio System File</string>
Expand All @@ -184,7 +198,7 @@
</property>
</widget>
</item>
<item row="6" column="2">
<item row="7" column="2">
<widget class="QComboBox" name="cropHint"/>
</item>
<item row="4" column="0">
Expand All @@ -194,23 +208,41 @@
</property>
</widget>
</item>
<item row="6" column="0">
<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="1" column="0">
<widget class="QLabel" name="label_9">
<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>Toast Type</string>
<string>Inline Hero Image</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="toastType"/>
</item>
</layout>
</widget>
</widget>
Expand Down

0 comments on commit d3fb4b0

Please sign in to comment.