-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SPDX-FileCopyrightText: 2024 Nick Korotysh <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
project(spectrum_clock VERSION 3.0.0 LANGUAGES CXX) | ||
|
||
qt_add_plugin(${PROJECT_NAME} CLASS_NAME SpectrumClockPluginFactory | ||
spectrum_clock_plugin.cpp | ||
spectrum_clock_plugin.hpp | ||
) | ||
|
||
add_win_rc_file(${PROJECT_NAME} ${PROJECT_NAME}.rc) | ||
|
||
set_clock_plugin_common_properties(${PROJECT_NAME}) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE PluginCore) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt::Gui) | ||
|
||
configure_file(${PROJECT_NAME}.json.in ${PROJECT_NAME}.json @ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@PROJECT_NAME@", | ||
"version": "@PROJECT_VERSION@", | ||
"settings_notifier": true, | ||
"author": "Nick Korotysh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
1 VERSIONINFO | ||
FILEVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},${BUILD_NUMBER} | ||
PRODUCTVERSION ${CLOCK_VERSION_MAJOR},${CLOCK_VERSION_MINOR},${CLOCK_VERSION_PATCH},0 | ||
FILEFLAGSMASK 0x3F | ||
FILEFLAGS 0x0 | ||
FILEOS 0x40004 | ||
FILETYPE 0x2 | ||
FILESUBTYPE 0x0 | ||
{ | ||
BLOCK "StringFileInfo" | ||
{ | ||
BLOCK "040904E4" | ||
{ | ||
VALUE "Comments", "${PROJECT_DESCRIPTION}" | ||
VALUE "CompanyName", "Nick Korotysh" | ||
VALUE "FileDescription", "Digital Clock Plugin" | ||
VALUE "FileVersion", "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${BUILD_NUMBER}" | ||
VALUE "InternalName", "${PROJECT_NAME}.dll" | ||
VALUE "LegalCopyright", "(c) 2013-2024 Nick Korotysh" | ||
VALUE "OriginalFilename", "${PROJECT_NAME}.dll" | ||
VALUE "ProductName", "Digital Clock" | ||
VALUE "ProductVersion", "${CLOCK_VERSION}" | ||
} | ||
} | ||
|
||
BLOCK "VarFileInfo" | ||
{ | ||
VALUE "Translation", 0x0409, 0x04E4 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Nick Korotysh <[email protected]> | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
#include "spectrum_clock_plugin.hpp" | ||
|
||
void SpectrumClockPlugin::initSharedSettings(const SharedSettings& s) | ||
{ | ||
_last_texture = s[cs::Texture].value<QBrush>(); | ||
} | ||
|
||
void SpectrumClockPlugin::init() | ||
{ | ||
_is_active = true; | ||
tick(); | ||
} | ||
|
||
void SpectrumClockPlugin::shutdown() | ||
{ | ||
_is_active = false; | ||
emit optionChanged(cs::Texture, _last_texture); | ||
} | ||
|
||
void SpectrumClockPlugin::tick() | ||
{ | ||
if (!_is_active) return; | ||
|
||
auto color = QColor::fromHsv(_hue, 255, 255); | ||
|
||
if (++_hue == 360) _hue = 0; | ||
|
||
emit optionChanged(cs::Texture, color); | ||
} | ||
|
||
void SpectrumClockPlugin::onOptionChanged(clock_settings::SharedConfigKeys opt, const QVariant& val) | ||
{ | ||
Q_UNUSED(opt); | ||
Q_UNUSED(val); | ||
} | ||
|
||
|
||
std::unique_ptr<ClockPluginBase> SpectrumClockPluginFactory::create() const | ||
{ | ||
return std::make_unique<SpectrumClockPlugin>(); | ||
} | ||
|
||
QString SpectrumClockPluginFactory::description() const | ||
{ | ||
return tr("Changes clock color during time."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Nick Korotysh <[email protected]> | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "clock_plugin.hpp" | ||
|
||
#include <QBrush> | ||
|
||
class SpectrumClockPlugin : public SettingsPlugin | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
void initSharedSettings(const SharedSettings& s) override; | ||
|
||
public slots: | ||
void init() override; | ||
void shutdown() override; | ||
|
||
void tick() override; | ||
|
||
void onOptionChanged(cs::SharedConfigKeys opt, const QVariant& val) override; | ||
|
||
private: | ||
bool _is_active = false; | ||
QBrush _last_texture; | ||
int _hue = 0; | ||
}; | ||
|
||
|
||
class SpectrumClockPluginFactory : public ClockPluginFactory | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID ClockPluginFactory_iid FILE "spectrum_clock.json") | ||
Q_INTERFACES(ClockPluginFactory) | ||
|
||
public: | ||
std::unique_ptr<ClockPluginBase> create() const override; | ||
|
||
QString title() const override { return tr("\"Spectrum clock\""); } | ||
QString description() const override; | ||
|
||
bool perClockInstance() const override { return true; } | ||
}; |