Revision
14279
Author
jmesquita
Date
2009-07-17 02:10:27 -0500 (Fri, 17 Jul 2009)

Log Message

NEW FEATURE: Set the colors of different log levels according to preferences.

Modified Paths

Diff

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp (14278 => 14279)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp	2009-07-17 06:11:29 UTC (rev 14278)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp	2009-07-17 07:10:27 UTC (rev 14279)
@@ -47,6 +47,7 @@
     m_ui(new Ui::consolePage)
 {
     m_ui->setupUi(this);
+    setConsoleBackground();
     connect(m_ui->comboLogLevel, SIGNAL(currentIndexChanged(int)),
             this, SLOT(loglevelChanged(int)));
 }
@@ -61,6 +62,11 @@
     delete eslConnection;
     delete m_ui;
 }
+void consolePage::setConsoleBackground()
+{
+    QSettings settings(SETTINGS_ORGANIZATION, SETTINGS_APPLICATION);
+    m_ui->textConsole->setPalette(settings.value("consoleBackgroundColor",QColor(Qt::white)).value<QColor>());
+}
 void consolePage::init(QString host)
 {
     this->host = host;
@@ -173,7 +179,6 @@
 void consolePage::gotConsoleEventSlot(ESLeventLog * event)
 {
     m_ui->textConsole->setTextColor(event->getConsoleColor());
-    qDebug() << event->getConsoleColor();
     if (event->getBody())
     {
         QString text = event->getBody();

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp (14278 => 14279)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp	2009-07-17 06:11:29 UTC (rev 14278)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp	2009-07-17 07:10:27 UTC (rev 14279)
@@ -506,10 +506,9 @@
 void ESLeventLog::readSettings()
 {
     QSettings settings(SETTINGS_ORGANIZATION, SETTINGS_APPLICATION);
-    QColor consoleColor = settings.value(QString("Log-Level-%1-Color").arg(ESLevent::getHeader("Log-Level")), QColor(Qt::black)).value<QColor>();
+    consoleColor = new QColor(settings.value(QString("Log-Level-%1-Color").arg(ESLevent::getHeader("Log-Level")), QColor(Qt::black)).value<QColor>());
 }
 QColor ESLeventLog::getConsoleColor()
 {
-    qDebug() << consoleColor;
-    return consoleColor;
+    return QColor(*consoleColor);
 }

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp (14278 => 14279)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp	2009-07-17 06:11:29 UTC (rev 14278)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp	2009-07-17 07:10:27 UTC (rev 14279)
@@ -129,7 +129,13 @@
     m_ui->tabWidget->removeTab(index);
     delete tab;
 }
-void Cfsgui::backgroundColorChanged(QColor color)
+void Cfsgui::backgroundColorChanged()
 {
-    //TODO: Get tabs and set them all!
+    //TODO: Still don't know how to do it...
+    /*for (int i = 0; i < m_ui->tabWidget->count(); i++)
+    {
+        qDebug() << "Tab: " << i;
+        consolePage *tab = m_ui->tabWidget->widget(i);
+        tab->setConsoleBackground();
+    }*/
 }

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h (14278 => 14279)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h	2009-07-17 06:11:29 UTC (rev 14278)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h	2009-07-17 07:10:27 UTC (rev 14279)
@@ -19,6 +19,7 @@
     consolePage(QWidget *parent = 0);
     ~consolePage();
     void init(QString host);
+    void setConsoleBackground();
 
 protected:
     virtual void changeEvent(QEvent *e);

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h (14278 => 14279)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h	2009-07-17 06:11:29 UTC (rev 14278)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h	2009-07-17 07:10:27 UTC (rev 14279)
@@ -81,7 +81,7 @@
     QColor getConsoleColor();
     void readSettings();
 private:
-    QColor consoleColor;
+    QColor *consoleColor;
 };
 
 class ESLconnection : public QThread

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h (14278 => 14279)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h	2009-07-17 06:11:29 UTC (rev 14278)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h	2009-07-17 07:10:27 UTC (rev 14279)
@@ -64,7 +64,7 @@
     void showPreferences();
     void newConnectionFromDialog();
     void closeTab(int);
-    void backgroundColorChanged(QColor);
+    void backgroundColorChanged();
 
 private:
     Ui::Cfsgui *m_ui;

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/preferencesdialog.h (14278 => 14279)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/preferencesdialog.h	2009-07-17 06:11:29 UTC (rev 14278)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/preferencesdialog.h	2009-07-17 07:10:27 UTC (rev 14279)
@@ -20,10 +20,17 @@
 private slots:
     void changePage(QListWidgetItem *current, QListWidgetItem *previous);
     void changeBackgroundColor();
+    void changeConsoleLogLevelColor();
+    void changeCriticalLogLevelColor();
+    void changeDebugLogLevelColor();
+    void changeErrorLogLevelColor();
+    void changeInfoLogLevelColor();
+    void changeNoticeLogLevelColor();
+    void changeWarningLogLevelColor();
     void saveSettings();
     void readSettings();
 signals:
-    void backgroundColorChanged(QColor);
+    void backgroundColorChanged();
 private:
     Ui::preferencesDialog *m_ui;
     QColorDialog *colorChooser;

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/preferencesdialog.cpp (14278 => 14279)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/preferencesdialog.cpp	2009-07-17 06:11:29 UTC (rev 14278)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/preferencesdialog.cpp	2009-07-17 07:10:27 UTC (rev 14279)
@@ -13,8 +13,25 @@
 
     connect(m_ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
             this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
+
     connect(m_ui->btnChangeBackgroundColor, SIGNAL(clicked()),
             this, SLOT(changeBackgroundColor()));
+
+    connect(m_ui->btnChangeConsoleLogLevelColor, SIGNAL(clicked()),
+            this, SLOT(changeConsoleLogLevelColor()));
+    connect(m_ui->btnChangeCriticalLogLevelColor, SIGNAL(clicked()),
+            this, SLOT(changeCriticalLogLevelColor()));
+    connect(m_ui->btnChangeDebugLogLevelColor, SIGNAL(clicked()),
+            this, SLOT(changeDebugLogLevelColor()));
+    connect(m_ui->btnChangeErrorLogLevelColor, SIGNAL(clicked()),
+            this, SLOT(changeErrorLogLevelColor()));
+    connect(m_ui->btnChangeInfoLogLevelColor, SIGNAL(clicked()),
+            this, SLOT(changeInfoLogLevelColor()));
+    connect(m_ui->btnChangeNoticeLogLevelColor, SIGNAL(clicked()),
+            this, SLOT(changeNoticeLogLevelColor()));
+    connect(m_ui->btnChangeWarningLogLevelColor, SIGNAL(clicked()),
+            this, SLOT(changeWarningLogLevelColor()));
+
     connect(this, SIGNAL(accepted()),
             this, SLOT(saveSettings()));
     connect(this, SIGNAL(rejected()),
@@ -53,6 +70,62 @@
      m_ui->frmBackgroundColor->setPalette(colorChooser->getColor(
              m_ui->frmBackgroundColor->palette().color(QPalette::Background)));
  }
+void preferencesDialog::changeConsoleLogLevelColor()
+{
+     if(!colorChooser)
+         colorChooser = new QColorDialog();
+
+     m_ui->frmConsoleLogLevelColor->setPalette(colorChooser->getColor(
+             m_ui->frmConsoleLogLevelColor->palette().color(QPalette::Background)));
+}
+void preferencesDialog::changeCriticalLogLevelColor()
+{
+     if(!colorChooser)
+         colorChooser = new QColorDialog();
+
+     m_ui->frmCriticalLogLevelColor->setPalette(colorChooser->getColor(
+             m_ui->frmCriticalLogLevelColor->palette().color(QPalette::Background)));
+}
+void preferencesDialog::changeDebugLogLevelColor()
+{
+     if(!colorChooser)
+         colorChooser = new QColorDialog();
+
+     m_ui->frmDebugLogLevelColor->setPalette(colorChooser->getColor(
+             m_ui->frmDebugLogLevelColor->palette().color(QPalette::Background)));
+}
+void preferencesDialog::changeErrorLogLevelColor()
+{
+     if(!colorChooser)
+         colorChooser = new QColorDialog();
+
+     m_ui->frmErrorLogLevelColor->setPalette(colorChooser->getColor(
+             m_ui->frmErrorLogLevelColor->palette().color(QPalette::Background)));
+}
+void preferencesDialog::changeInfoLogLevelColor()
+{
+     if(!colorChooser)
+         colorChooser = new QColorDialog();
+
+     m_ui->frmInfoLogLevelColor->setPalette(colorChooser->getColor(
+             m_ui->frmInfoLogLevelColor->palette().color(QPalette::Background)));
+}
+void preferencesDialog::changeNoticeLogLevelColor()
+{
+     if(!colorChooser)
+         colorChooser = new QColorDialog();
+
+     m_ui->frmNoticeLogLevelColor->setPalette(colorChooser->getColor(
+             m_ui->frmNoticeLogLevelColor->palette().color(QPalette::Background)));
+}
+void preferencesDialog::changeWarningLogLevelColor()
+{
+     if(!colorChooser)
+         colorChooser = new QColorDialog();
+
+     m_ui->frmWarningLogLevelColor->setPalette(colorChooser->getColor(
+             m_ui->frmWarningLogLevelColor->palette().color(QPalette::Background)));
+}
 void preferencesDialog::saveSettings()
 {
     QSettings settings(SETTINGS_ORGANIZATION, SETTINGS_APPLICATION);
@@ -70,7 +143,7 @@
     settings.setValue(QString("Log-Level-%1-Color").arg(ESL_LOG_LEVEL_WARNING), m_ui->frmWarningLogLevelColor->palette().color(QPalette::Background));
 
     /* Make all tabs change their settings */
-    emit backgroundColorChanged(m_ui->frmBackgroundColor->palette().color(QPalette::Background));
+    emit backgroundColorChanged();
 }
 void preferencesDialog::readSettings()
 {