Commit 25495537 authored by Rodney's avatar Rodney
Browse files

Add more documentation.

parent 4784fdbd
......@@ -24,13 +24,17 @@
namespace ergo
{
//! @cond
Clipboard::Clipboard(QObject *parent):
QObject(parent)
{
m_clipboard = QGuiApplication::clipboard();
}
//! @endcond
/*! Post some data to the system clipboard
*
*/
void Clipboard::pushData(const QVariant& data)
{
if (!data.isValid()) {
......
......@@ -28,7 +28,9 @@ namespace ergo
Q_OBJECT
public:
//! @cond
explicit Clipboard(QObject *parent = 0);
//! @endcond
Q_INVOKABLE void pushData(const QVariant& data);
......
......@@ -25,17 +25,33 @@
namespace ergo
{
//! @cond
Gettext::Gettext(QObject *parent):
QObject(parent)
{
setlocale(LC_ALL, "");
}
//! @endcond
/*! Get the translated version of a string
*
* @param text The untranslated version of a string to be translated
* @return The translated version of text
*/
QString Gettext::tr(const QString& text) const
{
return QString::fromUtf8(gettext(text.toUtf8()));
}
/*! Get the translated version of a possibly pluralized string
*
* @param singular The untranslated version of the string to be translated,
* in singular form
* @param plural The untranslated version of the string to be translated,
* in plural form
* @param n The value for determining the correct singular or plural form of
* the translated version of the string
* @return The translated version of singular or plural
*/
QString Gettext::tr(const QString& singular,
const QString& plural,
int n) const
......@@ -43,6 +59,7 @@ QString Gettext::tr(const QString& singular,
return QString::fromUtf8(ngettext(singular.toUtf8(), plural.toUtf8(), n));
}
//!@cond
QString Gettext::domain() const
{
return m_domain;
......@@ -74,5 +91,6 @@ void Gettext::setDomain(const QString& domain)
bindtextdomain(m_domain.toUtf8(), localePath.toUtf8());
}
//! @endcond
} // namespace ergo
......@@ -22,23 +22,35 @@
namespace ergo
{
/*! Utilities for translating QML interfaces using gettext
*
* Gettext provides a component for setting the translation domain of
* the application from QML, and the `i18n` context property, which
* provides access to the methods for internationalizing an application.
*
*/
class Gettext: public QObject
{
Q_OBJECT
/*! The translation domain of the application */
Q_PROPERTY(QString domain
READ domain
WRITE setDomain)
public:
//! @cond
explicit Gettext(QObject *parent = 0);
//! @endcond
Q_INVOKABLE QString tr(const QString& text) const;
Q_INVOKABLE QString tr(const QString& singular,
const QString& plural,
int n) const;
//! @cond
QString domain() const;
void setDomain(const QString& domain);
//! @endcond
private:
Q_DISABLE_COPY(Gettext);
......
......@@ -31,6 +31,12 @@ class ErgoPlugin: public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
explicit ErgoPlugin(QObject *parent=0):
QQmlExtensionPlugin(parent)
{
setlocale(LC_ALL, "");
}
void initializeEngine(QQmlEngine *engine, const char *uri) override
{
// FIXME: Need a better way to do this.
......
......@@ -24,12 +24,23 @@
namespace ergo
{
//! @cond
Units::Units(QObject *parent):
QObject(parent)
{
}
//! @endcond
/*! A display-independent pixel calculator
*
* Calculates an appropriate size in pixels, based on the input value in
* pixels for a 160 DPI screen, and the physical DPI of the creen currently
* being displayed on.
*
* @param value The standard number of pixels used on a 160 DPI screen.
*
* @return The nearest number of pixels, scaled from a 160 DPI base.
*/
int Units::dp(double value) const
{
auto screen = QGuiApplication::primaryScreen();
......
......@@ -22,12 +22,35 @@
namespace ergo
{
/*! Utilities for handling units of screen measurement
*
* Units provides provides device-independent pixel size calculations, to
* aid in the development of application interfaces which scale correctly
* across a wide range of screen configurations.
*
* The Units class is not instantiable within an application directly, but
* must be used through the singleton `units` context property.
*
* \code
* import QtQuick 2.7
* import QtQuick.Controls 2.2
* import Ergo 0.0
*
* Page {
* width: units.dp(640)
* height: units.dp(480)
* }
* \endcode
*
*/
class Units: public QObject
{
Q_OBJECT
public:
//! @cond
explicit Units(QObject *parent = 0);
//! @endcond
Q_INVOKABLE int dp(double value) const;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment