]> git.sesse.net Git - kdenlive/blob - src/unicodedialog.h
const'ref.
[kdenlive] / src / unicodedialog.h
1 /***************************************************************************
2  *   Copyright (C) 2008 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  ***************************************************************************/
9
10 #ifndef UNICODEDIALOG_H
11 #define UNICODEDIALOG_H
12
13 #include "ui_unicodedialog_ui.h"
14
15 class UnicodeDialog : public QDialog, public Ui::UnicodeDialog_UI
16 {
17     Q_OBJECT
18
19 public:
20     /** \brief The input method for the dialog. Atm only InputHex supported. */
21     enum InputMethod { InputHex, InputDec };
22
23     UnicodeDialog(InputMethod inputMeth);
24     ~UnicodeDialog();
25
26     /** \brief Returns infos about a unicode number. Extendable/improvable ;) */
27     QString unicodeInfo(const QString &unicode);
28
29     void showLastUnicode();
30
31 protected:
32     virtual void wheelEvent(QWheelEvent * event);
33
34 public slots:
35     /** \brief Override QDialog::exec() to assure the focus being on the unicode input field */
36     int exec();
37
38 private:
39     Ui::UnicodeDialog_UI m_view;
40
41     enum Direction { Forward, Backward };
42
43     /** Selected input method */
44     InputMethod inputMethod;
45
46     /** \brief Validates text and removes all invalid characters (non-hex e.g.) */
47     QString validateText(const QString &text);
48     /** \brief Removes all leading zeros */
49     QString trimmedUnicodeNumber(QString text);
50     /** \brief Checks whether the given string is a control character */
51     bool controlCharacter(const QString& text);
52     /** \brief Checks whether the given uint is a control character */
53     bool controlCharacter(uint value);
54
55     /** \brief Returns the next available unicode. */
56     QString nextUnicode(const QString &text, Direction direction);
57
58     /** \brief Paints previous and next characters around current char */
59     void updateOverviewChars(uint unicode);
60     void clearOverviewChars();
61
62     int m_lastCursorPos;
63     QString m_lastUnicodeNumber;
64
65     /** \brief Reads the last used unicode number from the config file. */
66     void readChoices();
67     /** \brief Writes the last used unicode number into the config file. */
68     void writeChoices();
69
70 signals:
71     /** \brief Contains the selected unicode character; emitted when Enter is pressed. */
72     void charSelected(const QString&);
73
74 private slots:
75     void slotTextChanged(const QString &text);
76     void slotReturnPressed();
77     void slotNextUnicode();
78     void slotPrevUnicode();
79
80 };
81
82 #endif