securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationcontentwidget.cpp
changeset 17 8957df7b0072
parent 15 318c4eab2439
child 19 098e361762d2
equal deleted inserted replaced
15:318c4eab2439 17:8957df7b0072
    17 */
    17 */
    18 
    18 
    19 #include "secuinotificationcontentwidget.h"
    19 #include "secuinotificationcontentwidget.h"
    20 #include "secuinotificationdialogpluginkeys.h"
    20 #include "secuinotificationdialogpluginkeys.h"
    21 #include <QGraphicsLinearLayout>
    21 #include <QGraphicsLinearLayout>
       
    22 #include <QToolButton>
    22 #include <hblabel.h>
    23 #include <hblabel.h>
    23 #include <hbpushbutton.h>
    24 #include <hbpushbutton.h>
       
    25 #include <hbiconitem.h>
    24 #include <hbcombobox.h>
    26 #include <hbcombobox.h>
    25 #include <hblineedit.h>
    27 #include <hblineedit.h>
    26 #include <hbinputeditorinterface.h>
    28 #include <hbinputeditorinterface.h>
    27 #include <QDebug>
    29 #include <QDebug>
       
    30 
       
    31 #include <HbEmailAddressFilter>
       
    32 
       
    33 #define ESecUiCancelSupported  0x1000000
       
    34 #define ESecUiCancelNotSupported  0x0000000
       
    35 
       
    36 #define ESecUiEmergencySupported  0x2000000
       
    37 #define ESecUiEmergencyNotSupported  0x0000000
       
    38 
       
    39 #define ESecUiAlphaSupported  0x4000000
       
    40 #define ESecUiAlphaNotSupported  0x0000000
       
    41 
       
    42 #define ESecUiMaskFlags  0xFF000000
       
    43 #define ESecUiMaskType   0x00FFFFFF
       
    44 
       
    45 #define ESecUiTypeDeviceLock		0x00100000
       
    46 #define ESecUiTypeKeyguard			0x00200000
       
    47 #define ESecUiTypeClock  				0x00300000
       
    48 #define ESecUiTypeScreensaver		0x00400000
       
    49 
       
    50 #define ESecUiTypeMaskLock			0x00F00000
    28 
    51 
    29 
    52 
    30 // ----------------------------------------------------------------------------
    53 // ----------------------------------------------------------------------------
    31 // SecUiNotificationContentWidget::SecUiNotificationContentWidget()
    54 // SecUiNotificationContentWidget::SecUiNotificationContentWidget()
    32 // ----------------------------------------------------------------------------
    55 // ----------------------------------------------------------------------------
    49 // SecUiNotificationContentWidget::constructFromParameters()
    72 // SecUiNotificationContentWidget::constructFromParameters()
    50 // ----------------------------------------------------------------------------
    73 // ----------------------------------------------------------------------------
    51 //
    74 //
    52 void SecUiNotificationContentWidget::constructFromParameters(const QVariantMap &parameters)
    75 void SecUiNotificationContentWidget::constructFromParameters(const QVariantMap &parameters)
    53 {
    76 {
    54 		qDebug() << "SecUiNotificationContentWidget::constructFromParameters";
    77 		qDebug() << "SecUiNotificationContentWidget::constructFromParameters 1";
    55 		qDebug() << parameters;
    78 		qDebug() << parameters;
    56     QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
    79     QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
    57 
    80 
    58     // TODO: add another layout for icon + text_block, and yet other for text_block
    81     lMinLength = 4;	// might be replaced later
    59 
    82     lMaxLength = 8;	// might be replaced later
    60     // KApplicationIcon
    83  		queryDual=0;
    61     if (1==0 && parameters.contains(KApplicationIcon)) {
    84  		isEmergency=0;
    62 				qDebug() << "SecUiNotificationContentWidget::KApplicationIcon";
       
    63         QString iconName = parameters.value(KApplicationIcon).toString();
       
    64         HbLabel *iconLabel = new HbLabel;
       
    65         iconLabel->setIcon(HbIcon(iconName));
       
    66         mainLayout->addItem(iconLabel);
       
    67     }
       
    68 
       
    69     // KApplicationName + KApplicationVersion
       
    70     if (1==0 && parameters.contains(KApplicationName)) {
       
    71 				qDebug() << "SecUiNotificationContentWidget::KApplicationName";
       
    72         QString appName = "";
       
    73         QString nameStr = parameters.value(KApplicationName).toString();
       
    74         appName = nameStr;
       
    75         HbLabel *appLabel = new HbLabel(appName);
       
    76         mainLayout->addItem(appLabel);
       
    77     }
       
    78 
    85 
    79     // KApplicationSize
    86     // KApplicationSize
    80     if (parameters.contains(KQueryType)) {
    87     if (parameters.contains(KQueryType)) {
    81 				qDebug() << "SecUiNotificationContentWidget::KQueryType";
    88 				qDebug() << "SecUiNotificationContentWidget::KQueryType";
    82         queryType = parameters.value(KQueryType).toUInt();
    89         queryType = parameters.value(KQueryType).toUInt();
    83 				qDebug() << queryType;
    90 				qDebug() << queryType;
    84     }
    91 				if( (queryType & ESecUiTypeMaskLock) )
       
    92 					{
       
    93 					qDebug() << "SecUiNotificationContentWidget::KQueryType=ESecUiTypeLock";
       
    94 					// showing "Lock" icon. All other params are irrelevant. codeTop is not even created
       
    95 
       
    96 					
       
    97         	HbLabel *iconLabel = new HbLabel("Locked");
       
    98         	HbIcon *icon = new HbIcon("qtg_large_device_lock");
       
    99         	// iconLabel->setAspectRatioMode(Qt::IgnoreAspectRatio);
       
   100     			// iconLabel->setGeometry(QRectF(QPointF(10,10),QSizeF(300,300)));
       
   101         	iconLabel->setIcon(*icon);
       
   102         	if( (queryType & ESecUiTypeMaskLock)==ESecUiTypeDeviceLock )
       
   103         		{	// really big icon for the devicelock
       
   104 	        	iconLabel->setPreferredHeight(500);
       
   105   	      	iconLabel->setPreferredWidth(500);
       
   106   	      	}
       
   107         	else if( (queryType & ESecUiTypeMaskLock)==ESecUiTypeKeyguard )
       
   108         		{	// smaller icon for the keyguard
       
   109 	        	iconLabel->setPreferredHeight(100);
       
   110   	      	iconLabel->setPreferredWidth(100);
       
   111   	      	}
       
   112 
       
   113         	// icon->setWidth(300);
       
   114         	// icon->setHeight(350);
       
   115         	// icon->setGeometry(QRectF(QPointF(10,10),QSizeF(500,300)));
       
   116         	// icon->setSize(QSizeF(300,300));
       
   117         	
       
   118         	mainLayout->addItem(iconLabel);
       
   119         	mainLayout->setAlignment(iconLabel, Qt::AlignCenter );
       
   120         	// mainLayout->setGeometry(QRectF(QPointF(10,10),QSizeF(300,300)));
       
   121         	
       
   122 					/*
       
   123 					QToolButton* mLabelIcon = new QToolButton;
       
   124 					mLabelIcon->setIcon(QIcon(":/AutolockSrv_hbicon/qtg_large_device_lock.svg"));
       
   125 					mLabelIcon->setIconSize(QSize(300,300));
       
   126 					HbLabel *iconLabel = new HbLabel("Locked");
       
   127 					iconLabel->setIcon(*mLabelIcon);
       
   128 					mainLayout->addItem(iconLabel);
       
   129 					*/
       
   130 
       
   131         	// mainLayout->setContentsMargins(10,10,300,500);	// this makes the dialog really big
       
   132 					setLayout(mainLayout);	// same as at the end
       
   133 					return;
       
   134 					}
       
   135 				// not ESecUiTypeMaskLock
       
   136 				lEmergencySupported = ESecUiEmergencyNotSupported;
       
   137 				if((queryType & ESecUiEmergencySupported)==ESecUiEmergencySupported)
       
   138 					{
       
   139 					lEmergencySupported = ESecUiEmergencySupported;
       
   140 					}
       
   141 				qDebug() << "SecUiNotificationContentWidget::lEmergencySupported =" << lEmergencySupported;
       
   142     }
       
   143 
       
   144     if (parameters.contains(KQueryMinLength)) {
       
   145 				qDebug() << "SecUiNotificationContentWidget::KQueryMinLength";
       
   146         lMinLength = parameters.value(KQueryMinLength).toUInt();
       
   147 				qDebug() << lMinLength;
       
   148     }
       
   149     if (parameters.contains(KQueryMaxLength)) {
       
   150 				qDebug() << "SecUiNotificationContentWidget::KQueryMaxLength";
       
   151         lMaxLength = parameters.value(KQueryMaxLength).toUInt();
       
   152 				qDebug() << lMaxLength;
       
   153     }
       
   154 
       
   155     if (parameters.contains(KEmergency)) {
       
   156 				qDebug() << "SecUiNotificationContentWidget::KEmergency";
       
   157         QString emergencyText = parameters.value(KEmergency).toString();
       
   158         qDebug() << emergencyText;
       
   159         if(!emergencyText.compare("emergencyYes"))
       
   160         	{
       
   161         	qDebug() << "SecUiNotificationContentWidget::KEmergency emergencyYes";
       
   162         	isEmergency = 1;
       
   163         	}
       
   164         if(!emergencyText.compare("emergencyNo"))
       
   165         	{
       
   166         	qDebug() << "SecUiNotificationContentWidget::KEmergency emergencyNo";
       
   167         	isEmergency = 0;
       
   168         	}
       
   169     }
       
   170 
    85 
   171 
    86     // KCodeTop
   172     // KCodeTop
    87     if (parameters.contains(KCodeTop)) {
   173     if (parameters.contains(KCodeTop)) {
    88 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 1";
   174 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 1";
    89         codeTop = new HbLineEdit("");	// no default value
   175         codeTop = new HbLineEdit("");	// no default value
       
   176         qDebug() << "SecUiNotificationContentWidget::KCodeTop lMaxLength=";
       
   177         qDebug() << lMaxLength;
       
   178         if(lMaxLength>2)
       
   179 	        codeTop->setMaxLength(lMaxLength);
    90         // HbLineEdit *codeTop2 = new HbLineEdit;
   180         // HbLineEdit *codeTop2 = new HbLineEdit;
    91 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 2";
   181 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 2";
    92     		HbEditorInterface editorInterface(codeTop);
   182 				qDebug() << "SecUiNotificationContentWidget::KCodeTop queryType=";
    93     		editorInterface.setUpAsPhoneNumberEditor();
   183 				qDebug() << queryType;
       
   184 				codeTop->setInputMethodHints(Qt::ImhDigitsOnly);	// default
       
   185  		    if (queryType & ESecUiAlphaSupported)
       
   186 		    	{
       
   187 		    	qDebug() << "SecUiNotificationContentWidget::KCodeTop setUpAsLatinAlphabetOnlyEditor";
       
   188  	    		codeTop->setInputMethodHints(Qt::ImhNone);
       
   189 			    // what about this: editorInterface.setEditorClass(HbInputEditorClassPassword);
       
   190 		  		}
    94 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 3";
   191 				qDebug() << "SecUiNotificationContentWidget::KCodeTop 3";
    95         connect(codeTop, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeTopChanged(const QString &)));
   192         connect(codeTop, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeTopChanged(const QString &)));
       
   193         connect(codeTop, SIGNAL(contentsChanged(const QString &)), this, SIGNAL(codeTopChanged(const QString &)));
    96     		mainLayout->addItem(codeTop);
   194     		mainLayout->addItem(codeTop);
    97         // mainLayout->addItem(codeTop2);
   195     		if (parameters.contains(KCodeBottom))
       
   196     			{
       
   197     			queryDual=1;
       
   198     			QString titleText = parameters.value(KDialogTitle).toString();
       
   199     			if(titleText.indexOf('|')>0)
       
   200     				{	// if no separator, don't create label
       
   201     				QString titleBottomStr = titleText.right(titleText.length()-titleText.indexOf('|')-1);
       
   202     				HbLabel *titleBottom = new HbLabel(titleBottomStr);
       
   203     				mainLayout->addItem(titleBottom);
       
   204     				}
       
   205     			
       
   206         	codeBottom = new HbLineEdit("");	// no default value
       
   207 	        if(lMaxLength>2)
       
   208 		        codeBottom->setMaxLength(lMaxLength);
       
   209 	    		codeBottom->setInputMethodHints(Qt::ImhDigitsOnly);	// default
       
   210 	 		    if (queryType & ESecUiAlphaSupported)
       
   211 			    	{
       
   212 			    	qDebug() << "SecUiNotificationContentWidget::KCodeBottom setUpAsLatinAlphabetOnlyEditor";
       
   213 	 	    		codeTop->setInputMethodHints(Qt::ImhNone);
       
   214 			  		}
       
   215 					qDebug() << "SecUiNotificationContentWidget::KCodeBottom 3";
       
   216 	        connect(codeBottom, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeBottomChanged(const QString &)));
       
   217         	connect(codeBottom, SIGNAL(contentsChanged(const QString &)), this, SIGNAL(codeBottomChanged(const QString &)));
       
   218 	    		mainLayout->addItem(codeBottom);
       
   219 	    		}
    98 
   220 
    99     		QGraphicsLinearLayout *mainLayoutButtons = new QGraphicsLinearLayout(Qt::Horizontal);
   221     		QGraphicsLinearLayout *mainLayoutButtons = new QGraphicsLinearLayout(Qt::Horizontal);
   100         HbPushButton *but1 = new HbPushButton("1234");
   222         HbPushButton *but1 = new HbPushButton("1234");
   101         HbPushButton *but2 = new HbPushButton("+1");
   223         HbPushButton *but2 = new HbPushButton("+1");
   102         HbPushButton *but3 = new HbPushButton("+5");
   224         HbPushButton *but3 = new HbPushButton("+5");
   111         
   233         
   112         codeTop->setFocus();
   234         codeTop->setFocus();
   113 
   235 
   114     }
   236     }
   115 
   237 
   116     // KCertificates
       
   117     // KDrmDetails
       
   118 
       
   119     setLayout(mainLayout);
   238     setLayout(mainLayout);
   120     }
   239     }
   121 
   240