]> git.sesse.net Git - kdenlive/commitdiff
Unicode dialog remembering selected unicode, explanations added and extended
authorSimon A. Eugster <simon.eu@gmail.com>
Sat, 20 Jun 2009 11:48:57 +0000 (11:48 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Sat, 20 Jun 2009 11:48:57 +0000 (11:48 +0000)
svn path=/trunk/kdenlive/; revision=3603

src/titlewidget.cpp
src/titlewidget.h
src/unicodedialog.cpp
src/unicodedialog.h
src/widgets/unicodedialog_ui.ui

index 5313acdf381e73f21a53bb3b52ba1ec00a31ee4a..71b7d12a9772b52ce08cdbeca5b84b8eaa3d4ce9 100644 (file)
@@ -46,7 +46,6 @@ TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget
         m_endViewport(NULL),
         m_render(render),
         m_count(0),
-        m_unicodeDialog(new UnicodeDialog(UnicodeDialog::InputHex)),
         m_projectPath(projectPath)
 {
     setupUi(this);
@@ -102,7 +101,6 @@ TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget
     connect(buttonAlignCenter, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
     connect(buttonAlignNone, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
     connect(buttonInsertUnicode, SIGNAL(clicked()), this, SLOT(slotInsertUnicode()));
-    connect(m_unicodeDialog, SIGNAL(charSelected(QString)), this, SLOT(slotInsertUnicodeString(QString)));
     connect(displayBg, SIGNAL(stateChanged(int)), this, SLOT(displayBackgroundFrame()));
 
     // mbd
@@ -236,6 +234,9 @@ TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget
     } else {
         slotRectTool();
     }
+    m_unicodeDialog = new UnicodeDialog(UnicodeDialog::InputHex, m_lastUnicodeNumber);
+    connect(m_unicodeDialog, SIGNAL(charSelected(QString)), this, SLOT(slotInsertUnicodeString(QString)));
+       connect(m_unicodeDialog, SIGNAL(newUnicodeNumber(QString)), this, SLOT(slotUnicodeNumber(QString)));
 }
 
 TitleWidget::~TitleWidget()
@@ -932,7 +933,6 @@ void TitleWidget::textChanged(QGraphicsTextItem *i)
 
 void TitleWidget::slotInsertUnicode()
 {
-    m_unicodeDialog->showLastUnicode();
     m_unicodeDialog->exec();
 }
 
@@ -947,6 +947,11 @@ void TitleWidget::slotInsertUnicodeString(QString text)
     }
 }
 
+void TitleWidget::slotUnicodeNumber(QString newUnicodeNumber)
+{
+       m_lastUnicodeNumber = newUnicodeNumber;
+}
+
 void TitleWidget::slotUpdateText()
 {
     QFont font = font_family->currentFont();
@@ -1225,6 +1230,9 @@ void TitleWidget::writeChoices()
     titleConfig.writeEntry("background_alpha", horizontalSlider->value());
 
     titleConfig.writeEntry("crop_image", cropImage->isChecked());
+       
+       titleConfig.writeEntry("unicode_number", m_lastUnicodeNumber);
+       
     //! \todo Not sure if I should sync - it is probably safe to do it
     config->sync();
 
@@ -1255,5 +1263,7 @@ void TitleWidget::readChoices()
     horizontalSlider->setValue(titleConfig.readEntry("background_alpha", horizontalSlider->value()));
 
     cropImage->setChecked(titleConfig.readEntry("crop_image", cropImage->isChecked()));
+       
+       m_lastUnicodeNumber = titleConfig.readEntry("unicode_number", QString("2013"));
 }
 
index 611dad413d9679f605782276f40c57b2f0631981..70711fd5a077e253dc21db03b0afda937a4e992e 100644 (file)
@@ -97,6 +97,8 @@ private:
     QAction *m_buttonLoad;
     /** \brief Dialog for entering unicode in text fields */
     UnicodeDialog *m_unicodeDialog;
+       /** \brief Stores the last used unicode */
+       QString m_lastUnicodeNumber;
     /** project path for storing title clips */
     QString m_projectPath;
     /** \brief Store the current choices of font, background and rect values */
@@ -185,6 +187,8 @@ private slots:
     void slotUpdateText();
     void slotInsertUnicode();
     void slotInsertUnicodeString(QString);
+       /** \brief Called when unicode dialog closed, updates the last selected unicode number */
+       void slotUnicodeNumber(QString);
 
     void displayBackgroundFrame();
 
@@ -194,6 +198,7 @@ private slots:
     void slotRectTool();
     void slotSelectTool();
     void slotImageTool();
+       
 
     /** \brief Called when accepted, stores the user selections for next time use */
     void slotAccepted();
index 53e1a9695bdbe1e46111e70f3b332971733ccc1e..8a7b06ff1731e45eb53c76c37a97e4ef8ae92c53 100644 (file)
@@ -17,9 +17,13 @@ const uint MAX_UNICODE_V1 = 65535;
 
 /// CONSTRUCTORS/DECONSTRUCTORS
 
-UnicodeDialog::UnicodeDialog(InputMethod inputMeth) : inputMethod(inputMeth), lastCursorPos(0), lastUnicodeNumber("")
+UnicodeDialog::UnicodeDialog(InputMethod inputMeth, QString lastUnicodeNumber) : 
+       inputMethod(inputMeth), 
+       m_lastCursorPos(0), 
+       m_lastUnicodeNumber(lastUnicodeNumber)
 {
     setupUi(this);
+       showLastUnicode();
     connect(unicodeNumber, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString)));
     connect(unicodeNumber, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
     connect(arrowUp, SIGNAL(clicked()), this, SLOT(slotNextUnicode()));
@@ -40,6 +44,8 @@ UnicodeDialog::UnicodeDialog(InputMethod inputMeth) : inputMethod(inputMeth), la
     arrowUp->setToolTip(i18n("Next Unicode character (Arrow Up)"));
     arrowDown->setToolTip(i18n("Previous 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
+       
 }
 
 UnicodeDialog::~UnicodeDialog()
@@ -51,7 +57,9 @@ UnicodeDialog::~UnicodeDialog()
 
 void UnicodeDialog::showLastUnicode()
 {
-    unicodeNumber->setText(lastUnicodeNumber);
+    unicodeNumber->setText(m_lastUnicodeNumber);
+       unicodeNumber->selectAll();
+       slotTextChanged(m_lastUnicodeNumber);
 }
 
 bool UnicodeDialog::controlCharacter(QString text)
@@ -96,12 +104,12 @@ QString UnicodeDialog::trimmedUnicodeNumber(QString text)
     return text;
 }
 
-QString UnicodeDialog::unicodeInfo(QString unicode_number)
+QString UnicodeDialog::unicodeInfo(QString unicode)
 {
     QString infoText(i18n("<small>(no character selected)</small>"));
-    if (unicode_number.length() == 0) return infoText;
+    if (unicode.length() == 0) return infoText;
 
-    QString u = trimmedUnicodeNumber(unicode_number).toLower();
+    QString u = trimmedUnicodeNumber(unicode).toLower();
 
     if (controlCharacter(u)) {
         infoText = i18n("Control character. Cannot be inserted/printed. See <a href=\"http://en.wikipedia.org/wiki/Control_character\">Wikipedia:Control_character</a>");
@@ -111,6 +119,8 @@ QString UnicodeDialog::unicodeInfo(QString unicode_number)
         infoText = i18n("Standard space character. (See U+00a0 and U+2000&#x2013;200b)");
     } else if (u == "a0") {
         infoText = i18n("No-break space. &amp;nbsp; in HTML. See U+0020.");
+       } else if (u == "ab" || u == "bb" || u == "2039" || u == "203a") {
+               infoText = i18n("<p><strong>«</strong> (u+00ab, <code>&amp;lfquo;</code> in HTML) and <strong>»</strong> (u+00bb, <code>&amp;rfquo;</code> in HTML) are called Guillemets or angle quotes. Usage in different countries: «&nbsp;France&nbsp;» (with non-breaking Space 0x00a0), «Switzerland», »Germany«, »Finland and Sweden».</p><p><strong>&lsaquo;</strong> and <strong>&rsaquo;</strong> (U+2039/203a, <code>&amp;lsaquo;/&amp;rsaquo;</code>) are their single quote equivalents.</p><p>See <a href=\"http://en.wikipedia.org/wiki/Guillemets\">Wikipedia:Guillemets</a></p>");
     } else if (u == "2002") {
         infoText = i18n("En Space (width of an n)");
     } else if (u == "2003") {
@@ -132,11 +142,11 @@ QString UnicodeDialog::unicodeInfo(QString unicode_number)
     } else if (u == "2019") {
         infoText = i18n("Punctuation Apostrophe. Should be used instead of U+0027. See <a href=\"http://en.wikipedia.org/wiki/Apostrophe\">Wikipedia:Apostrophe</a>");
     } else if (u == "2013") {
-        infoText = i18n("An en Dash (dash of the width of an n). See <a href=\"http://en.wikipedia.org/wiki/Dash\">Wikipedia:Dash</a>");
+        infoText = i18n("<p>An en Dash (dash of the width of an n).</p><p>Usage examples: In English language for value ranges (1878&#x2013;1903), for relationships/connections (Zurich&#x2013;Dublin). In the German language it is also used (with spaces!) for showing thoughts: &ldquo;Es war &#x2013; wie immer in den Ferien &#x2013; ein regnerischer Tag.</p> <p>See <a href=\"http://en.wikipedia.org/wiki/Dash\">Wikipedia:Dash</a></p>");
     } else if (u == "2014") {
-        infoText = i18n("An em Dash (dash of the widht of an m). See <a href=\"http://en.wikipedia.org/wiki/Dash\">Wikipedia:Dash</a>");
+        infoText = i18n("<p>An em Dash (dash of the widht of an m).</p><p>Usage examples: In English language to mark&#x2014;like here&#x2014;thoughts. Traditionally without spaces. </p><p>See <a href=\"http://en.wikipedia.org/wiki/Dash\">Wikipedia:Dash</a></p>");
     } else if (u == "2026") {
-        infoText = i18n("Ellipsis: If text has been left out. See <a href=\"http://en.wikipedia.org/wiki/Ellipsis\">Wikipedia:Ellipsis</a>");
+        infoText = i18n("Ellipsis: If text has been left o&#x2026; See <a href=\"http://en.wikipedia.org/wiki/Ellipsis\">Wikipedia:Ellipsis</a>");
     } else {
         infoText = i18n("<small>No additional information available for this character.</small>");
     }
@@ -244,8 +254,8 @@ void UnicodeDialog::slotTextChanged(QString text)
         unicodeChar->setText("");
         unicodeNumber->setText("");
         clearOverviewChars();
-        lastCursorPos = 0;
-        lastUnicodeNumber = "";
+        m_lastCursorPos = 0;
+        m_lastUnicodeNumber = "";
         labelInfoText->setText(unicodeInfo(""));
 
     } else {
@@ -274,12 +284,12 @@ void UnicodeDialog::slotTextChanged(QString text)
 
         // If an invalid character has been entered:
         // Reset the cursor position because the entered char has been deleted.
-        if (text != newText && newText == lastUnicodeNumber) {
-            unicodeNumber->setCursorPosition(lastCursorPos);
+        if (text != newText && newText == m_lastUnicodeNumber) {
+            unicodeNumber->setCursorPosition(m_lastCursorPos);
         }
 
-        lastCursorPos = unicodeNumber->cursorPosition();
-        lastUnicodeNumber = newText;
+        m_lastCursorPos = unicodeNumber->cursorPosition();
+        m_lastUnicodeNumber = newText;
 
         labelInfoText->setText(unicodeInfo(newText));
         unicodeChar->setText(QChar(value));
@@ -297,6 +307,7 @@ void UnicodeDialog::slotReturnPressed()
     QString text = trimmedUnicodeNumber(unicodeNumber->text());
     if (!controlCharacter(text)) {
         emit charSelected(unicodeChar->text());
+               emit newUnicodeNumber(unicodeNumber->text());
     }
     emit accept();
 }
index 009d2349436573d395964c934a08efc21ce64066..3dde58c4058e4647b43d38ad525d9a12ae6c5c74 100644 (file)
@@ -20,11 +20,11 @@ public:
     /** \brief The input method for the dialog. Atm only InputHex supported. */
     enum InputMethod { InputHex, InputDec };
 
-    UnicodeDialog(InputMethod inputMeth);
+    UnicodeDialog(InputMethod inputMeth, QString lastUnicodeNumber);
     ~UnicodeDialog();
 
     /** \brief Returns infos about a unicode number. Extendable/improvable ;) */
-    QString unicodeInfo(QString unicode_number);
+    QString unicodeInfo(QString unicode);
 
     void showLastUnicode();
 
@@ -52,12 +52,14 @@ private:
     void updateOverviewChars(uint unicode);
     void clearOverviewChars();
 
-    int lastCursorPos;
-    QString lastUnicodeNumber;
+    int m_lastCursorPos;
+    QString m_lastUnicodeNumber;
 
 signals:
     /** \brief Contains the selected unicode character; emitted when Enter is pressed. */
     void charSelected(const QString&);
+       /** \brief Contains the last used unicode number. */
+       void newUnicodeNumber(const QString&);
 
 private slots:
     void slotTextChanged(QString text);
index 07f3c4e17f94d8bf4787c458b96b937bea3afa1d..f1b4a75ee06eb83fb5399f5bbc1027d7d6737882 100644 (file)
@@ -7,9 +7,15 @@
     <x>0</x>
     <y>0</y>
     <width>576</width>
-    <height>211</height>
+    <height>309</height>
    </rect>
   </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
   <property name="windowTitle">
    <string>Enter Unicode value</string>
   </property>
    </item>
    <item row="1" column="0">
     <widget class="QFrame" name="frame_2">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
      <property name="frameShape">
       <enum>QFrame::StyledPanel</enum>
      </property>
         </property>
        </widget>
       </item>
-      <item row="2" column="0">
-       <widget class="QLabel" name="labelInfoText">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="locale">
-         <locale language="English" country="UnitedStates"/>
-        </property>
-        <property name="text">
-         <string notr="true"/>
-        </property>
-        <property name="alignment">
-         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-        </property>
-        <property name="wordWrap">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
       <item row="0" column="0">
        <widget class="QLabel" name="label_2">
         <property name="font">
         </property>
        </widget>
       </item>
+      <item row="2" column="0">
+       <widget class="QTextEdit" name="labelInfoText">
+        <property name="frameShadow">
+         <enum>QFrame::Plain</enum>
+        </property>
+        <property name="documentTitle">
+         <string notr="true"/>
+        </property>
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>