client: Add keyboard shortcuts for formatting
authorShane Synan <digitalcircuit36939@gmail.com>
Fri, 1 Jun 2018 03:24:07 +0000 (22:24 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 6 Jun 2018 18:15:42 +0000 (20:15 +0200)
Add keyboard shortcuts for formatting options as follows:

* Apply foreground color: Ctrl-Shift-G
* Apply background color: Ctrl-Shift-B
* Clear formatting:       Ctrl-Shift-C
* Toggle bold:            Ctrl-B       (from QKeySequence::Bold)
* Toggle italic:          Ctrl-I       (from QKeySequence::Italic)
* Toggle underline:       Ctrl-U       (from QKeySequence::Underline)

src/qtui/mainwin.cpp
src/qtui/mainwin.h

index 8eefba1..ff4c81a 100644 (file)
@@ -479,6 +479,38 @@ void MainWin::setupActions()
     coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll,
             this, SLOT(hideCurrentBuffer()), QKeySequence::Close));
 
+    // Text formatting
+    coll = QtUi::actionCollection("TextFormat", tr("Text formatting"));
+
+    coll->addAction("FormatApplyColor", new Action(
+                        QIcon::fromTheme("format-text-color"), tr("Apply foreground color"), coll,
+                        this, SLOT(on_inputFormatApplyColor_triggered()),
+                        QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G)));
+
+    coll->addAction("FormatApplyColorFill", new Action(
+                        QIcon::fromTheme("format-fill-color"), tr("Apply background color"), coll,
+                        this, SLOT(on_inputFormatApplyColorFill_triggered()),
+                        QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B)));
+
+    coll->addAction("FormatClear", new Action(
+                        QIcon::fromTheme("edit-clear"), tr("Clear formatting"), coll,
+                        this, SLOT(on_inputFormatClear_triggered()),
+                        QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C)));
+
+    coll->addAction("FormatBold", new Action(
+                        QIcon::fromTheme("format-text-bold"), tr("Toggle bold"), coll,
+                        this, SLOT(on_inputFormatBold_triggered()),
+                        QKeySequence::Bold));
+
+    coll->addAction("FormatItalic", new Action(
+                        QIcon::fromTheme("format-text-italic"), tr("Toggle italics"), coll,
+                        this, SLOT(on_inputFormatItalic_triggered()),
+                        QKeySequence::Italic));
+
+    coll->addAction("FormatUnderline", new Action(
+                        QIcon::fromTheme("format-text-underline"), tr("Toggle underline"), coll,
+                        this, SLOT(on_inputFormatUnderline_triggered()), QKeySequence::Underline));
+
     // Navigation
     coll = QtUi::actionCollection("Navigation", tr("Navigation"));
 
@@ -1755,6 +1787,60 @@ void MainWin::connectOrDisconnectFromNet()
 }
 
 
+void MainWin::on_inputFormatApplyColor_triggered()
+{
+    if (!_inputWidget)
+        return;
+
+    _inputWidget->applyFormatActiveColor();
+}
+
+
+void MainWin::on_inputFormatApplyColorFill_triggered()
+{
+    if (!_inputWidget)
+        return;
+
+    _inputWidget->applyFormatActiveColorFill();
+}
+
+
+void MainWin::on_inputFormatClear_triggered()
+{
+    if (!_inputWidget)
+        return;
+
+    _inputWidget->clearFormat();
+}
+
+
+void MainWin::on_inputFormatBold_triggered()
+{
+    if (!_inputWidget)
+        return;
+
+    _inputWidget->toggleFormatBold();
+}
+
+
+void MainWin::on_inputFormatItalic_triggered()
+{
+    if (!_inputWidget)
+        return;
+
+    _inputWidget->toggleFormatItalic();
+}
+
+
+void MainWin::on_inputFormatUnderline_triggered()
+{
+    if (!_inputWidget)
+        return;
+
+    _inputWidget->toggleFormatUnderline();
+}
+
+
 void MainWin::on_jumpHotBuffer_triggered()
 {
     if (!_bufferHotList->rowCount())
index 431a308..aa8aa94 100644 (file)
@@ -143,6 +143,49 @@ private slots:
     void on_actionConfigureNetworks_triggered();
     void on_actionConfigureViews_triggered();
     void on_actionLockLayout_toggled(bool lock);
+
+    /**
+     * Apply the active color to the input widget selected or typed text
+     *
+     * @seealso InputWidget::applyFormatActiveColor()
+     */
+    void on_inputFormatApplyColor_triggered();
+
+    /**
+     * Apply the active fill color to the input widget selected or typed text background
+     *
+     * @seealso InputWidget::applyFormatActiveColorFill()
+     */
+    void on_inputFormatApplyColorFill_triggered();
+
+    /**
+     * Toggle the boldness of the input widget selected or typed text
+     *
+     * @seealso InputWidget::toggleFormatBold()
+     */
+    void on_inputFormatBold_triggered();
+
+    /**
+     * Toggle the italicness of the input widget selected or typed text
+     *
+     * @seealso InputWidget::toggleFormatItalic()
+     */
+    void on_inputFormatItalic_triggered();
+
+    /**
+     * Toggle the underlining of the input widget selected or typed text
+     *
+     * @seealso InputWidget::toggleFormatUnderline()
+     */
+    void on_inputFormatUnderline_triggered();
+
+    /**
+     * Clear the formatting of the input widget selected or typed text
+     *
+     * @seealso InputWidget::clearFormat()
+     */
+    void on_inputFormatClear_triggered();
+
     void on_jumpHotBuffer_triggered();
     void on_bufferSearch_triggered();
     void on_actionDebugNetworkModel_triggered();