added settings option to show/hide the style buttons
[quassel.git] / src / qtui / inputwidget.cpp
index 1652393..ec6e92a 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-09 by the Quassel Project                          *
+ *   Copyright (C) 2005-2010 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -85,9 +85,9 @@ InputWidget::InputWidget(QWidget *parent)
   _colorFillMenu->addAction(pix, tr("Clear Color"))->setData("");
 
   ui.textcolorButton->setMenu(_colorMenu);
-  connect(_colorMenu, SIGNAL(triggered(QAction*)), this, SLOT(colorChoosen(QAction*)));
+  connect(_colorMenu, SIGNAL(triggered(QAction*)), this, SLOT(colorChosen(QAction*)));
   ui.highlightcolorButton->setMenu(_colorFillMenu);
-  connect(_colorFillMenu, SIGNAL(triggered(QAction*)), this, SLOT(colorHighlightChoosen(QAction*)));
+  connect(_colorFillMenu, SIGNAL(triggered(QAction*)), this, SLOT(colorHighlightChosen(QAction*)));
 
   new TabCompleter(ui.inputEdit);
 
@@ -107,6 +107,9 @@ InputWidget::InputWidget(QWidget *parent)
   s.notify("ShowNickSelector", this, SLOT(setShowNickSelector(QVariant)));
   setShowNickSelector(s.value("ShowNickSelector", true));
 
+  s.notify("ShowStyleButtons", this, SLOT(setShowStyleButtons(QVariant)));
+  setShowStyleButtons(s.value("ShowStyleButtons", true));
+
   s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant)));
   setMaxLines(s.value("MaxNumLines", 5));
 
@@ -152,6 +155,10 @@ void InputWidget::setShowNickSelector(const QVariant &v) {
   ui.ownNick->setVisible(v.toBool());
 }
 
+void InputWidget::setShowStyleButtons(const QVariant &v) {
+  ui.showStyleButton->setVisible(v.toBool());
+}
+
 void InputWidget::setMaxLines(const QVariant &v) {
   ui.inputEdit->setMaxHeight(v.toInt());
 }
@@ -396,6 +403,7 @@ QTextCharFormat InputWidget::getFormatOfWordOrSelection() {
 
 void InputWidget::currentCharFormatChanged(const QTextCharFormat &format) {
   fontChanged(format.font());
+
   if (format.foreground().isOpaque())
     colorChanged(format.foreground().color());
   else
@@ -406,19 +414,19 @@ void InputWidget::currentCharFormatChanged(const QTextCharFormat &format) {
     colorHighlightChanged(Qt::transparent);
 }
 
-void InputWidget::on_boldButton_toggled(bool checked) {
+void InputWidget::on_boldButton_clicked(bool checked) {
   QTextCharFormat fmt;
   fmt.setFontWeight(checked ? QFont::Bold : QFont::Normal);
   mergeFormatOnWordOrSelection(fmt);
 }
 
-void InputWidget::on_underlineButton_toggled(bool checked) {
+void InputWidget::on_underlineButton_clicked(bool checked) {
   QTextCharFormat fmt;
   fmt.setFontUnderline(checked);
   mergeFormatOnWordOrSelection(fmt);
 }
 
-void InputWidget::on_italicButton_toggled(bool checked) {
+void InputWidget::on_italicButton_clicked(bool checked) {
   QTextCharFormat fmt;
   fmt.setFontItalic(checked);
   mergeFormatOnWordOrSelection(fmt);
@@ -431,7 +439,7 @@ void InputWidget::fontChanged(const QFont &f)
   ui.underlineButton->setChecked(f.underline());
 }
 
-void InputWidget::colorChoosen(QAction * action) {
+void InputWidget::colorChosen(QAction *action) {
   QTextCharFormat fmt;
   QColor color;
   if (qVariantValue<QString>(action->data()) == "") {
@@ -449,7 +457,7 @@ void InputWidget::colorChoosen(QAction * action) {
   ui.textcolorButton->setIcon(createColorToolButtonIcon(SmallIcon("format-text-color"), color));
 }
 
-void InputWidget::colorHighlightChoosen(QAction * action) {
+void InputWidget::colorHighlightChosen(QAction *action) {
   QTextCharFormat fmt;
   QColor color;
   if (qVariantValue<QString>(action->data()) == "") {
@@ -495,7 +503,7 @@ void InputWidget::on_showStyleButton_toggled(bool checked) {
   }
 }
 
-QIcon InputWidget::createColorToolButtonIcon(const QIcon &icon, QColor color) {
+QIcon InputWidget::createColorToolButtonIcon(const QIcon &icon, const QColor &color) {
   QPixmap pixmap(16, 16);
   pixmap.fill(Qt::transparent);
   QPainter painter(&pixmap);