Commit 5528ae9e authored by JanKusanagi's avatar JanKusanagi

Moved character picker functionality to Composer

parent c96a10ad
......@@ -147,6 +147,15 @@ Composer::Composer(GlobalObject *globalObject, bool forPublisher,
+ tr("Text Formatting Options"));
#ifdef HAVE_KCHARSELECT
m_charPickerButton = new QToolButton(this);
m_charPickerButton->setIcon(QIcon::fromTheme("face-smile",
QIcon(":/images/button-symbols.png")));
connect(m_charPickerButton, &QToolButton::clicked,
this, &Composer::showCharacterPicker);
#endif
// Extra action for the context menu, paste as plaintext
m_pastePlaintextAction = new QAction(QIcon::fromTheme("edit-paste"),
tr("Paste Text Without Formatting"),
......@@ -288,6 +297,12 @@ QPushButton *Composer::getToolsButton()
return m_toolsButton;
}
#ifdef HAVE_KCHARSELECT
QToolButton *Composer::getCharPickerButton()
{
return m_charPickerButton;
}
#endif
/*
* Enable or disable the Ctrl+Shift+V action to paste without format
......@@ -1006,6 +1021,19 @@ void Composer::insertSymbol(QAction *action)
}
#ifdef HAVE_KCHARSELECT
void Composer::showCharacterPicker()
{
// Make focus default to the composer when the character picker is closed
this->setFocus();
m_characterPicker = new CharacterPicker(this);
connect(m_characterPicker, &CharacterPicker::characterSelected,
this, &Composer::insertHtml);
m_characterPicker->show();
}
#endif
void Composer::pasteAsPlaintext()
{
......
......@@ -25,6 +25,7 @@
#include <QFocusEvent>
#include <QLabel>
#include <QPushButton>
#include <QToolButton>
#include <QMenu>
#include <QInputDialog>
#include <QMessageBox>
......@@ -48,6 +49,10 @@
#include "globalobject.h"
#include "mischelpers.h"
#ifdef HAVE_KCHARSELECT
#include "characterpicker.h"
#endif
class Composer : public QTextEdit
{
......@@ -64,6 +69,9 @@ public:
void hideInfoMessage();
QPushButton *getToolsButton();
#ifdef HAVE_KCHARSELECT
QToolButton *getCharPickerButton();
#endif
void setPlainPasteEnabled(bool state);
......@@ -100,6 +108,10 @@ public slots:
void insertSymbol(QAction *action);
#ifdef HAVE_KCHARSELECT
void showCharacterPicker();
#endif
void pasteAsPlaintext();
void insertCompletedNick(QModelIndex nickData);
......@@ -120,6 +132,11 @@ private:
QMenu *m_toolsMenu;
QMenu *m_symbolsMenu;
#ifdef HAVE_KCHARSELECT
QToolButton *m_charPickerButton;
CharacterPicker *m_characterPicker;
#endif
QAction *m_pastePlaintextAction;
QMenu *m_customContextMenu;
......
......@@ -155,11 +155,7 @@ Publisher::Publisher(PumpController *pumpController,
#ifdef HAVE_KCHARSELECT
m_charPickerButton = new QToolButton(this);
m_charPickerButton->setIcon(QIcon::fromTheme("face-smile",
QIcon(":/images/button-symbols.png")));
connect(m_charPickerButton, &QPushButton::clicked,
this, &Publisher::showCharacterPicker);
m_charPickerButton = m_composerBox->getCharPickerButton();
#endif
// Add formatting button exported from Composer
......@@ -1703,16 +1699,3 @@ void Publisher::updateCharacterCounter()
int charCount = m_composerBox->textCursor().document()->characterCount() - 1;
m_charCounterLabel->setText(QLocale::system().toString(charCount));
}
#ifdef HAVE_KCHARSELECT
void Publisher::showCharacterPicker()
{
// Make focus default to the composer when the character picker is closed
m_composerBox->setFocus();
m_characterPicker = new CharacterPicker(this);
connect(m_characterPicker, &CharacterPicker::characterSelected,
m_composerBox, &Composer::insertHtml);
m_characterPicker->show();
}
#endif
......@@ -42,10 +42,6 @@
#include "audienceselector.h"
#include "draftsmanager.h"
#ifdef HAVE_KCHARSELECT
#include "characterpicker.h"
#endif
class Publisher : public QWidget
{
......@@ -54,7 +50,7 @@ class Publisher : public QWidget
public:
explicit Publisher(PumpController *pumpController,
GlobalObject *globalObject,
QWidget *parent = 0);
QWidget *parent = nullptr);
~Publisher();
void syncFromConfig();
......@@ -129,10 +125,6 @@ public slots:
void updateCharacterCounter();
#ifdef HAVE_KCHARSELECT
void showCharacterPicker();
#endif
private:
QVBoxLayout *m_mainLayout;
......@@ -152,7 +144,6 @@ private:
#ifdef HAVE_KCHARSELECT
QToolButton *m_charPickerButton;
CharacterPicker *m_characterPicker;
#endif
QPushButton *m_toolsButton;
......
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