Commit 203f18e6 authored by JanKusanagi's avatar JanKusanagi

Better way to allow selecting any character with single click (thx pepo!)

It depends on internal implementation of KCharSelect, but selecting via
double click or Enter would still work if that changed
parent 7b0c02ca
......@@ -53,12 +53,28 @@ CharacterPicker::CharacterPicker(QWidget *parent) : QWidget(parent)
24).toInt());
m_charSelect->setCurrentFont(charFont);
connect(m_charSelect, &KCharSelect::currentCodePointChanged,
this, &CharacterPicker::onCodePointChanged);
// To allow selecting the first symbol on the list, preselected...
/*
* Using KCharSelect::currentCodePointChanged has some drawbacks, mainly
* that it's emited whenever the Unicode block is changed or a search is
* performed. Also it doesn't allow selectint the symbol that's already
* selected.
*
* KCharSelect::codePointSelected works much better, but requires
* double-clicking the symbol, or pressing Enter.
*
* In addition to that, find the QTableView object used inside KCharSelect
* and use its clicked() signal.
*
*/
connect(m_charSelect, &KCharSelect::codePointSelected,
this, &CharacterPicker::onCodePointChanged); // FIXME TMP
this, &CharacterPicker::onCodePointChanged);
m_charSelectTableView = m_charSelect->findChild<QTableView *>();
if (m_charSelectTableView)
{
connect(m_charSelectTableView, &QTableView::clicked,
this, &CharacterPicker::onCodePointChanged);
}
m_makeBigCheckbox = new QCheckBox(tr("Insert in big size"), this);
m_makeBigCheckbox->setChecked(settings.value("CharacterPicker/bigSymbols")
......@@ -119,19 +135,10 @@ CharacterPicker::~CharacterPicker()
//////////////////////////////////////////////////////////////////////////////
void CharacterPicker::onCodePointChanged(uint codepoint)
void CharacterPicker::onCodePointChanged()
{
if (m_charSelect->displayedCodePoints() != m_displayedCodePoints)
{
m_displayedCodePoints = m_charSelect->displayedCodePoints();
return;
}
const uint codepoint = m_charSelect->currentCodePoint();
if (m_charSelect->currentFont().pointSize() != m_fontSize)
{
m_fontSize = m_charSelect->currentFont().pointSize();
return;
}
QString htmlToInsert = QString("&#%1;").arg(codepoint);
if (m_makeBigCheckbox->isChecked())
......
......@@ -24,6 +24,7 @@
#include <QWidget>
#include <QVBoxLayout>
#include <KCharSelect>
#include <QTableView>
#include <QPushButton>
#include <QCheckBox>
#include <QDialogButtonBox>
......@@ -47,7 +48,7 @@ signals:
public slots:
void onCodePointChanged(uint codepoint);
void onCodePointChanged();
protected:
......@@ -57,6 +58,7 @@ protected:
private:
QVBoxLayout *m_mainLayout;
KCharSelect *m_charSelect;
QTableView *m_charSelectTableView;
QCheckBox *m_makeBigCheckbox;
......
......@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
{
QApplication dianaraApp(argc, argv);
dianaraApp.setApplicationName(QStringLiteral("Dianara"));
dianaraApp.setApplicationVersion(QStringLiteral("1.4.3-dev+11"));
dianaraApp.setApplicationVersion(QStringLiteral("1.4.3-dev+12"));
dianaraApp.setOrganizationName(QStringLiteral("JanCoding"));
dianaraApp.setOrganizationDomain(QStringLiteral("jancoding.wordpress.com"));
......
Markdown is supported
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