Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog -> Widget, Use signals instead of timer, and code cleanup (#1) #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include(helpers)
add_library(${CMAKE_PROJECT_NAME} MODULE src/datetime.cpp src/datetime.h src/text.cpp src/text.h)

find_package(libobs REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs OBS::libobs gdiplus)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs gdiplus)

if(ENABLE_FRONTEND_API)
find_package(obs-frontend-api REQUIRED)
Expand All @@ -35,8 +35,15 @@ if(ENABLE_QT)
AUTORCC ON)
endif()

target_sources(${CMAKE_PROJECT_NAME} PRIVATE forms/obs-text-mustache-definitions.ui)
target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-main.c src/variables.cpp src/obs-text.cpp
src/obs-text-mustache-definitions.cpp)
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
src/plugin-main.cpp
src/variables.cpp
src/obs-text.cpp
src/obs-text-mustache-definitions.cpp
src/variables.hpp
src/obs-text.hpp
src/obs-text-mustache-definitions.hpp
forms/OBSTextMustacheDefinitions.ui
)

set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
27 changes: 21 additions & 6 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 3,
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 22,
"minor": 25,
"patch": 0
},
"configurePresets": [
Expand All @@ -26,7 +26,7 @@
"rhs": "Darwin"
},
"generator": "Xcode",
"warnings": {"dev": true, "deprecated": true},
"warnings": { "dev": true, "deprecated": true },
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_OSX_DEPLOYMENT_TARGET": "11.0",
Expand Down Expand Up @@ -57,7 +57,7 @@
},
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"warnings": {"dev": true, "deprecated": true},
"warnings": { "dev": true, "deprecated": true },
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_SYSTEM_VERSION": "10.0.18363.657"
Expand All @@ -84,7 +84,7 @@
"rhs": "Linux"
},
"generator": "Ninja",
"warnings": {"dev": true, "deprecated": true},
"warnings": { "dev": true, "deprecated": true },
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
Expand Down Expand Up @@ -112,7 +112,7 @@
"rhs": "Linux"
},
"generator": "Ninja",
"warnings": {"dev": true, "deprecated": true},
"warnings": { "dev": true, "deprecated": true },
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
Expand Down Expand Up @@ -186,5 +186,20 @@
"description": "Linux CI build for aarch64",
"configuration": "RelWithDebInfo"
}
],
"workflowPresets": [
{
"name": "windows-x64",
"steps": [
{
"type": "configure",
"name": "windows-x64"
},
{
"type": "build",
"name": "windows-x64"
}
]
}
]
}
1 change: 1 addition & 0 deletions data/locale/en-US.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
OBSTextMustacheDefinitions="Text Template Values"
TextGDIPlusDefinitions="Edit Text (GDI+) With Templates Variables"
TextGDIPlus="Text (GDI+) With Templates"
Font="Font"
Expand Down
42 changes: 42 additions & 0 deletions forms/OBSTextMustacheDefinitions.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OBSTextMustacheDefinitions</class>
<widget class="QWidget" name="OBSTextMustacheDefinitions">
<layout class="QVBoxLayout" name="baseLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="vScrollArea">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QFrame" name="formWidget">
<layout class="QFormLayout" name="gridLayout" rowstretch="0">
<property name="margin">
<number>8</number>
</property>
<property name="spacing">
<number>5</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
52 changes: 0 additions & 52 deletions forms/obs-text-mustache-definitions.ui

This file was deleted.

52 changes: 16 additions & 36 deletions src/datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,74 +10,54 @@
#include "datetime.h"
using namespace std;

wstring getFormattedTime(const struct tm *const localTime, const wchar_t *format) {
std::wstringstream wss;
wss << std::put_time(localTime, format);

return wss.str();
}

wstring getCurrentMonthName(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%B");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%B");
}

wstring getCurrentYear(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%EY");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%EY");
}

wstring getCurrentDay(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%e");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%e");
}

wstring getCurrentDayOfWeek(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%A");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%A");
}

wstring getCurrent24Hour(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%OH");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%OH");
}

wstring getCurrent12Hour(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%OI");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%OI");
}

wstring getCurrentMinute(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%M");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%M");
}

wstring getCurrentSecond(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%S");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%S");
}

wstring getCurrentAmPm(const struct tm *const localTime)
{
std::ostringstream oss;
oss << std::put_time(localTime, "%p");

return QString::fromStdString(oss.str()).toStdWString();
return getFormattedTime(localTime, L"%p");
}
2 changes: 2 additions & 0 deletions src/datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef DATETIME_H
#define DATETIME_H

std::wstring getFormattedTime(const tm *localTime, const char *format);

std::wstring getCurrentMonthName(const tm *localTime);

std::wstring getCurrentYear(const tm *localTime);
Expand Down
Loading
Loading