瀏覽代碼

ctkConsole - Rename TextBackgroundColor into BackgroundColor

Also fix an issue in backgroundColor() getter, the palette
as retrieved from the public class (QWidget) instead of the pimpl (QTextedit).
Jean-Christophe Fillion-Robin 14 年之前
父節點
當前提交
5904604c76
共有 2 個文件被更改,包括 14 次插入7 次删除
  1. 11 4
      Libs/Widgets/ctkConsole.cpp
  2. 3 3
      Libs/Widgets/ctkConsole.h

+ 11 - 4
Libs/Widgets/ctkConsole.cpp

@@ -669,17 +669,24 @@ CTK_GET_CPP(ctkConsole, QColor, welcomeTextColor, WelcomeTextColor);
 CTK_SET_CPP(ctkConsole, const QColor&, setWelcomeTextColor, WelcomeTextColor);
 
 //-----------------------------------------------------------------------------
-QColor ctkConsole::textBackgroundColor()const
+QColor ctkConsole::backgroundColor()const
 {
   Q_D(const ctkConsole);
-  return d->textBackgroundColor();
+  QPalette pal = d->palette();
+  return pal.color(QPalette::Base);
 }
 
 //-----------------------------------------------------------------------------
-void ctkConsole::setTextBackgroundColor(const QColor& newColor)
+void ctkConsole::setBackgroundColor(const QColor& newColor)
 {
   Q_D(ctkConsole);
-  return d->setTextBackgroundColor(newColor);
+  if (this->backgroundColor() == newColor)
+    {
+    return;
+    }
+  QPalette pal = this->palette();
+  pal.setColor(QPalette::Base, newColor);
+  d->setPalette(pal);
 }
 
 //-----------------------------------------------------------------------------

+ 3 - 3
Libs/Widgets/ctkConsole.h

@@ -72,7 +72,7 @@ class CTK_WIDGETS_EXPORT ctkConsole : public QWidget
   Q_PROPERTY(QColor errorTextColor READ errorTextColor WRITE setErrorTextColor)
   Q_PROPERTY(QColor commandTextColor READ commandTextColor WRITE setCommandTextColor)
   Q_PROPERTY(QColor welcomeTextColor READ welcomeTextColor WRITE setWelcomeTextColor)
-  Q_PROPERTY(QColor textBackgroundColor READ textBackgroundColor WRITE setTextBackgroundColor)
+  Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
   Q_PROPERTY(QString ps1 READ ps1 WRITE setPs1)
   Q_PROPERTY(QString ps2 READ ps2 WRITE setPs2)
   Q_FLAGS(EditorHint EditorHints)
@@ -129,9 +129,9 @@ public:
   /// \sa welcomeTextColor()
   void setWelcomeTextColor(const QColor& newColor);
 
-  QColor textBackgroundColor()const;
+  QColor backgroundColor()const;
 
-  void setTextBackgroundColor(const QColor& newColor);
+  void setBackgroundColor(const QColor& newColor);
 
   EditorHints editorHints()const;