tests/manual/keypadnavigation/main.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    68             connect(layoutMappings[i].action, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
    68             connect(layoutMappings[i].action, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
    69             m_layoutSignalMapper.setMapping(layoutMappings[i].action, layoutMappings[i].page);
    69             m_layoutSignalMapper.setMapping(layoutMappings[i].action, layoutMappings[i].page);
    70         }
    70         }
    71         connect(&m_layoutSignalMapper, SIGNAL(mapped(QWidget*)), ui->m_stackWidget, SLOT(setCurrentWidget(QWidget*)));
    71         connect(&m_layoutSignalMapper, SIGNAL(mapped(QWidget*)), ui->m_stackWidget, SLOT(setCurrentWidget(QWidget*)));
    72 
    72 
       
    73 #ifdef QT_KEYPAD_NAVIGATION
    73         const struct {
    74         const struct {
    74             QObject *action;
    75             QObject *action;
    75             Qt::NavigationMode mode;
    76             Qt::NavigationMode mode;
    76         } modeMappings[] = {
    77         } modeMappings[] = {
    77             {ui->m_actionModeNone,                  Qt::NavigationModeNone},
    78             {ui->m_actionModeNone,                  Qt::NavigationModeNone},
    83         for (int i = 0; i < int(sizeof modeMappings / sizeof modeMappings[0]); ++i) {
    84         for (int i = 0; i < int(sizeof modeMappings / sizeof modeMappings[0]); ++i) {
    84             connect(modeMappings[i].action, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
    85             connect(modeMappings[i].action, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
    85             m_modeSignalMapper.setMapping(modeMappings[i].action, int(modeMappings[i].mode));
    86             m_modeSignalMapper.setMapping(modeMappings[i].action, int(modeMappings[i].mode));
    86         }
    87         }
    87         connect(&m_modeSignalMapper, SIGNAL(mapped(int)), SLOT(setNavigationMode(int)));
    88         connect(&m_modeSignalMapper, SIGNAL(mapped(int)), SLOT(setNavigationMode(int)));
       
    89 #else // QT_KEYPAD_NAVIGATION
       
    90         ui->m_menuNavigation_mode->deleteLater();
       
    91 #endif // QT_KEYPAD_NAVIGATION
    88 
    92 
    89         const struct {
    93         const struct {
    90             QObject *button;
    94             QObject *button;
    91             Dialog dialog;
    95             Dialog dialog;
    92         } openDialogMappings[] = {
    96         } openDialogMappings[] = {
   110     {
   114     {
   111         delete ui;
   115         delete ui;
   112     }
   116     }
   113 
   117 
   114 protected slots:
   118 protected slots:
       
   119 #ifdef QT_KEYPAD_NAVIGATION
   115     void setNavigationMode(int mode)
   120     void setNavigationMode(int mode)
   116     {
   121     {
   117         QApplication::setNavigationMode(Qt::NavigationMode(mode));
   122         QApplication::setNavigationMode(Qt::NavigationMode(mode));
   118     }
   123     }
       
   124 #endif // QT_KEYPAD_NAVIGATION
   119 
   125 
   120     void openDialog(int dialog)
   126     void openDialog(int dialog)
   121     {
   127     {
   122         switch (Dialog(dialog)) {
   128         switch (Dialog(dialog)) {
   123             case DialogGetOpenFileName:
   129             case DialogGetOpenFileName:
   161         DialogGetItem
   167         DialogGetItem
   162     };
   168     };
   163 
   169 
   164     Ui_KeypadNavigation *ui;
   170     Ui_KeypadNavigation *ui;
   165     QSignalMapper m_layoutSignalMapper;
   171     QSignalMapper m_layoutSignalMapper;
       
   172 #ifdef QT_KEYPAD_NAVIGATION
   166     QSignalMapper m_modeSignalMapper;
   173     QSignalMapper m_modeSignalMapper;
       
   174 #endif // QT_KEYPAD_NAVIGATION
   167     QSignalMapper m_dialogSignalMapper;
   175     QSignalMapper m_dialogSignalMapper;
   168 };
   176 };
   169 
   177 
   170 int main(int argc, char *argv[])
   178 int main(int argc, char *argv[])
   171 {
   179 {