diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,8 @@ XmlGui ConfigWidgets TextEditor + Notifications + NotifyConfig ) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS diff --git a/deploy/CMakeLists.txt b/deploy/CMakeLists.txt --- a/deploy/CMakeLists.txt +++ b/deploy/CMakeLists.txt @@ -1,11 +1,14 @@ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/atelier.png" DESTINATION share/pixmaps) - + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/org.kde.atelier.desktop" DESTINATION share/applications) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/org.kde.atelier.appdata.xml" DESTINATION ${KDE_INSTALL_METAINFODIR}) + +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/atelier.notifyrc" + DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR}) diff --git a/deploy/atelier.notifyrc b/deploy/atelier.notifyrc new file mode 100644 --- /dev/null +++ b/deploy/atelier.notifyrc @@ -0,0 +1,29 @@ +[Global] +IconName=atelier +Comment=Atelier Printer Host +Name=Atelier + +[Event/printerIdle] +Name=Printer Idle +Comment=Printer is on idle state +Action=Popup + +[Event/printerDisconnected] +Name=Printer Disconnected +Comment=The printer is disconnected +Action=Popup + +[Event/printerError] +Name=Error +Comment=The printer reported an error +Action=Popup + +[Event/startPrint] +Name=Started Print +Comment=A print job has started +Action=Popup + +[Event/finishedPrint] +Name=Finished Print +Comment=A print job has finished +Action=Popup diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,5 +36,6 @@ AtCore::AtCore AtCore::AtCoreWidgets KF5::ConfigWidgets + KF5::NotifyConfig KF5::XmlGui ) diff --git a/src/mainwindow.h b/src/mainwindow.h --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -79,6 +79,9 @@ void toggleGCodeActions(); void updateClientFactory(KTextEditor::View *view); +private slots: + void configureNotifications(); + signals: void extruderCountChanged(int count); void profilesChanged(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -18,6 +18,7 @@ */ #include #include +#include #include #include #include @@ -291,6 +292,8 @@ emit(profilesChanged()); }); + action = KStandardAction::configureNotifications(this, SLOT(configureNotifications()), actionCollection()); + action = actionCollection()->addAction(QStringLiteral("quit")); action->setIcon(QIcon::fromTheme("application-exit", QIcon(":/icon/exit"))); @@ -473,3 +476,8 @@ return dialog->exec(); } + +void MainWindow::configureNotifications() +{ + KNotifyConfigWidget::configure(this); +} diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -15,6 +15,7 @@ target_link_libraries(AtelierWidgets AtCore::AtCore KF5::I18n + KF5::Notifications KF5::TextEditor Qt5::Charts Qt5::Core diff --git a/src/widgets/atcoreinstancewidget.h b/src/widgets/atcoreinstancewidget.h --- a/src/widgets/atcoreinstancewidget.h +++ b/src/widgets/atcoreinstancewidget.h @@ -56,6 +56,7 @@ private: AtCore m_core; + AtCore::STATES m_lastState; BedExtruderWidget *m_bedExtWidget; CommandWidget *m_commandWidget; int m_fileCount; diff --git a/src/widgets/atcoreinstancewidget.cpp b/src/widgets/atcoreinstancewidget.cpp --- a/src/widgets/atcoreinstancewidget.cpp +++ b/src/widgets/atcoreinstancewidget.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include "atcoreinstancewidget.h" @@ -357,6 +358,13 @@ connect(m_core.serial(), &SerialLayer::pushedCommand, m_logWidget, &LogWidget::appendSLog); } break; case AtCore::IDLE: { + if (m_lastState == AtCore::CONNECTING) { + KNotification::event("printerIdle" + , i18n("Printer is Idle \n Profile %1 on device %2" + , m_comboProfile->currentText() + , m_core.serial()->portName()) + , QString()); + } stateString = i18n("Connected to %1", m_core.serial()->portName()); emit extruderCountChanged(m_core.extruderCount()); m_logWidget->appendLog(stateString); @@ -372,6 +380,12 @@ disconnect(&m_core, &AtCore::receivedMessage, m_logWidget, &LogWidget::appendRLog); disconnect(m_core.serial(), &SerialLayer::pushedCommand, m_logWidget, &LogWidget::appendSLog); m_logWidget->appendLog(i18n("Serial disconnected")); + KNotification::event("printerDisconnected" + , i18n("Disconnected") + , i18n("Disconnected from device %1." + , m_core.serial()->portName() + ) + ); m_core.setSerialTimerInterval(100); m_connectButton->setText(i18n("Connect")); m_connectButton->setIcon(QIcon::fromTheme("network-connect", QIcon(QString(":/%1/connect").arg(m_theme)))); @@ -386,14 +400,26 @@ case AtCore::STARTPRINT: { stateString = i18n("Starting Print"); m_statusWidget->showPrintArea(true); + KNotification::event("startPrint" + , i18n("Started!") + , i18n("The print job has started on device %1." + , m_core.serial()->portName() + ) + ); connect(&m_core, &AtCore::printProgressChanged, m_statusWidget, &StatusWidget::updatePrintProgress); } break; case AtCore::FINISHEDPRINT: { stateString = i18n("Finished Print"); m_statusWidget->showPrintArea(false); disconnect(&m_core, &AtCore::printProgressChanged, m_statusWidget, &StatusWidget::updatePrintProgress); m_printAction->setText(i18n("Print")); m_printAction->setIcon(QIcon::fromTheme("media-playback-start", QIcon(QString(":/%1/start").arg(m_theme)))); + KNotification::event("finishedPrint" + , i18n("Finished!") + , i18n("The print job of device %1 has just finished." + , m_core.serial()->portName() + ) + ); m_logWidget->appendLog(i18n("Finished Print Job")); } break; case AtCore::BUSY: { @@ -419,6 +445,7 @@ qWarning("AtCore State not Recognized."); break; } + m_lastState = newState; m_statusWidget->setState(stateString); }