24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 #include <QDir> |
25 #include <QDir> |
26 #include <QtAlgorithms> |
26 #include <QtAlgorithms> |
27 |
27 |
28 #include <hbinputdef.h> |
28 #include <hbinputdef.h> |
29 #include <hblistdialog.h> |
29 #include <hbselectiondialog.h> |
30 #include <hblistwidgetitem.h> |
30 #include <hblistwidgetitem.h> |
31 #include <hbinpututils.h> |
31 #include <hbinpututils.h> |
32 #include <hbinputsettingproxy.h> |
32 #include <hbinputsettingproxy.h> |
33 #include <hbinputmethod.h> |
33 #include <hbinputmethod.h> |
34 |
34 |
49 /*! |
49 /*! |
50 Displays language selection dialog and returns selected language. |
50 Displays language selection dialog and returns selected language. |
51 */ |
51 */ |
52 HbInputLanguage HbInputCommonDialogs::showLanguageSelectionDialog(QLocale::Language selectedLanguage, const QList<HbInputLanguage> languageList) |
52 HbInputLanguage HbInputCommonDialogs::showLanguageSelectionDialog(QLocale::Language selectedLanguage, const QList<HbInputLanguage> languageList) |
53 { |
53 { |
54 HbListDialog* langDialog = new HbListDialog(); |
54 HbSelectionDialog* langDialog = new HbSelectionDialog(); |
55 langDialog->setObjectName("Language dialog"); |
55 langDialog->setObjectName("Language dialog"); |
56 |
56 |
57 #if QT_VERSION >= 0x040600 |
57 #if QT_VERSION >= 0x040600 |
58 // Make sure the language dialog never steals focus. |
58 // Make sure the language dialog never steals focus. |
59 langDialog->setFlag(QGraphicsItem::ItemIsPanel, true); |
59 langDialog->setFlag(QGraphicsItem::ItemIsPanel, true); |
78 langName = QString("Unknown"); |
78 langName = QString("Unknown"); |
79 } |
79 } |
80 item = new HbListWidgetItem(); |
80 item = new HbListWidgetItem(); |
81 item->setText(langName); |
81 item->setText(langName); |
82 if (language == currentLang ) { |
82 if (language == currentLang ) { |
83 QList<int> selected; |
83 QList<QVariant> selected; |
84 selected.append(listItems.count()); |
84 selected.append(listItems.count()); |
85 langDialog->setSelectedItems(selected); |
85 langDialog->setSelectedItems(selected); |
86 } |
86 } |
87 if (language.language() == QLocale::Chinese) { |
87 if (language.language() == QLocale::Chinese) { |
88 item->setData(language.variant(), Hb::UserRole); |
88 item->setData(language.variant(), Hb::UserRole); |
94 } |
94 } |
95 langDialog->setWidgetItems(listItems, true); |
95 langDialog->setWidgetItems(listItems, true); |
96 langDialog->setSelectionMode(HbAbstractItemView::SingleSelection); |
96 langDialog->setSelectionMode(HbAbstractItemView::SingleSelection); |
97 langDialog->setDismissPolicy(HbPopup::NoDismiss); |
97 langDialog->setDismissPolicy(HbPopup::NoDismiss); |
98 langDialog->setModal(true); |
98 langDialog->setModal(true); |
99 langDialog->exec(); |
99 //langDialog->exec(); TODO |
100 //TODO: needed to check from action which button was pressed (ok, cancel) |
100 //TODO: needed to check from action which button was pressed (ok, cancel) |
101 //HbAction* action = langDialog->exec(); |
101 //HbAction* action = langDialog->exec(); |
102 if (langDialog->selectedItems().count()) { |
102 if (langDialog->selectedItems().count()) { |
103 int selection = langDialog->selectedItems().at(0); |
103 int selection = langDialog->selectedItems().at(0).toInt(); |
104 HbInputLanguage result; |
104 HbInputLanguage result; |
105 if(languages.at(selection).language() == QLocale::Chinese) { |
105 if(languages.at(selection).language() == QLocale::Chinese) { |
106 result = languages.at(selection); |
106 result = languages.at(selection); |
107 } else { |
107 } else { |
108 result = languages.at(selection).language(); |
108 result = languages.at(selection).language(); |
120 */ |
120 */ |
121 HbInputMethodDescriptor HbInputCommonDialogs::showCustomInputMethodSelectionDialog(const HbInputLanguage &language) |
121 HbInputMethodDescriptor HbInputCommonDialogs::showCustomInputMethodSelectionDialog(const HbInputLanguage &language) |
122 { |
122 { |
123 Q_UNUSED(language); |
123 Q_UNUSED(language); |
124 |
124 |
125 HbListDialog* methodDialog = new HbListDialog(); |
125 HbSelectionDialog* methodDialog = new HbSelectionDialog(); |
126 methodDialog->setObjectName("Input method dialog"); |
126 methodDialog->setObjectName("Input method dialog"); |
127 |
127 |
128 #if QT_VERSION >= 0x040600 |
128 #if QT_VERSION >= 0x040600 |
129 // Make sure the language dialog never steals focus. |
129 // Make sure the language dialog never steals focus. |
130 methodDialog->setFlag(QGraphicsItem::ItemIsPanel, true); |
130 methodDialog->setFlag(QGraphicsItem::ItemIsPanel, true); |
151 } |
151 } |
152 methodDialog->setWidgetItems(listItems, true); |
152 methodDialog->setWidgetItems(listItems, true); |
153 methodDialog->setSelectionMode(HbAbstractItemView::SingleSelection); |
153 methodDialog->setSelectionMode(HbAbstractItemView::SingleSelection); |
154 methodDialog->setDismissPolicy(HbPopup::NoDismiss); |
154 methodDialog->setDismissPolicy(HbPopup::NoDismiss); |
155 methodDialog->setModal(true); |
155 methodDialog->setModal(true); |
156 methodDialog->exec(); |
156 //methodDialog->exec(); TODO |
157 //TODO: needed to check from action which button was pressed (ok, cancel) |
157 //TODO: needed to check from action which button was pressed (ok, cancel) |
158 //HbAction* action = langDialog->exec(); |
158 //HbAction* action = langDialog->exec(); |
159 |
159 |
160 HbInputMethodDescriptor result; |
160 HbInputMethodDescriptor result; |
161 if (methodDialog->selectedItems().count()) { |
161 if (methodDialog->selectedItems().count()) { |
162 int selection = methodDialog->selectedItems().first(); |
162 int selection = methodDialog->selectedItems().first().toInt(); |
163 if (selection == 0) { |
163 if (selection == 0) { |
164 result.setDefault(); |
164 result.setDefault(); |
165 } else { |
165 } else { |
166 result = customList[selection-1]; |
166 result = customList[selection-1]; |
167 } |
167 } |