emailuis/nmailuiwidgets/src/nmeditortextedit.cpp
changeset 59 16ed8d08d0b1
parent 54 997a02608b3a
child 75 47d84de1c893
equal deleted inserted replaced
54:997a02608b3a 59:16ed8d08d0b1
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "nmailuiwidgetsheaders.h"
    18 #include "nmailuiwidgetsheaders.h"
    19 
    19 
    20 static const QString FILE_PATH_CSS = ":nmeditortextedit.css";
    20 static const QString FILE_PATH_CSS_DEFAULT = ":nmeditortexteditblack.css";
       
    21 static const QString FILE_PATH_CSS_SECONDARY = ":nmeditortexteditblue.css";
    21 static const QString FILE_PATH_WIDGETML = ":nmeditortextedit.widgetml";
    22 static const QString FILE_PATH_WIDGETML = ":nmeditortextedit.widgetml";
    22 
    23 
    23 /*!
    24 /*!
    24     Constructor
    25     Constructor
    25 */
    26 */
    27     HbTextEdit(parent)
    28     HbTextEdit(parent)
    28 {
    29 {
    29     NM_FUNCTION;
    30     NM_FUNCTION;
    30     
    31     
    31     HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
    32     HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
    32     HbStyleLoader::registerFilePath(FILE_PATH_CSS);
    33     HbStyleLoader::registerFilePath(FILE_PATH_CSS_DEFAULT);
    33 
    34 
    34     mCustomTextColor = QPair<bool, QColor>(false, Qt::black);
    35     mCustomTextColor = QPair<bool, QColor>(false, Qt::black);
    35     
    36     
    36     // Disable HbTextEdit scrolling. Background scroll area will handle scrolling.
    37     // Disable HbTextEdit scrolling. Background scroll area will handle scrolling.
    37     setScrollable(false);
    38     setScrollable(false);
    40     // set background colour to plain white
    41     // set background colour to plain white
    41     QPixmap whitePixmap(10,10);
    42     QPixmap whitePixmap(10,10);
    42     whitePixmap.fill(Qt::white);
    43     whitePixmap.fill(Qt::white);
    43     QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem (whitePixmap);
    44     QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem (whitePixmap);
    44     setBackgroundItem(pixmapItem); 
    45     setBackgroundItem(pixmapItem); 
    45     
       
    46     // disables highlight frame for now - new api to set the frame item should be release somewhere wk26
       
    47     setFocusHighlight(HbStyle::P_TextEdit_frame_highlight, HbWidget::FocusHighlightNone);
       
    48     
    46     
    49     // Create custom palette based on the current one
    47     // Create custom palette based on the current one
    50     QPalette testPalette = QApplication::palette();
    48     QPalette testPalette = QApplication::palette();
    51 
    49 
    52     // Sets the selection background colour
    50     // Sets the selection background colour
    59     testPalette.setColor(QPalette::Active, QPalette::LinkVisited, Qt::darkMagenta);
    57     testPalette.setColor(QPalette::Active, QPalette::LinkVisited, Qt::darkMagenta);
    60     testPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, Qt::darkMagenta);
    58     testPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, Qt::darkMagenta);
    61 
    59 
    62     // Update custom palette for this widget
    60     // Update custom palette for this widget
    63     setPalette(testPalette);
    61     setPalette(testPalette);
    64 
       
    65     connect(this, SIGNAL(contentsChanged()), this, SLOT(updateCustomTextColor()));
       
    66 }
    62 }
    67 
    63 
    68 /*!
    64 /*!
    69     Destructor
    65     Destructor
    70 */
    66 */
    71 NmEditorTextEdit::~NmEditorTextEdit()
    67 NmEditorTextEdit::~NmEditorTextEdit()
    72 {
    68 {
    73     NM_FUNCTION;
    69     NM_FUNCTION;
    74     
    70     
    75     HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML);
    71     HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML);
    76     HbStyleLoader::unregisterFilePath(FILE_PATH_CSS);    
    72     if (mCustomTextColor.first) {
       
    73 		HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_SECONDARY);    
       
    74     }
       
    75     else {
       
    76 		HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_DEFAULT);    
       
    77     }
    77 }
    78 }
    78 
    79 
    79 /*!
    80 /*!
    80 	This slot applies custom text color for user - entered text
    81 	This slot applies custom text color for user - entered text
    81     It does not affect the text originally inserted into editor
    82     It does not affect the text originally inserted into editor
   129  */
   130  */
   130 void NmEditorTextEdit::setCustomTextColor(bool useCustom, const QColor& color)
   131 void NmEditorTextEdit::setCustomTextColor(bool useCustom, const QColor& color)
   131 {   
   132 {   
   132     NM_FUNCTION;
   133     NM_FUNCTION;
   133     
   134     
   134     mCustomTextColor.first = useCustom;
   135     if (!mCustomTextColor.first && useCustom) {
   135     //check and set custom color
   136         HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_DEFAULT);    
   136     mCustomTextColor.first ? mCustomTextColor.second = color : 
   137         HbStyleLoader::registerFilePath(FILE_PATH_CSS_SECONDARY);
   137                              mCustomTextColor.second = mCustomTextColor.second;
   138 
   138     
   139         mCustomTextColor.first = useCustom;
       
   140         mCustomTextColor.second = color;
       
   141     }		
   139 }
   142 }
   140 
   143 
   141 /*!
   144 /*!
   142  *  Return current custom color and if it must be used.
   145  *  Return current custom color and if it must be used.
   143  *  
   146  *