m_endViewport(NULL),
m_render(render),
m_count(0),
- m_unicodeDialog(new UnicodeDialog(UnicodeDialog::InputHex)),
m_projectPath(projectPath)
{
setupUi(this);
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
} 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()
void TitleWidget::slotInsertUnicode()
{
- m_unicodeDialog->showLastUnicode();
m_unicodeDialog->exec();
}
}
}
+void TitleWidget::slotUnicodeNumber(QString newUnicodeNumber)
+{
+ m_lastUnicodeNumber = newUnicodeNumber;
+}
+
void TitleWidget::slotUpdateText()
{
QFont font = font_family->currentFont();
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();
horizontalSlider->setValue(titleConfig.readEntry("background_alpha", horizontalSlider->value()));
cropImage->setChecked(titleConfig.readEntry("crop_image", cropImage->isChecked()));
+
+ m_lastUnicodeNumber = titleConfig.readEntry("unicode_number", QString("2013"));
}
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 */
void slotUpdateText();
void slotInsertUnicode();
void slotInsertUnicodeString(QString);
+ /** \brief Called when unicode dialog closed, updates the last selected unicode number */
+ void slotUnicodeNumber(QString);
void displayBackgroundFrame();
void slotRectTool();
void slotSelectTool();
void slotImageTool();
+
/** \brief Called when accepted, stores the user selections for next time use */
void slotAccepted();
/// 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()));
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()
void UnicodeDialog::showLastUnicode()
{
- unicodeNumber->setText(lastUnicodeNumber);
+ unicodeNumber->setText(m_lastUnicodeNumber);
+ unicodeNumber->selectAll();
+ slotTextChanged(m_lastUnicodeNumber);
}
bool UnicodeDialog::controlCharacter(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>");
infoText = i18n("Standard space character. (See U+00a0 and U+2000–200b)");
} else if (u == "a0") {
infoText = i18n("No-break space. &nbsp; in HTML. See U+0020.");
+ } else if (u == "ab" || u == "bb" || u == "2039" || u == "203a") {
+ infoText = i18n("<p><strong>«</strong> (u+00ab, <code>&lfquo;</code> in HTML) and <strong>»</strong> (u+00bb, <code>&rfquo;</code> in HTML) are called Guillemets or angle quotes. Usage in different countries: « France » (with non-breaking Space 0x00a0), «Switzerland», »Germany«, »Finland and Sweden».</p><p><strong>‹</strong> and <strong>›</strong> (U+2039/203a, <code>&lsaquo;/&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") {
} 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–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.</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—like here—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… See <a href=\"http://en.wikipedia.org/wiki/Ellipsis\">Wikipedia:Ellipsis</a>");
} else {
infoText = i18n("<small>No additional information available for this character.</small>");
}
unicodeChar->setText("");
unicodeNumber->setText("");
clearOverviewChars();
- lastCursorPos = 0;
- lastUnicodeNumber = "";
+ m_lastCursorPos = 0;
+ m_lastUnicodeNumber = "";
labelInfoText->setText(unicodeInfo(""));
} else {
// 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));
QString text = trimmedUnicodeNumber(unicodeNumber->text());
if (!controlCharacter(text)) {
emit charSelected(unicodeChar->text());
+ emit newUnicodeNumber(unicodeNumber->text());
}
emit accept();
}
/** \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();
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);
<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>