X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Funicodedialog.h;h=83065c09f8ee5d13805f144ff8b554270f746e1e;hb=c3302003093710ee247ad84c0fe2ef3c579d417f;hp=52abd3f7c5857dbd432dc52c5e574c234918fc57;hpb=c61a67584434b6712359f973c7767c3a9242074e;p=kdenlive diff --git a/src/unicodedialog.h b/src/unicodedialog.h index 52abd3f7..83065c09 100644 --- a/src/unicodedialog.h +++ b/src/unicodedialog.h @@ -10,46 +10,91 @@ #ifndef UNICODEDIALOG_H #define UNICODEDIALOG_H -#include "ui_unicodedialog_ui.h" +#include "ui_unicodewidget_ui.h" +#include -class UnicodeDialog : public QDialog, public Ui::UnicodeDialog_UI +class UnicodeWidget; +class UnicodeDialog : public KDialog { - Q_OBJECT - + Q_OBJECT public: - /** \brief The input method for the dialog. Atm only InputHex supported. */ - enum InputMethod { InputHex, InputDec }; - - UnicodeDialog(InputMethod inputMeth); - ~UnicodeDialog(); - - /** \brief Returns infos about a unicode number. Extendable/improvable ;) */ - QString unicodeInfo(QString unicode_number); + /** \brief The input method for the dialog. Atm only InputHex supported. */ + enum InputMethod { InputHex, InputDec }; + explicit UnicodeDialog(InputMethod inputMeth, QWidget *parent = 0); + ~UnicodeDialog(); + +private Q_SLOTS: + void slotAccept(); + +Q_SIGNALS: + /** \brief Contains the selected unicode character; emitted when Enter is pressed. */ + void charSelected(const QString&); + +private: + UnicodeWidget *mUnicodeWidget; +}; + +class UnicodeWidget : public QWidget, public Ui::UnicodeWidget_UI +{ + Q_OBJECT +public: + + explicit UnicodeWidget(UnicodeDialog::InputMethod inputMeth, QWidget *parent = 0); + ~UnicodeWidget(); + + /** \brief Returns infos about a unicode number. Extendable/improvable ;) */ + QString unicodeInfo(const QString &unicode); + + void showLastUnicode(); + +protected: + void wheelEvent(QWheelEvent * event); private: - Ui::UnicodeDialog_UI m_view; - - /** Selected input method */ - InputMethod inputMethod; - - /** \brief Validates text and removes all invalid characters (non-hex e.g.) */ - QString validateText(QString text); - /** \brief Removes all leading zeros */ - QString trimmedUnicodeNumber(QString text); - /** \brief Checks whether the given string is a control character */ - bool controlCharacter(QString text); - - int lastCursorPos; - QString lastUnicodeNumber; + Ui::UnicodeWidget_UI m_view; + + enum Direction { Forward, Backward }; + + /** Selected input method */ + UnicodeDialog::InputMethod inputMethod; + + /** \brief Validates text and removes all invalid characters (non-hex e.g.) */ + QString validateText(const QString &text); + /** \brief Removes all leading zeros */ + QString trimmedUnicodeNumber(QString text); + /** \brief Checks whether the given string is a control character */ + bool controlCharacter(const QString& text); + /** \brief Checks whether the given uint is a control character */ + bool controlCharacter(uint value); + + /** \brief Returns the next available unicode. */ + QString nextUnicode(const QString &text, Direction direction); + + /** \brief Paints previous and next characters around current char */ + void updateOverviewChars(uint unicode); + void clearOverviewChars(); + + int m_lastCursorPos; + QString m_lastUnicodeNumber; + + /** \brief Reads the last used unicode number from the config file. */ + void readChoices(); + /** \brief Writes the last used unicode number into the config file. */ + void writeChoices(); signals: - /** \brief Contains the selected unicode character; emitted when Enter is pressed. */ - void charSelected(const QString&); + /** \brief Contains the selected unicode character; emitted when Enter is pressed. */ + void charSelected(const QString&); -private slots: - void slotTextChanged(QString text); - void slotReturnPressed(); +public slots: + void slotReturnPressed(); +private slots: + void slotTextChanged(const QString &text); + void slotNextUnicode(); + void slotPrevUnicode(); }; + + #endif