messagingapp/msgui/conversationview/src/msgeditorwidget.cpp
changeset 41 25fe1fe642e3
parent 37 518b245aa84c
child 48 4f501b74aeb1
equal deleted inserted replaced
40:224522e33db9 41:25fe1fe642e3
    26 #include <HbFrameItem>
    26 #include <HbFrameItem>
    27 #include <HbAction>
    27 #include <HbAction>
    28 #include <csmsaccount.h>
    28 #include <csmsaccount.h>
    29 #include <smutset.h>
    29 #include <smutset.h>
    30 #include <hbmessagebox.h>
    30 #include <hbmessagebox.h>
       
    31 #include <hbcolorscheme.h>
       
    32 #include <QColor>
    31 #include <QTimer>
    33 #include <QTimer>
    32 #include "unieditorpluginloader.h"
    34 #include "unieditorpluginloader.h"
    33 #include "unieditorplugininterface.h"
    35 #include "unieditorplugininterface.h"
    34 #include "UniSendingSettings.h"
    36 #include "UniSendingSettings.h"
    35 #include "UniEditorGenUtils.h"
    37 #include "UniEditorGenUtils.h"
    37 
    39 
    38 // LOCAL CONSTANTS
    40 // LOCAL CONSTANTS
    39 
    41 
    40 const QString SEND_ICON("qtg_mono_send");
    42 const QString SEND_ICON("qtg_mono_send");
    41 const QString BACKGROUND("qtg_fr_input_v_bg");
    43 const QString BACKGROUND("qtg_fr_input_v_bg");
    42 const QString BACKGROUND_FRAME("qtg_fr_btn_normal");
    44 const QString BACKGROUND_FRAME("qtg_fr_messaging_char_count");
    43 
    45 const QString CHAR_COUNTER_COLOR("qtc_messaging_char_count");
    44 const QString SEND_BUTTON_NORMAL("qtg_fr_input_btn_function_normal");
    46 
    45 const QString SEND_BUTTON_PRESSED("qtg_fr_input_btn_function_pressed");
    47 const QString SEND_BUTTON_NORMAL("qtg_fr_btn_green_normal");
    46 const QString SEND_BUTTON_DISABLED("qtg_fr_input_btn_function_disabled");
    48 const QString SEND_BUTTON_PRESSED("qtg_fr_btn_green_pressed");
       
    49 const QString SEND_BUTTON_DISABLED("qtg_fr_btn_disabled");
       
    50 
       
    51 const QString SEND_BUTTON_NORMAL_COLOR("qtc_callhandling_answer_normal");
       
    52 const QString SEND_BUTTON_PRESSED_COLOR("qtc_callhandling_answer_pressed");
       
    53 const QString SEND_BUTTON_DISABLED_COLOR("qtc_button_disabled");
    47 
    54 
    48 #define LOC_SMS_CHAR_LIMIT_REACHED hbTrId("txt_messaging_dialog_sms_character_count_exceeded")
    55 #define LOC_SMS_CHAR_LIMIT_REACHED hbTrId("txt_messaging_dialog_sms_character_count_exceeded")
    49 #define LOC_HINT_TEXT hbTrId("txt_messaging_formlabel_enter_message_here")
    56 #define LOC_HINT_TEXT hbTrId("txt_messaging_formlabel_enter_message_here")
    50 
    57 
    51   
    58   
    88     mSendButton->setEnabled(false); 
    95     mSendButton->setEnabled(false); 
    89     
    96     
    90     HbFrameItem* backGround = new HbFrameItem(this); 
    97     HbFrameItem* backGround = new HbFrameItem(this); 
    91     backGround->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); 
    98     backGround->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); 
    92     mSendButton->setBackgroundItem(backGround); 
    99     mSendButton->setBackgroundItem(backGround); 
    93     updateButtonBackground(SEND_BUTTON_DISABLED); 
   100     updateButtonBackgroundAndColor(SEND_BUTTON_DISABLED,SEND_BUTTON_DISABLED_COLOR); 
    94     mSendButton->setIcon(HbIcon(SEND_ICON));
   101     mSendButton->setIcon(HbIcon(SEND_ICON));
    95     
   102     
    96     mCharCounter = new HbTextItem(this);
   103     mCharCounter = new HbTextItem(this);
    97     HbStyle::setItemName(mCharCounter, "charCounter");
   104     HbStyle::setItemName(mCharCounter, "charCounter");
    98     mCharCounter->setZValue(1.5);
   105     mCharCounter->setZValue(1.5);
    99     
   106     
       
   107     QColor color = HbColorScheme::color(CHAR_COUNTER_COLOR);
       
   108     mCharCounter->setTextColor(color);
       
   109     
   100     mBackgroundItem = new HbFrameItem(this);
   110     mBackgroundItem = new HbFrameItem(this);
   101     HbStyle::setItemName(mBackgroundItem, "charCounterFrame");
   111     HbStyle::setItemName(mBackgroundItem, "charCounterFrame");
   102 
   112 
   103     mBackgroundItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   113     mBackgroundItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
   104     mBackgroundItem->frameDrawer().setFillWholeRect(true);
   114     mBackgroundItem->frameDrawer().setFillWholeRect(true);
   105     
   115     
   106     mBackgroundItem->frameDrawer().setFrameGraphicsName(
   116     mBackgroundItem->frameDrawer().setFrameGraphicsName(
   107         BACKGROUND_FRAME);    
   117         BACKGROUND_FRAME);    
   108     
   118     
   173         {
   183         {
   174         if(!mSendButton->isEnabled())
   184         if(!mSendButton->isEnabled())
   175             {
   185             {
   176             mSendButton->setFocusProxy(mMsgEditor);
   186             mSendButton->setFocusProxy(mMsgEditor);
   177             mSendButton->setEnabled(true);
   187             mSendButton->setEnabled(true);
   178             updateButtonBackground(SEND_BUTTON_NORMAL);
   188             updateButtonBackgroundAndColor(SEND_BUTTON_NORMAL,SEND_BUTTON_NORMAL_COLOR);
   179             }
   189             }
   180         }
   190         }
   181     else
   191     else
   182         {
   192         {
   183         if(mSendButton->isEnabled())
   193         if(mSendButton->isEnabled())
   184             {
   194             {
   185             mSendButton->setFocusProxy(0);
   195             mSendButton->setFocusProxy(0);
   186             mSendButton->setEnabled(false);
   196             mSendButton->setEnabled(false);
   187             updateButtonBackground(SEND_BUTTON_DISABLED);
   197             updateButtonBackgroundAndColor(SEND_BUTTON_DISABLED,SEND_BUTTON_DISABLED_COLOR);
   188             }
   198             }
   189         }
   199         }
   190     
   200     
   191     //Check done for optimization
   201     //Check done for optimization
   192     //Only if content is deleted we need to call encodingsettings again
   202     //Only if content is deleted we need to call encodingsettings again
   277     
   287     
   278     emit sendMessage();
   288     emit sendMessage();
   279     }
   289     }
   280 
   290 
   281 //---------------------------------------------------------------
   291 //---------------------------------------------------------------
   282 // MsgEditor::updateButtonBackground
   292 // MsgEditor::updateButtonBackgroundAndColor
   283 // @see header
   293 // @see header
   284 //---------------------------------------------------------------
   294 //---------------------------------------------------------------
   285 void MsgEditorWidget::updateButtonBackground(const QString& bg) 
   295 void MsgEditorWidget::updateButtonBackgroundAndColor(const QString& bg,const QString& iconColor) 
   286     { 
   296     { 
   287     HbFrameItem* drawer = static_cast<HbFrameItem*>(mSendButton->backgroundItem()); 
   297     HbFrameItem* drawer = static_cast<HbFrameItem*>(mSendButton->backgroundItem()); 
   288     if(drawer) 
   298     if(drawer) 
   289         { 
   299         { 
   290         drawer->frameDrawer().setFrameGraphicsName(bg);   
   300         drawer->frameDrawer().setFrameGraphicsName(bg);   
   291         } 
   301         } 
       
   302     QColor color = HbColorScheme::color(iconColor);
       
   303     
       
   304     if(color.isValid())
       
   305     	 {
       
   306     	 mSendButton->icon().setColor(color);
       
   307     	 }	    
   292     } 
   308     } 
   293     
   309     
   294 
   310 
   295 //---------------------------------------------------------------
   311 //---------------------------------------------------------------
   296 // MsgEditor::onPressed
   312 // MsgEditor::onPressed
   297 // @see header
   313 // @see header
   298 //---------------------------------------------------------------
   314 //---------------------------------------------------------------
   299 void MsgEditorWidget::onPressed()
   315 void MsgEditorWidget::onPressed()
   300     {
   316     {
   301     updateButtonBackground(SEND_BUTTON_PRESSED);
   317     updateButtonBackgroundAndColor(SEND_BUTTON_PRESSED,SEND_BUTTON_PRESSED_COLOR);
   302     }
   318     }
   303 
   319 
   304 //---------------------------------------------------------------
   320 //---------------------------------------------------------------
   305 // MsgEditor::onReleased
   321 // MsgEditor::onReleased
   306 // @see header
   322 // @see header
   307 //---------------------------------------------------------------
   323 //---------------------------------------------------------------
   308 void MsgEditorWidget::onReleased()
   324 void MsgEditorWidget::onReleased()
   309     {
   325     {
   310     updateButtonBackground(SEND_BUTTON_NORMAL);
   326     updateButtonBackgroundAndColor(SEND_BUTTON_NORMAL,SEND_BUTTON_NORMAL_COLOR);
   311     }
   327     }
   312 	
   328 	
   313 //---------------------------------------------------------------
   329 //---------------------------------------------------------------
   314 // MsgEditor::setEncodingSettingsL
   330 // MsgEditor::setEncodingSettingsL
   315 // @see header
   331 // @see header