appinstaller/AppinstUi/sifuidevicedialogplugin/src/sifuidialogtitlewidget.cpp
changeset 29 26b6f0522fd8
parent 25 98b66e4fb0be
child 37 6e7b00453237
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
    19 #include "sifuidialog.h"                    // dialogType, dialogMode
    19 #include "sifuidialog.h"                    // dialogType, dialogMode
    20 #include <QGraphicsLinearLayout>
    20 #include <QGraphicsLinearLayout>
    21 #include <hblabel.h>
    21 #include <hblabel.h>
    22 #include <hbpushbutton.h>
    22 #include <hbpushbutton.h>
    23 
    23 
    24 // See definitions in sifuidevicedialogplugin.qrc
    24 const char KSifUiCertTrusted[]    = "qtg_small_secure.svg";
    25 const char KSifUiDialogIconCertificates[] = ":/cert_indi_icon.svg";
    25 // TODO: enable when available, take also in use
       
    26 //const char KSifUiCertNotTrusted[] = "qtg_small_untrusted.svg";
    26 
    27 
    27 
    28 
    28 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    29 // SifUiDialogTitleWidget::SifUiDialogTitleWidget()
    30 // SifUiDialogTitleWidget::SifUiDialogTitleWidget()
    30 // ----------------------------------------------------------------------------
    31 // ----------------------------------------------------------------------------
    56     if (parameters.contains(KSifUiDialogTitle)) {
    57     if (parameters.contains(KSifUiDialogTitle)) {
    57         QString titleText = parameters.value(KSifUiDialogTitle).toString();
    58         QString titleText = parameters.value(KSifUiDialogTitle).toString();
    58         titleLabel = new HbLabel(titleText);
    59         titleLabel = new HbLabel(titleText);
    59     } else {
    60     } else {
    60         SifUiDeviceDialogType type = SifUiDialog::dialogType(parameters);
    61         SifUiDeviceDialogType type = SifUiDialog::dialogType(parameters);
    61         SifUiDeviceDialogMode mode = SifUiDialog::dialogMode(parameters);
    62         titleLabel = new HbLabel(defaultTitle(type));
    62         titleLabel = new HbLabel(defaultTitle(type, mode));
       
    63     }
    63     }
    64     titleLabel->setFontSpec(HbFontSpec(HbFontSpec::Title));
    64     titleLabel->setFontSpec(HbFontSpec(HbFontSpec::Title));
    65     mLayout->addItem(titleLabel);
    65     mLayout->addItem(titleLabel);
    66     mTitle = titleLabel;
    66     mTitle = titleLabel;
    67 
    67 
    81     QString titleText;
    81     QString titleText;
    82     if (parameters.contains(KSifUiDialogTitle)) {
    82     if (parameters.contains(KSifUiDialogTitle)) {
    83         titleText = parameters.value(KSifUiDialogTitle).toString();
    83         titleText = parameters.value(KSifUiDialogTitle).toString();
    84     } else {
    84     } else {
    85         SifUiDeviceDialogType type = SifUiDialog::dialogType(parameters);
    85         SifUiDeviceDialogType type = SifUiDialog::dialogType(parameters);
    86         SifUiDeviceDialogMode mode = SifUiDialog::dialogMode(parameters);
    86         titleText = defaultTitle(type);
    87         titleText = defaultTitle(type, mode);
       
    88     }
    87     }
    89     if (titleText != mTitle->plainText()) {
    88     if (titleText != mTitle->plainText()) {
    90         mTitle->setPlainText(titleText);
    89         mTitle->setPlainText(titleText);
    91     }
       
    92 
       
    93     if (parameters.contains(KSifUiCertificates)) {
       
    94         createCertButton();
       
    95     } else {
       
    96         removeCertButton();
       
    97     }
    90     }
    98 }
    91 }
    99 
    92 
   100 // ----------------------------------------------------------------------------
    93 // ----------------------------------------------------------------------------
   101 // SifUiDialogTitleWidget::defaultTitle()
    94 // SifUiDialogTitleWidget::defaultTitle()
   102 // ----------------------------------------------------------------------------
    95 // ----------------------------------------------------------------------------
   103 //
    96 //
   104 QString SifUiDialogTitleWidget::defaultTitle(SifUiDeviceDialogType type,
    97 QString SifUiDialogTitleWidget::defaultTitle(SifUiDeviceDialogType type)
   105     SifUiDeviceDialogMode mode)
       
   106 {
    98 {
   107     QString title;
    99     QString title;
   108     switch (mode) {
   100     switch (type) {
   109         case SifUiInstalling:
   101         case SifUiConfirmationQuery:
   110             switch (type) {
   102             //: Install confirmation query title. Installation starts if
   111                 case SifUiConfirmationQuery:
   103             //: the user accepts the query.
   112                     //: Install confirmation query title. Installation starts if
   104             // TODO: enable when translations ready
   113                     //: the user accepts the query.
   105             //title = hbTrId("txt_sisxui_install_conf_head");
   114                     // TODO: enable when translations ready
   106             title = tr("Install?");
   115                     //title = hbTrId("txt_sisxui_install_conf_head");
       
   116                     title = tr("Install?");
       
   117                     break;
       
   118                 case SifUiProgressNote:
       
   119                     //: Progress note title. Installation is going on and progress
       
   120                     //: bar shows how it proceeds.
       
   121                     // TODO: enable when translations ready
       
   122                     //title = hbTrId("txt_sisxui_installing_progress_head");
       
   123                     title = tr("Installing");
       
   124                     break;
       
   125                 case SifUiCompleteNote:
       
   126                     //: Installation complete note title. Indicates that installation
       
   127                     //: was succesfully completed. User has option to launch AppLib
       
   128                     // TODO: enable when translations ready
       
   129                     //title = hbTrId("txt_sisxui_install_complete_head");
       
   130                     title = tr("Installed");
       
   131                     break;
       
   132                 case SifUiErrorNote:
       
   133                     //: Installation failed note title. Indicates that installation failed.
       
   134                     // TODO: enable when translations ready
       
   135                     //title = hbTrId("txt_sisxui_install_failed_head");
       
   136                     title = tr("Install failed");
       
   137                     break;
       
   138                 case SifUiUnspecifiedDialog:
       
   139                 default:
       
   140                     break;
       
   141             }
       
   142             break;
   107             break;
   143         case SifUiUninstalling:
   108         case SifUiProgressNote:
   144             switch (type) {
   109             //: Progress note title. Installation is going on and progress
   145                 case SifUiConfirmationQuery:
   110             //: bar shows how it proceeds.
   146                     //: Uninstall confirmation query title. Asks permission to
   111             // TODO: enable when translations ready
   147                     //: remove selected application/other content.
   112             //title = hbTrId("txt_sisxui_installing_progress_head");
   148                     // TODO: enable when translations ready
   113             title = tr("Installing");
   149                     //title = hbTrId("txt_sisxui_uninstall_conf_head");
       
   150                     title = tr("Remove?");
       
   151                     break;
       
   152                 case SifUiProgressNote:
       
   153                     //: Progress note title. Uninstallation is going on and progress
       
   154                     //: bar shows how it proceeds.
       
   155                     // TODO: enable when translations ready
       
   156                     //title = hbTrId("txt_sisxui_uninstalling_progress_head");
       
   157                     title = tr("Removing");
       
   158                     break;
       
   159                 case SifUiCompleteNote:
       
   160                     //: Uninstallation complete note title. Indicates that application
       
   161                     //: was succesfully removed.
       
   162                     // TODO: enable when translations ready
       
   163                     //title = hbTrId("txt_sisxui_uninstall_complete_head");
       
   164                     title = tr("Removed");
       
   165                     break;
       
   166                 case SifUiErrorNote:
       
   167                     //: Uninstallation failed note title. Indicates that uninstallation failed.
       
   168                     // TODO: enable when translations ready
       
   169                     //title = hbTrId("txt_sisxui_uninstall_failed_head");
       
   170                     title = tr("Uninstall failed");
       
   171                     break;
       
   172                 case SifUiUnspecifiedDialog:
       
   173                 default:
       
   174                     break;
       
   175             }
       
   176             break;
   114             break;
   177         case SifUiUnspecified:
   115         case SifUiCompleteNote:
       
   116             //: Installation complete note title. Indicates that installation
       
   117             //: was succesfully completed. User has option to launch AppLib
       
   118             // TODO: enable when translations ready
       
   119             //title = hbTrId("txt_sisxui_install_complete_head");
       
   120             title = tr("Installed");
       
   121             break;
       
   122         case SifUiErrorNote:
       
   123             //: Installation failed note title. Indicates that installation failed.
       
   124             // TODO: enable when translations ready
       
   125             //title = hbTrId("txt_sisxui_install_failed_head");
       
   126             title = tr("Install failed");
       
   127             break;
       
   128         case SifUiUnspecifiedDialog:
   178         default:
   129         default:
   179             break;
   130             break;
   180     }
   131     }
   181     return title;
   132     return title;
   182 }
   133 }
   187 //
   138 //
   188 void SifUiDialogTitleWidget::createCertButton()
   139 void SifUiDialogTitleWidget::createCertButton()
   189 {
   140 {
   190     if (!mCertButton) {
   141     if (!mCertButton) {
   191         HbPushButton *certButton = new HbPushButton;
   142         HbPushButton *certButton = new HbPushButton;
   192         certButton->setIcon(HbIcon(KSifUiDialogIconCertificates));
   143         // TODO: show KSifUiCertNotTrusted when needed (and when available)
       
   144         certButton->setIcon(HbIcon(KSifUiCertTrusted));
   193         connect(certButton,SIGNAL(clicked()),this,SIGNAL(certificatesClicked()));
   145         connect(certButton,SIGNAL(clicked()),this,SIGNAL(certificatesClicked()));
   194         mLayout->addStretch();
   146         mLayout->addStretch();
   195         mLayout->addItem(certButton);
   147         mLayout->addItem(certButton);
   196         mLayout->setAlignment(certButton, Qt::AlignRight|Qt::AlignVCenter);
   148         mLayout->setAlignment(certButton, Qt::AlignRight|Qt::AlignVCenter);
   197         mCertButton = certButton;
   149         mCertButton = certButton;