Commit 0de836a6 authored by JanKusanagi's avatar JanKusanagi

Basic buttons for recently used symbols

parent 9c21ac93
......@@ -80,10 +80,27 @@ CharacterPicker::CharacterPicker(QWidget *parent) : QWidget(parent)
this, &CharacterPicker::onCodePointSelected);
}
// Line with options and buttons for recently used symbols
m_makeBigCheckbox = new QCheckBox(tr("Insert in big size"), this);
m_makeBigCheckbox->setChecked(settings.value("CharacterPicker/bigSymbols")
.toBool());
uint codepoint = 128526;
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);
m_recentButtons.append(recentButton);
m_recentLayout->addWidget(recentButton);
++codepoint;///////////tmp
}
// Insert / Cancel buttons
m_insertButton = new QPushButton(QIcon::fromTheme("insert-image",
......@@ -106,6 +123,8 @@ CharacterPicker::CharacterPicker(QWidget *parent) : QWidget(parent)
m_mainLayout = new QVBoxLayout();
m_mainLayout->addLayout(m_recentLayout);
m_mainLayout->addSpacing(8);
m_mainLayout->addWidget(m_charSelect);
m_mainLayout->addWidget(m_makeBigCheckbox);
m_mainLayout->addWidget(m_buttonBox);
......@@ -161,6 +180,33 @@ void CharacterPicker::onCodePointSelected()
}
void CharacterPicker::onRecentButtonClicked()
{
if (sender() == 0) // Used inside the slot, it _should_ be valid
{
return; // ...but something's wrong, abort
}
// Cast sender() QObject pointer to the original QToolButton, to get its text
QToolButton *recentButton = qobject_cast<QToolButton *>(sender());
QString htmlToInsert = recentButton->text();
if (m_makeBigCheckbox->isChecked())
{
htmlToInsert.prepend(QStringLiteral("<h2>"));
htmlToInsert.append(QStringLiteral("</h2> "));
}
else
{
htmlToInsert.append(QStringLiteral(" "));
}
emit characterSelected(htmlToInsert);
qDebug() << "CharacterPicker::onRecentButtonClicked()" << htmlToInsert;
this->close();
}
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////// PROTECTED ////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
......
......@@ -23,9 +23,11 @@
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <KCharSelect>
#include <QTableView>
#include <QPushButton>
#include <QToolButton>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QAction>
......@@ -49,6 +51,7 @@ signals:
public slots:
void onCodePointSelected();
void onRecentButtonClicked();
protected:
......@@ -60,8 +63,9 @@ private:
KCharSelect *m_charSelect;
QTableView *m_charSelectTableView;
QHBoxLayout *m_recentLayout;
QCheckBox *m_makeBigCheckbox;
QList<QToolButton *> m_recentButtons;
int m_fontSize;
......
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