Allow libraries use their own langpacks.
This commit is contained in:
parent
f762cc8b87
commit
0e51c8ab76
3 changed files with 99 additions and 0 deletions
|
|
@ -130,6 +130,8 @@
|
||||||
<(src_loc)/ui/main_queue_processor.cpp
|
<(src_loc)/ui/main_queue_processor.cpp
|
||||||
<(src_loc)/ui/main_queue_processor.h
|
<(src_loc)/ui/main_queue_processor.h
|
||||||
<(src_loc)/ui/painter.h
|
<(src_loc)/ui/painter.h
|
||||||
|
<(src_loc)/ui/ph.cpp
|
||||||
|
<(src_loc)/ui/ph.h
|
||||||
<(src_loc)/ui/rect_part.h
|
<(src_loc)/ui/rect_part.h
|
||||||
<(src_loc)/ui/round_rect.cpp
|
<(src_loc)/ui/round_rect.cpp
|
||||||
<(src_loc)/ui/round_rect.h
|
<(src_loc)/ui/round_rect.h
|
||||||
|
|
|
||||||
37
ui/ph.cpp
Normal file
37
ui/ph.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
// This file is part of Desktop App Toolkit,
|
||||||
|
// a set of libraries for developing nice desktop applications.
|
||||||
|
//
|
||||||
|
// For license and copyright information please follow this link:
|
||||||
|
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||||
|
//
|
||||||
|
#include "ui/ph.h"
|
||||||
|
|
||||||
|
namespace ph {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
int &PhraseCounter() {
|
||||||
|
static auto result = 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
phrase::phrase(const QString &initial) : value(initial) {
|
||||||
|
if (auto &counter = PhraseCounter()) {
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
now_t start_phrase_count() {
|
||||||
|
PhraseCounter() = 1;
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
|
||||||
|
now_t check_phrase_count(int count) {
|
||||||
|
Expects(PhraseCounter() == count + 1);
|
||||||
|
|
||||||
|
PhraseCounter() = 0;
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ph
|
||||||
60
ui/ph.h
Normal file
60
ui/ph.h
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
// This file is part of Desktop App Toolkit,
|
||||||
|
// a set of libraries for developing nice desktop applications.
|
||||||
|
//
|
||||||
|
// For license and copyright information please follow this link:
|
||||||
|
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ph {
|
||||||
|
|
||||||
|
struct now_t {
|
||||||
|
};
|
||||||
|
|
||||||
|
inline constexpr auto now = now_t();
|
||||||
|
|
||||||
|
struct I {
|
||||||
|
QString operator()(const QString &value) const { return value; };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename P>
|
||||||
|
using Result = decltype(std::declval<P>()(QString()));
|
||||||
|
|
||||||
|
struct phrase {
|
||||||
|
phrase(const QString &initial);
|
||||||
|
template <std::size_t Size>
|
||||||
|
phrase(const char (&initial)[Size])
|
||||||
|
: phrase(QString::fromUtf8(initial, Size - 1)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P = I, typename = Result<P>>
|
||||||
|
Result<P> operator()(ph::now_t, P p = P()) const {
|
||||||
|
return p(value.current());
|
||||||
|
};
|
||||||
|
template <typename P = I, typename = Result<P>>
|
||||||
|
rpl::producer<Result<P>> operator()(P p = P()) const {
|
||||||
|
return value.value() | rpl::map(p);
|
||||||
|
};
|
||||||
|
|
||||||
|
rpl::variable<QString> value;
|
||||||
|
};
|
||||||
|
|
||||||
|
now_t start_phrase_count();
|
||||||
|
now_t check_phrase_count(int count);
|
||||||
|
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
template <int Count>
|
||||||
|
using phrase_value_array = std::array<
|
||||||
|
std::pair<not_null<phrase*>, rpl::producer<QString>>,
|
||||||
|
Count>;
|
||||||
|
|
||||||
|
template <int Count>
|
||||||
|
void set_values(phrase_value_array<Count> &&data) {
|
||||||
|
for (auto &[single, value] : data) {
|
||||||
|
single->value = std::move(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
} // namespace ph
|
||||||
Loading…
Add table
Reference in a new issue