X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Funicodedialog.cpp;h=4edf66d2fb1c439317d8434e6c97b4d5312e218c;hb=0ae9f07b0172db7341c39da60cfa0f4c406e28d0;hp=1eb151f54532669edf16f867f9e700656d0ae01c;hpb=d0d2c1275ae7c561cbddeef3baa8f29cf1fa68bc;p=kdenlive diff --git a/src/unicodedialog.cpp b/src/unicodedialog.cpp index 1eb151f5..4edf66d2 100644 --- a/src/unicodedialog.cpp +++ b/src/unicodedialog.cpp @@ -9,6 +9,8 @@ #include "unicodedialog.h" +#include + /// CONSTANTS const int MAX_LENGTH_HEX = 4; @@ -17,17 +19,17 @@ const uint MAX_UNICODE_V1 = 65535; /// CONSTRUCTORS/DECONSTRUCTORS -UnicodeDialog::UnicodeDialog(InputMethod inputMeth, QString lastUnicodeNumber) : +UnicodeDialog::UnicodeDialog(InputMethod inputMeth) : inputMethod(inputMeth), - m_lastCursorPos(0), - m_lastUnicodeNumber(lastUnicodeNumber) + m_lastCursorPos(0) { setupUi(this); + readChoices(); showLastUnicode(); connect(unicodeNumber, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString))); connect(unicodeNumber, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed())); - connect(arrowUp, SIGNAL(clicked()), this, SLOT(slotNextUnicode())); - connect(arrowDown, SIGNAL(clicked()), this, SLOT(slotPrevUnicode())); + connect(arrowUp, SIGNAL(clicked()), this, SLOT(slotPrevUnicode())); + connect(arrowDown, SIGNAL(clicked()), this, SLOT(slotNextUnicode())); switch (inputMethod) { case InputHex: @@ -40,9 +42,9 @@ UnicodeDialog::UnicodeDialog(InputMethod inputMeth, QString lastUnicodeNumber) : arrowUp->setShortcut(Qt::Key_Up); arrowDown->setShortcut(Qt::Key_Down); - - arrowUp->setToolTip(i18n("Next Unicode character (Arrow Up)")); - arrowDown->setToolTip(i18n("Previous Unicode character (Arrow Down)")); + unicode_link->setText(i18n("Information about unicode characters: http://decodeunicode.org")); + arrowUp->setToolTip(i18n("Previous Unicode character (Arrow Up)")); + arrowDown->setToolTip(i18n("Next Unicode character (Arrow Down)")); unicodeNumber->setToolTip(i18n("Enter your Unicode number here. Allowed characters: [0-9] and [a-f].")); unicodeNumber->selectAll(); // Selection will be reset by setToolTip and similar, so set it here @@ -53,6 +55,15 @@ UnicodeDialog::~UnicodeDialog() } +/// PUBLIC SLOTS + +int UnicodeDialog::exec() +{ + unicodeNumber->setFocus(); + return QDialog::exec(); +} + + /// METHODS void UnicodeDialog::showLastUnicode() @@ -120,7 +131,7 @@ QString UnicodeDialog::unicodeInfo(QString unicode) } else if (u == "a0") { infoText = i18n("No-break space.   in HTML. See U+2009 and U+0020."); } else if (u == "ab" || u == "bb" || u == "2039" || u == "203a") { - infoText = i18n("

« (u+00ab, &lfquo; in HTML) and » (u+00bb, &rfquo; in HTML) are called Guillemets or angle quotes. Usage in different countries: « France Â» (with non-breaking Space 0x00a0), «Switzerland», »Germany«, »Finland and Sweden».

and (U+2039/203a, ‹/›) are their single quote equivalents.

See Wikipedia:Guillemets

"); + infoText = i18n("

« (u+00ab, &lfquo; in HTML) and » (u+00bb, &rfquo; in HTML) are called Guillemets or angle quotes. Usage in different countries: France (with non-breaking Space 0x00a0), Switzerland, Germany, Finland and Sweden.

and (U+2039/203a, ‹/›) are their single quote equivalents.

See Wikipedia:Guillemets

"); } else if (u == "2002") { infoText = i18n("En Space (width of an n)"); } else if (u == "2003") { @@ -144,15 +155,23 @@ QString UnicodeDialog::unicodeInfo(QString unicode) } else if (u == "2013") { infoText = i18n("

An en Dash (dash of the width of an n).

Usage examples: In English language for value ranges (1878–1903), for relationships/connections (Zurich–Dublin). In the German language it is also used (with spaces!) for showing thoughts: “Es war – wie immer in den Ferien – ein regnerischer Tag.

See Wikipedia:Dash

"); } else if (u == "2014") { - infoText = i18n("

An em Dash (dash of the widht of an m).

Usage examples: In English language to mark—like here—thoughts. Traditionally without spaces.

See Wikipedia:Dash

"); + infoText = i18n("

An em Dash (dash of the width of an m).

Usage examples: In English language to mark—like here—thoughts. Traditionally without spaces.

See Wikipedia:Dash

"); } else if (u == "202f") { - infoText = i18n("

Narrow no-break space. Has the same width as U+2009.

Usage: For units (spaces are marked with U+2423, ␣): 230␣V, −21␣°C, 50␣lb, but 90° (no space). In German for abbreviations (like: i. d. R. instead of i. d. R. with U+00a0).

See Wikipedia:de:Schmales_Leerzeichen

"); + infoText = i18n("

Narrow no-break space. Has the same width as U+2009.

Usage: For units (spaces are marked with U+2423, ␣): 230␣V, −21␣°C, 50␣lb, but 90° (no space). In German for abbreviations (like: i. d. R. instead of i. d. R. with U+00a0).

See Wikipedia:de:Schmales_Leerzeichen

"); } else if (u == "2026") { infoText = i18n("Ellipsis: If text has been left o… See Wikipedia:Ellipsis"); } else if (u == "2212") { infoText = i18n("Minus sign. For numbers: −42"); } else if (u == "2423") { infoText = i18n("Open box; stands for a space."); + } else if (u == "2669") { + infoText = i18n("Quarter note (Am.) or crochet (Brit.). See Wikipedia:Quarter_note"); + } else if (u == "266a" || u == "266b") { + infoText = i18n("Eighth note (Am.) or quaver (Brit.). Half as long as a quarter note (U+2669). See Wikipedia:Eighth_note"); + } else if (u == "266c") { + infoText = i18n("Sixteenth note (Am.) or semiquaver (Brit.). Half as long as an eighth note (U+266a). See Wikipedia:Sixteenth_note"); + } else if (u == "1D162") { + infoText = i18n("Thirty-second note (Am.) or demisemiquaver (Brit.). Half as long as a sixteenth note (U+266b). See Wikipedia:Thirty-second_note"); } else { infoText = i18n("No additional information available for this character."); } @@ -245,6 +264,25 @@ QString UnicodeDialog::nextUnicode(QString text, Direction direction) return newText; } +void UnicodeDialog::readChoices() +{ + // Get a pointer to a shared configuration instance, then get the TitleWidget group. + KSharedConfigPtr config = KGlobal::config(); + KConfigGroup titleConfig(config, "TitleWidget"); + + // Default is 2013 because there is also (perhaps interesting) information. + m_lastUnicodeNumber = titleConfig.readEntry("unicode_number", QString("2013")); +} + +void UnicodeDialog::writeChoices() +{ + // Get a pointer to a shared configuration instance, then get the TitleWidget group. + KSharedConfigPtr config = KGlobal::config(); + KConfigGroup titleConfig(config, "TitleWidget"); + + titleConfig.writeEntry("unicode_number", m_lastUnicodeNumber); +} + /// SLOTS @@ -313,7 +351,7 @@ void UnicodeDialog::slotReturnPressed() QString text = trimmedUnicodeNumber(unicodeNumber->text()); if (!controlCharacter(text)) { emit charSelected(unicodeChar->text()); - emit newUnicodeNumber(unicodeNumber->text()); + writeChoices(); } emit accept(); } @@ -330,4 +368,12 @@ void UnicodeDialog::slotPrevUnicode() unicodeNumber->setText(nextUnicode(text, Backward)); } +void UnicodeDialog::wheelEvent(QWheelEvent * event) +{ + if (frame->underMouse()) { + if (event->delta() > 0) slotNextUnicode(); + else slotPrevUnicode(); + } +} + #include "unicodedialog.moc"