Added don't annoy me toggle to alarm clock.
Changed version to v2.2.1.
This commit is contained in:
@@ -214,6 +214,16 @@ MyStackViewPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
MyToggleButton {
|
||||||
|
id: alarmDontAnnoyToggle
|
||||||
|
text: "Don't Annoy me"
|
||||||
|
onCheckedChanged: {
|
||||||
|
UtilitiesTabController.setAlarmIsModal(!checked, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,6 +233,7 @@ MyStackViewPage {
|
|||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
alarmClockToggle.checked = UtilitiesTabController.alarmEnabled
|
alarmClockToggle.checked = UtilitiesTabController.alarmEnabled
|
||||||
|
alarmDontAnnoyToggle.checked = !UtilitiesTabController.alarmIsModal
|
||||||
setAlarmHourText(UtilitiesTabController.alarmTimeHour)
|
setAlarmHourText(UtilitiesTabController.alarmTimeHour)
|
||||||
setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute)
|
setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute)
|
||||||
alarmGroupBox.visible = !OverlayController.desktopMode
|
alarmGroupBox.visible = !OverlayController.desktopMode
|
||||||
@@ -234,6 +245,9 @@ MyStackViewPage {
|
|||||||
onAlarmEnabledChanged: {
|
onAlarmEnabledChanged: {
|
||||||
alarmClockToggle.checked = UtilitiesTabController.alarmEnabled
|
alarmClockToggle.checked = UtilitiesTabController.alarmEnabled
|
||||||
}
|
}
|
||||||
|
onAlarmIsModalChanged: {
|
||||||
|
alarmDontAnnoyToggle.checked = !UtilitiesTabController.alarmIsModal
|
||||||
|
}
|
||||||
onAlarmTimeHourChanged: {
|
onAlarmTimeHourChanged: {
|
||||||
setAlarmHourText(UtilitiesTabController.alarmTimeHour)
|
setAlarmHourText(UtilitiesTabController.alarmTimeHour)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class OverlayController : public QObject {
|
|||||||
public:
|
public:
|
||||||
static constexpr const char* applicationKey = "matzman666.AdvancedSettings";
|
static constexpr const char* applicationKey = "matzman666.AdvancedSettings";
|
||||||
static constexpr const char* applicationName = "Advanced Settings";
|
static constexpr const char* applicationName = "Advanced Settings";
|
||||||
static constexpr const char* applicationVersionString = "v2.2";
|
static constexpr const char* applicationVersionString = "v2.2.1";
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid;
|
vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid;
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ namespace advsettings {
|
|||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup("utilitiesSettings");
|
settings->beginGroup("utilitiesSettings");
|
||||||
auto qAlarmEnabled = settings->value("alarmEnabled", m_alarmEnabled);
|
auto qAlarmEnabled = settings->value("alarmEnabled", m_alarmEnabled);
|
||||||
|
auto qAlarmIsModal = settings->value("alarmIsModal", m_alarmIsModal);
|
||||||
auto qAlarmHour = settings->value("alarmHour", 0);
|
auto qAlarmHour = settings->value("alarmHour", 0);
|
||||||
auto qAlarmMinute = settings->value("alarmMinute", 0);
|
auto qAlarmMinute = settings->value("alarmMinute", 0);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
m_alarmEnabled = qAlarmEnabled.toBool();
|
m_alarmEnabled = qAlarmEnabled.toBool();
|
||||||
|
m_alarmIsModal = qAlarmIsModal.toBool();
|
||||||
m_alarmTime = QTime(qAlarmHour.toInt(), qAlarmMinute.toInt());
|
m_alarmTime = QTime(qAlarmHour.toInt(), qAlarmMinute.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +162,10 @@ namespace advsettings {
|
|||||||
return m_alarmEnabled;
|
return m_alarmEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UtilitiesTabController::alarmIsModal() const {
|
||||||
|
return m_alarmIsModal;
|
||||||
|
}
|
||||||
|
|
||||||
int UtilitiesTabController::alarmTimeHour() const {
|
int UtilitiesTabController::alarmTimeHour() const {
|
||||||
return m_alarmTime.hour();
|
return m_alarmTime.hour();
|
||||||
}
|
}
|
||||||
@@ -183,6 +189,20 @@ namespace advsettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UtilitiesTabController::setAlarmIsModal(bool modal, bool notify) {
|
||||||
|
if (m_alarmIsModal != modal) {
|
||||||
|
m_alarmIsModal = modal;
|
||||||
|
auto settings = OverlayController::appSettings();
|
||||||
|
settings->beginGroup("utilitiesSettings");
|
||||||
|
settings->setValue("alarmIsModal", m_alarmIsModal);
|
||||||
|
settings->endGroup();
|
||||||
|
settings->sync();
|
||||||
|
if (notify) {
|
||||||
|
emit alarmIsModalChanged(m_alarmIsModal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::setAlarmTimeHour(int hour, bool notify) {
|
void UtilitiesTabController::setAlarmTimeHour(int hour, bool notify) {
|
||||||
if (m_alarmTime.hour() != hour) {
|
if (m_alarmTime.hour() != hour) {
|
||||||
if (m_alarmTime.isValid()) {
|
if (m_alarmTime.isValid()) {
|
||||||
@@ -278,22 +298,7 @@ namespace advsettings {
|
|||||||
setAlarmEnabled(false);
|
setAlarmEnabled(false);
|
||||||
char alarmMessageBuffer[1024];
|
char alarmMessageBuffer[1024];
|
||||||
std::snprintf(alarmMessageBuffer, 1024, "The alarm at %02i:%02i went off.", alarmTimeHour(), alarmTimeMinute());
|
std::snprintf(alarmMessageBuffer, 1024, "The alarm at %02i:%02i went off.", alarmTimeHour(), alarmTimeMinute());
|
||||||
vr::VRNotificationId notificationId;
|
if (m_alarmIsModal) {
|
||||||
vr::EVRInitError eError;
|
|
||||||
vr::IVRNotifications* vrnotification = (vr::IVRNotifications*)vr::VR_GetGenericInterface(vr::IVRNotifications_Version, &eError);
|
|
||||||
if (eError != vr::VRInitError_None) {
|
|
||||||
LOG(ERROR) << "Error while getting IVRNotifications interface" << vr::VR_GetVRInitErrorAsEnglishDescription(eError);
|
|
||||||
vrnotification = nullptr;
|
|
||||||
} else {
|
|
||||||
auto nError = vrnotification->CreateNotification(
|
|
||||||
parent->overlayThumbnailHandle(), 666, vr::EVRNotificationType_Transient_SystemWithUserValue, alarmMessageBuffer, vr::EVRNotificationStyle_Application, nullptr, ¬ificationId
|
|
||||||
);
|
|
||||||
if (nError != vr::VRNotificationError_OK) {
|
|
||||||
LOG(ERROR) << "Error while creating notification: " << nError;
|
|
||||||
vrnotification = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!vr::VROverlay()->IsDashboardVisible()) { // message overlay is not shown when the dashboard is visible (see https://github.com/ValveSoftware/openvr/issues/348)
|
|
||||||
std::thread messageThread([](UtilitiesTabController* parent, std::string message) {
|
std::thread messageThread([](UtilitiesTabController* parent, std::string message) {
|
||||||
auto res = vr::VROverlay()->ShowMessageOverlay(message.c_str(), "Alarm Clock", "Ok", "+15 min");
|
auto res = vr::VROverlay()->ShowMessageOverlay(message.c_str(), "Alarm Clock", "Ok", "+15 min");
|
||||||
if (res == vr::VRMessageOverlayResponse_ButtonPress_1) {
|
if (res == vr::VRMessageOverlayResponse_ButtonPress_1) {
|
||||||
@@ -311,6 +316,46 @@ namespace advsettings {
|
|||||||
}
|
}
|
||||||
}, this, std::string(alarmMessageBuffer));
|
}, this, std::string(alarmMessageBuffer));
|
||||||
messageThread.detach();
|
messageThread.detach();
|
||||||
|
} else {
|
||||||
|
vr::VRNotificationId notificationId;
|
||||||
|
vr::EVRInitError eError;
|
||||||
|
vr::IVRNotifications* vrnotification = (vr::IVRNotifications*)vr::VR_GetGenericInterface(vr::IVRNotifications_Version, &eError);
|
||||||
|
if (eError != vr::VRInitError_None) {
|
||||||
|
LOG(ERROR) << "Error while getting IVRNotifications interface" << vr::VR_GetVRInitErrorAsEnglishDescription(eError);
|
||||||
|
vrnotification = nullptr;
|
||||||
|
} else {
|
||||||
|
vr::NotificationBitmap_t* messageIconPtr = nullptr;
|
||||||
|
/*
|
||||||
|
// Can i even create this object on the stack, who takes ownership?
|
||||||
|
vr::NotificationBitmap_t messageIcon;
|
||||||
|
|
||||||
|
// First get image width and height
|
||||||
|
vr::VROverlay()->GetOverlayImageData(parent->overlayThumbnailHandle(), nullptr, 0, (uint32_t*)&messageIcon.m_nWidth, (uint32_t*)&messageIcon.m_nHeight);
|
||||||
|
|
||||||
|
messageIcon.m_nBytesPerPixel = 4;
|
||||||
|
unsigned bufferSize = messageIcon.m_nWidth*messageIcon.m_nHeight*messageIcon.m_nBytesPerPixel;
|
||||||
|
|
||||||
|
// Can I delete this buffer after this section? Who takes ownership?
|
||||||
|
std::unique_ptr<char> imageBuffer;
|
||||||
|
imageBuffer.reset(new char[bufferSize]);
|
||||||
|
messageIcon.m_pImageData = imageBuffer.get();
|
||||||
|
|
||||||
|
// Get image data
|
||||||
|
auto iconError = vr::VROverlay()->GetOverlayImageData(parent->overlayThumbnailHandle(), messageIcon.m_pImageData, bufferSize, (uint32_t*)&messageIcon.m_nWidth, (uint32_t*)&messageIcon.m_nHeight);
|
||||||
|
if (iconError != vr::VROverlayError_None) {
|
||||||
|
LOG(ERROR) << "Error while getting message overlay icon: " << vr::VROverlay()->GetOverlayErrorNameFromEnum(iconError);
|
||||||
|
} else {
|
||||||
|
messageIconPtr = &messageIcon;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
auto nError = vrnotification->CreateNotification(
|
||||||
|
parent->overlayHandle(), 666, vr::EVRNotificationType_Transient, alarmMessageBuffer, vr::EVRNotificationStyle_Application, messageIconPtr, ¬ificationId
|
||||||
|
);
|
||||||
|
if (nError != vr::VRNotificationError_OK) {
|
||||||
|
LOG(ERROR) << "Error while creating notification: " << nError;
|
||||||
|
vrnotification = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_alarmLastCheckTime = now;
|
m_alarmLastCheckTime = now;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace advsettings {
|
|||||||
class UtilitiesTabController : public QObject {
|
class UtilitiesTabController : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled NOTIFY alarmEnabledChanged)
|
Q_PROPERTY(bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled NOTIFY alarmEnabledChanged)
|
||||||
|
Q_PROPERTY(bool alarmIsModal READ alarmIsModal WRITE setAlarmIsModal NOTIFY alarmIsModalChanged)
|
||||||
Q_PROPERTY(int alarmTimeHour READ alarmTimeHour WRITE setAlarmTimeHour NOTIFY alarmTimeHourChanged)
|
Q_PROPERTY(int alarmTimeHour READ alarmTimeHour WRITE setAlarmTimeHour NOTIFY alarmTimeHourChanged)
|
||||||
Q_PROPERTY(int alarmTimeMinute READ alarmTimeMinute WRITE setAlarmTimeMinute NOTIFY alarmTimeMinuteChanged)
|
Q_PROPERTY(int alarmTimeMinute READ alarmTimeMinute WRITE setAlarmTimeMinute NOTIFY alarmTimeMinuteChanged)
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ namespace advsettings {
|
|||||||
unsigned settingsUpdateCounter = 0;
|
unsigned settingsUpdateCounter = 0;
|
||||||
|
|
||||||
bool m_alarmEnabled = false;
|
bool m_alarmEnabled = false;
|
||||||
|
bool m_alarmIsModal = true;
|
||||||
QTime m_alarmTime;
|
QTime m_alarmTime;
|
||||||
QTime m_alarmLastCheckTime;
|
QTime m_alarmLastCheckTime;
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ namespace advsettings {
|
|||||||
void eventLoopTick();
|
void eventLoopTick();
|
||||||
|
|
||||||
bool alarmEnabled() const;
|
bool alarmEnabled() const;
|
||||||
|
bool alarmIsModal() const;
|
||||||
int alarmTimeHour() const;
|
int alarmTimeHour() const;
|
||||||
int alarmTimeMinute() const;
|
int alarmTimeMinute() const;
|
||||||
|
|
||||||
@@ -44,6 +47,7 @@ namespace advsettings {
|
|||||||
void sendKeyboardBackspace(int count);
|
void sendKeyboardBackspace(int count);
|
||||||
|
|
||||||
void setAlarmEnabled(bool enabled, bool notify = true);
|
void setAlarmEnabled(bool enabled, bool notify = true);
|
||||||
|
void setAlarmIsModal(bool modal, bool notify = true);
|
||||||
void setAlarmTimeHour(int hour, bool notify = true);
|
void setAlarmTimeHour(int hour, bool notify = true);
|
||||||
void setAlarmTimeMinute(int min, bool notify = true);
|
void setAlarmTimeMinute(int min, bool notify = true);
|
||||||
void setAlarmTimeToCurrentTime();
|
void setAlarmTimeToCurrentTime();
|
||||||
@@ -52,6 +56,7 @@ namespace advsettings {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void alarmEnabledChanged(bool enabled);
|
void alarmEnabledChanged(bool enabled);
|
||||||
|
void alarmIsModalChanged(bool modal);
|
||||||
void alarmTimeHourChanged(int hour);
|
void alarmTimeHourChanged(int hour);
|
||||||
void alarmTimeMinuteChanged(int min);
|
void alarmTimeMinuteChanged(int min);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user