Optional PC key blocks: function row, navigation, numeric keypad
- Template sections placed above or to the right of the typing keys; the user picks any mix in settings, typing keys included - keysym keys send XKB keysyms on press, optionally repeating - Geometry lays blocks side by side with one key unit; stretch keys are resolved at layout time so composed blocks line up - Toggling a block resizes the window so keys keep their size Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#include "Settings.h"
|
||||
|
||||
#include "layout/Layout.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
namespace {
|
||||
constexpr auto AutoCapitalizeKey = "typing/autoCapitalize";
|
||||
constexpr auto DoubleSpacePeriodKey = "typing/doubleSpacePeriod";
|
||||
constexpr auto VisibleSectionsKey = "layout/visibleSections";
|
||||
}
|
||||
|
||||
Settings::Settings(QObject *parent)
|
||||
@@ -14,6 +17,23 @@ Settings::Settings(QObject *parent)
|
||||
const TypingOptions defaults;
|
||||
m_typing.autoCapitalize = store.value(AutoCapitalizeKey, defaults.autoCapitalize).toBool();
|
||||
m_typing.doubleSpacePeriod = store.value(DoubleSpacePeriodKey, defaults.doubleSpacePeriod).toBool();
|
||||
m_visibleSections = store.value(VisibleSectionsKey, QStringList{MainSectionId}).toStringList();
|
||||
if (m_visibleSections.isEmpty())
|
||||
m_visibleSections = {MainSectionId};
|
||||
}
|
||||
|
||||
void Settings::setSectionVisible(const QString &id, bool visible)
|
||||
{
|
||||
QStringList sections = m_visibleSections;
|
||||
if (visible && !sections.contains(id))
|
||||
sections.append(id);
|
||||
else if (!visible)
|
||||
sections.removeAll(id);
|
||||
if (sections == m_visibleSections || sections.isEmpty())
|
||||
return;
|
||||
m_visibleSections = sections;
|
||||
QSettings().setValue(VisibleSectionsKey, m_visibleSections);
|
||||
Q_EMIT visibleSectionsChanged();
|
||||
}
|
||||
|
||||
void Settings::setAutoCapitalize(bool enabled)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "input/TypingOptions.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QtQml/qqmlregistration.h>
|
||||
|
||||
// User preferences, persisted with QSettings (~/.config/sloposk/sloposk.conf)
|
||||
@@ -14,6 +15,8 @@ class Settings : public QObject
|
||||
QML_UNCREATABLE("Created in C++")
|
||||
Q_PROPERTY(bool autoCapitalize READ autoCapitalize WRITE setAutoCapitalize NOTIFY typingOptionsChanged)
|
||||
Q_PROPERTY(bool doubleSpacePeriod READ doubleSpacePeriod WRITE setDoubleSpacePeriod NOTIFY typingOptionsChanged)
|
||||
// Which key blocks are shown: "main" (the typing keys) and template section ids.
|
||||
Q_PROPERTY(QStringList visibleSections READ visibleSections NOTIFY visibleSectionsChanged)
|
||||
|
||||
public:
|
||||
explicit Settings(QObject *parent = nullptr);
|
||||
@@ -25,11 +28,17 @@ public:
|
||||
bool doubleSpacePeriod() const { return m_typing.doubleSpacePeriod; }
|
||||
void setDoubleSpacePeriod(bool enabled);
|
||||
|
||||
QStringList visibleSections() const { return m_visibleSections; }
|
||||
// Hiding the last visible section is refused: something must stay on screen.
|
||||
Q_INVOKABLE void setSectionVisible(const QString &id, bool visible);
|
||||
|
||||
Q_SIGNALS:
|
||||
void typingOptionsChanged();
|
||||
void visibleSectionsChanged();
|
||||
|
||||
private:
|
||||
void setTypingOptions(const TypingOptions &options);
|
||||
|
||||
TypingOptions m_typing;
|
||||
QStringList m_visibleSections;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user