Commit 509349d6 authored by JanKusanagi's avatar JanKusanagi

Actually store and restore list of recently used symbols

parent 0de836a6
......@@ -86,19 +86,30 @@ CharacterPicker::CharacterPicker(QWidget *parent) : QWidget(parent)
m_makeBigCheckbox->setChecked(settings.value("CharacterPicker/bigSymbols")
.toBool());
uint codepoint = 128526;
const QVariantList codepoints = settings.value("CharacterPicker/recentCodepoints")
.toList();
m_recentLayout = new QHBoxLayout();
for (int counter = 0; counter < 8; ++counter)
{
QToolButton *recentButton = new QToolButton(this);
recentButton->setFont(charFont);
recentButton->setText(QString::fromUcs4(&codepoint, 1));
connect(recentButton, &QToolButton::clicked,
this, &CharacterPicker::onRecentButtonClicked);
if (counter < codepoints.size())
{
uint codepoint = codepoints.at(counter).toUInt();
recentButton->setText(QString::fromUcs4(&codepoint, 1));
connect(recentButton, &QToolButton::clicked,
this, &CharacterPicker::onRecentButtonClicked);
m_recentCodepoints.append(codepoint);
}
else
{
recentButton->setText("-");
recentButton->setDisabled(true);
}
m_recentButtons.append(recentButton);
m_recentLayout->addWidget(recentButton);
++codepoint;///////////tmp
}
......@@ -174,6 +185,25 @@ void CharacterPicker::onCodePointSelected()
}
emit characterSelected(htmlToInsert);
// Update list of recently used...
if (m_recentCodepoints.isEmpty())
{
m_recentCodepoints.append(codepoint);
}
else
{ // ...unless already present
if (!m_recentCodepoints.contains(codepoint))
{
if (m_recentCodepoints.size() == 8)
{
m_recentCodepoints.takeFirst();
}
m_recentCodepoints.append(codepoint);
}
}
qDebug() << "CharacterPicker::onCodePointChanged()" << codepoint;
this->close();
......@@ -218,6 +248,7 @@ void CharacterPicker::closeEvent(QCloseEvent *event)
settings.setValue("CharacterPicker/charPickerWindowSize", this->size());
settings.setValue("CharacterPicker/charPickerFontSize", m_fontSize);
settings.setValue("CharacterPicker/bigSymbols", m_makeBigCheckbox->isChecked());
settings.setValue("CharacterPicker/recentCodepoints", m_recentCodepoints);
this->deleteLater();
......
......@@ -68,6 +68,7 @@ private:
QList<QToolButton *> m_recentButtons;
int m_fontSize;
QVariantList m_recentCodepoints;
QAction *m_closeAction;
QDialogButtonBox *m_buttonBox;
......
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