summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/keypadnavigation/keypadnavigation.ui105
-rw-r--r--tests/manual/keypadnavigation/main.cpp114
2 files changed, 191 insertions, 28 deletions
diff --git a/tests/manual/keypadnavigation/keypadnavigation.ui b/tests/manual/keypadnavigation/keypadnavigation.ui
index e0db662..6b11ae0 100644
--- a/tests/manual/keypadnavigation/keypadnavigation.ui
+++ b/tests/manual/keypadnavigation/keypadnavigation.ui
@@ -1058,6 +1058,79 @@ As a reward you can try out the QDial, below.</string>
</item>
</layout>
</widget>
+ <widget class="QWidget" name="m_pageDialogs">
+ <layout class="QVBoxLayout" name="verticalLayout_13">
+ <item>
+ <widget class="QPushButton" name="m_buttonGetOpenFileName">
+ <property name="text">
+ <string>QFileDialog::getOpenFileName()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetSaveFileName">
+ <property name="text">
+ <string>QFileDialog::getSaveFileName()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetExistingDirectory">
+ <property name="text">
+ <string>QFileDialog::getExistingDirectory()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetColor">
+ <property name="text">
+ <string>QColorDialog::getColor()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetFont">
+ <property name="text">
+ <string>QFontDialog::getFont()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonQuestion">
+ <property name="text">
+ <string>QMessageBox::question()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonAboutQt">
+ <property name="text">
+ <string>QMessageBox::aboutQt()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetItem">
+ <property name="text">
+ <string>QInputDialog::getItem()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>104</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
@@ -1080,6 +1153,7 @@ As a reward you can try out the QDial, below.</string>
<addaction name="m_actionLayoutTwoDimensional"/>
<addaction name="m_actionLayoutSliderMagic"/>
<addaction name="m_actionLayoutChaos"/>
+ <addaction name="m_actionLayoutDialogs"/>
</widget>
<widget class="QMenu" name="menuNavigation_mode">
<property name="title">
@@ -1144,14 +1218,22 @@ As a reward you can try out the QDial, below.</string>
<string>CursorForceVisible</string>
</property>
</action>
+ <action name="m_actionLayoutDialogs">
+ <property name="text">
+ <string>Dialogs</string>
+ </property>
+ <property name="toolTip">
+ <string>m_actionLayoutDialogs</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
- <tabstop>lineEdit</tabstop>
- <tabstop>horizontalSlider</tabstop>
- <tabstop>lineEdit_4</tabstop>
- <tabstop>horizontalSlider_2</tabstop>
- <tabstop>dateEdit</tabstop>
+ <tabstop>m_buttonGetOpenFileName</tabstop>
+ <tabstop>m_buttonGetSaveFileName</tabstop>
+ <tabstop>m_buttonGetExistingDirectory</tabstop>
+ <tabstop>m_buttonGetColor</tabstop>
+ <tabstop>m_buttonGetFont</tabstop>
<tabstop>comboBox</tabstop>
<tabstop>plainTextEdit</tabstop>
<tabstop>pushButton</tabstop>
@@ -1169,7 +1251,6 @@ As a reward you can try out the QDial, below.</string>
<tabstop>toolButton_3</tabstop>
<tabstop>horizontalSlider_6</tabstop>
<tabstop>horizontalSlider_5</tabstop>
- <tabstop>scrollArea_3</tabstop>
<tabstop>lineEdit_13</tabstop>
<tabstop>toolButton_31</tabstop>
<tabstop>lineEdit_14</tabstop>
@@ -1202,7 +1283,17 @@ As a reward you can try out the QDial, below.</string>
<tabstop>toolButton_16</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>scrollArea_2</tabstop>
- <tabstop>scrollArea</tabstop>
+ <tabstop>horizontalSlider_4</tabstop>
+ <tabstop>horizontalSlider_3</tabstop>
+ <tabstop>tabWidget_2</tabstop>
+ <tabstop>toolButton_2</tabstop>
+ <tabstop>toolButton_7</tabstop>
+ <tabstop>toolButton_13</tabstop>
+ <tabstop>lineEdit_4</tabstop>
+ <tabstop>lineEdit</tabstop>
+ <tabstop>horizontalSlider</tabstop>
+ <tabstop>horizontalSlider_2</tabstop>
+ <tabstop>dateEdit</tabstop>
</tabstops>
<resources/>
<connections>
diff --git a/tests/manual/keypadnavigation/main.cpp b/tests/manual/keypadnavigation/main.cpp
index 0e4bf31..d1cc8a7 100644
--- a/tests/manual/keypadnavigation/main.cpp
+++ b/tests/manual/keypadnavigation/main.cpp
@@ -53,29 +53,57 @@ public:
{
ui->setupUi(this);
- connect(ui->m_actionLayoutVerticalSimple, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutVerticalSimple, ui->m_pageVerticalSimple);
- connect(ui->m_actionLayoutVerticalComplex, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutVerticalComplex, ui->m_pageVerticalComplex);
- connect(ui->m_actionLayoutTwoDimensional, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutTwoDimensional, ui->m_pageTwoDimensional);
- connect(ui->m_actionLayoutSliderMagic, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutSliderMagic, ui->m_pageSliderMagic);
- connect(ui->m_actionLayoutChaos, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutChaos, ui->m_pageChaos);
+ const struct {
+ QObject *action;
+ QWidget *page;
+ } layoutMappings[] = {
+ {ui->m_actionLayoutVerticalSimple, ui->m_pageVerticalSimple},
+ {ui->m_actionLayoutVerticalComplex, ui->m_pageVerticalComplex},
+ {ui->m_actionLayoutTwoDimensional, ui->m_pageTwoDimensional},
+ {ui->m_actionLayoutSliderMagic, ui->m_pageSliderMagic},
+ {ui->m_actionLayoutChaos, ui->m_pageChaos},
+ {ui->m_actionLayoutDialogs, ui->m_pageDialogs}
+ };
+ for (int i = 0; i < int(sizeof layoutMappings / sizeof layoutMappings[0]); ++i) {
+ connect(layoutMappings[i].action, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
+ m_layoutSignalMapper.setMapping(layoutMappings[i].action, layoutMappings[i].page);
+ }
connect(&m_layoutSignalMapper, SIGNAL(mapped(QWidget*)), ui->m_stackWidget, SLOT(setCurrentWidget(QWidget*)));
- connect(ui->m_actionModeNone, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeNone, int(Qt::NavigationModeNone));
- connect(ui->m_actionModeKeypadTabOrder, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeKeypadTabOrder, int(Qt::NavigationModeKeypadTabOrder));
- connect(ui->m_actionModeKeypadDirectional, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeKeypadDirectional, int(Qt::NavigationModeKeypadDirectional));
- connect(ui->m_actionModeCursorAuto, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeCursorAuto, int(Qt::NavigationModeCursorAuto));
- connect(ui->m_actionModeCursorForceVisible, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeCursorForceVisible, int(Qt::NavigationModeCursorForceVisible));
+ const struct {
+ QObject *action;
+ Qt::NavigationMode mode;
+ } modeMappings[] = {
+ {ui->m_actionModeNone, Qt::NavigationModeNone},
+ {ui->m_actionModeKeypadTabOrder, Qt::NavigationModeKeypadTabOrder},
+ {ui->m_actionModeKeypadDirectional, Qt::NavigationModeKeypadDirectional},
+ {ui->m_actionModeCursorAuto, Qt::NavigationModeCursorAuto},
+ {ui->m_actionModeCursorForceVisible, Qt::NavigationModeCursorForceVisible}
+ };
+ for (int i = 0; i < int(sizeof modeMappings / sizeof modeMappings[0]); ++i) {
+ connect(modeMappings[i].action, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
+ m_modeSignalMapper.setMapping(modeMappings[i].action, int(modeMappings[i].mode));
+ }
connect(&m_modeSignalMapper, SIGNAL(mapped(int)), SLOT(setNavigationMode(int)));
+
+ const struct {
+ QObject *button;
+ Dialog dialog;
+ } openDialogMappings[] = {
+ {ui->m_buttonGetOpenFileName, DialogGetOpenFileName},
+ {ui->m_buttonGetSaveFileName, DialogGetSaveFileName},
+ {ui->m_buttonGetExistingDirectory, DialogGetExistingDirectory},
+ {ui->m_buttonGetColor, DialogGetColor},
+ {ui->m_buttonGetFont, DialogGetFont},
+ {ui->m_buttonQuestion, DialogQuestion},
+ {ui->m_buttonAboutQt, DialogAboutQt},
+ {ui->m_buttonGetItem, DialogGetItem}
+ };
+ for (int i = 0; i < int(sizeof openDialogMappings / sizeof openDialogMappings[0]); ++i) {
+ connect(openDialogMappings[i].button, SIGNAL(clicked()), &m_dialogSignalMapper, SLOT(map()));
+ m_dialogSignalMapper.setMapping(openDialogMappings[i].button, int(openDialogMappings[i].dialog));
+ }
+ connect(&m_dialogSignalMapper, SIGNAL(mapped(int)), SLOT(openDialog(int)));
}
~KeypadNavigation()
@@ -83,16 +111,60 @@ public:
delete ui;
}
-public slots:
+protected slots:
void setNavigationMode(int mode)
{
QApplication::setNavigationMode(Qt::NavigationMode(mode));
}
+ void openDialog(int dialog)
+ {
+ switch (Dialog(dialog)) {
+ case DialogGetOpenFileName:
+ QFileDialog::getOpenFileName(this, QLatin1String("getOpenFileName"));
+ break;
+ case DialogGetSaveFileName:
+ QFileDialog::getSaveFileName(this, QLatin1String("getSaveFileName"));
+ break;
+ case DialogGetExistingDirectory:
+ QFileDialog::getExistingDirectory(this, QLatin1String("getExistingDirectory"));
+ break;
+ case DialogGetColor:
+ QColorDialog::getColor(QColor(Qt::green), this, QLatin1String("getColor"));
+ break;
+ case DialogGetFont:
+ QFontDialog::getFont(0, this);
+ break;
+ case DialogQuestion:
+ QMessageBox::question(this, QLatin1String("question"), QLatin1String("¿Hola, que tal?"));
+ break;
+ case DialogAboutQt:
+ QMessageBox::aboutQt(this);
+ break;
+ case DialogGetItem:
+ QInputDialog::getItem(this, QLatin1String("getItem"), QLatin1String("Choose a color"), QColor::colorNames());
+ break;
+ default:
+ break;
+ }
+ }
+
private:
+ enum Dialog {
+ DialogGetOpenFileName,
+ DialogGetSaveFileName,
+ DialogGetExistingDirectory,
+ DialogGetColor,
+ DialogGetFont,
+ DialogQuestion,
+ DialogAboutQt,
+ DialogGetItem
+ };
+
Ui_KeypadNavigation *ui;
QSignalMapper m_layoutSignalMapper;
QSignalMapper m_modeSignalMapper;
+ QSignalMapper m_dialogSignalMapper;
};
int main(int argc, char *argv[])