]> git.sesse.net Git - kdenlive/blob - src/unicodedialog.h
Some progress on keyframe editor
[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(QString unicode);
28
29     void showLastUnicode();
30
31 public slots:
32     /** \brief Override QDialog::exec() to assure the focus being on the unicode input field */
33     int exec();
34
35 private:
36     Ui::UnicodeDialog_UI m_view;
37
38     enum Direction { Forward, Backward };
39
40     /** Selected input method */
41     InputMethod inputMethod;
42
43     /** \brief Validates text and removes all invalid characters (non-hex e.g.) */
44     QString validateText(QString text);
45     /** \brief Removes all leading zeros */
46     QString trimmedUnicodeNumber(QString text);
47     /** \brief Checks whether the given string is a control character */
48     bool controlCharacter(QString text);
49     /** \brief Checks whether the given uint is a control character */
50     bool controlCharacter(uint value);
51
52     /** \brief Returns the next available unicode. */
53     QString nextUnicode(QString text, Direction direction);
54
55     /** \brief Paints previous and next characters around current char */
56     void updateOverviewChars(uint unicode);
57     void clearOverviewChars();
58
59     int m_lastCursorPos;
60     QString m_lastUnicodeNumber;
61
62     /** \brief Reads the last used unicode number from the config file. */
63     void readChoices();
64     /** \brief Writes the last used unicode number into the config file. */
65     void writeChoices();
66
67 signals:
68     /** \brief Contains the selected unicode character; emitted when Enter is pressed. */
69     void charSelected(const QString&);
70
71 private slots:
72     void slotTextChanged(QString text);
73     void slotReturnPressed();
74     void slotNextUnicode();
75     void slotPrevUnicode();
76
77 };
78
79 #endif