--- a/src/hbinput/inputwidgets/hbinputsettinglist.cpp Wed Jun 23 18:33:25 2010 +0300
+++ b/src/hbinput/inputwidgets/hbinputsettinglist.cpp Tue Jul 06 14:36:53 2010 +0300
@@ -27,6 +27,7 @@
#include <QGraphicsLinearLayout>
#include <QGraphicsGridLayout>
+#include <hbmainwindow.h>
#include <hblabel.h>
#include <hbpushbutton.h>
#include <hblistwidget.h>
@@ -36,20 +37,28 @@
#include <hbinpututils.h>
#include <hbinputpredictionfactory.h>
#include <hbinputregioncollector_p.h>
+#include <hbinputmethodselectionlist.h>
#include "hbdialog_p.h"
const QString settingsIcon("qtg_mono_settings");
const QString inputMethodIcon("qtg_mono_virtual_input");
+const qreal HbSelectionListMarginInUnits = 0.8;
+const qreal HbSelectionListLandscapeAlignInUnits = 9.4;
+
/// @cond
class HbInputSettingListPrivate : public HbDialogPrivate
{
+ Q_DECLARE_PUBLIC(HbInputSettingList)
+
public:
HbInputSettingListPrivate();
+ ~HbInputSettingListPrivate();
qreal languageNameWidth();
+ void showInputMethodSelectionList();
public:
HbPushButton *mLanguageButton;
@@ -58,13 +67,19 @@
HbInputLanguage mPrimaryLanguage;
HbInputLanguage mSecondaryLanguage;
QList<QString> mPredictionValues;
+ HbInputMethodSelectionList *mInputMethodSelectionList;
};
HbInputSettingListPrivate::HbInputSettingListPrivate()
- : mLanguageButton(0), mPredictionButton(0), mOptionList(0)
+ : mLanguageButton(0), mPredictionButton(0), mOptionList(0), mInputMethodSelectionList(0)
{
}
+HbInputSettingListPrivate::~HbInputSettingListPrivate()
+{
+ delete mInputMethodSelectionList;
+}
+
qreal HbInputSettingListPrivate::languageNameWidth()
{
qreal nameWidth(0);
@@ -82,6 +97,30 @@
return nameWidth;
}
+void HbInputSettingListPrivate::showInputMethodSelectionList()
+{
+ Q_Q(HbInputSettingList);
+
+ delete mInputMethodSelectionList;
+ mInputMethodSelectionList = new HbInputMethodSelectionList();
+ mInputMethodSelectionList->setObjectName("Input method selection list");
+
+ qreal unitValue = HbDeviceProfile::profile(q->mainWindow()).unitValue();
+
+ QPointF position(q->scenePos().x() + q->size().width(),
+ mOptionList->scenePos().y() - HbSelectionListMarginInUnits * unitValue);
+
+ if (q->mainWindow()->orientation() == Qt::Horizontal) {
+ position.setX(position.x() - HbSelectionListLandscapeAlignInUnits * unitValue);
+ }
+
+ mInputMethodSelectionList->setPreferredPos(position, HbPopup::BottomRightCorner);
+
+ QObject::connect(mInputMethodSelectionList, SIGNAL(inputMethodSelected(const HbInputMethodDescriptor &, const QByteArray &)),
+ q, SLOT(closeSettings(const HbInputMethodDescriptor &, const QByteArray &)));
+ mInputMethodSelectionList->show();
+}
+
/// @endcond
/*!
@@ -93,6 +132,13 @@
Q_D(HbInputSettingList);
HbInputRegionCollector::instance()->attach(this);
+ // Get correct size from style parameters
+ HbStyle style;
+ qreal listWidth(300);
+ style.parameter(QString("expr(var(hb-param-screen-short-edge)-(2*var(hb-param-margin-gene-screen)))"), listWidth);
+ qreal margin(5);
+ style.parameter(QString("hb-param-margin-gene-popup"), margin);
+
QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
QGraphicsGridLayout *gridLayout = new QGraphicsGridLayout();
@@ -113,24 +159,25 @@
d->mOptionList->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
d->mOptionList->setObjectName("Input options list");
d->mOptionList->addItem(HbIcon(settingsIcon), tr("Input settings"));
- d->mOptionList->setPreferredWidth(300);
+ d->mOptionList->setContentsMargins(0, 0, 0, 0);
+ d->mOptionList->setPreferredWidth(listWidth - 2 * margin);
gridLayout->addItem(languageLabel, 0, 0);
gridLayout->addItem(d->mLanguageButton, 0, 1);
gridLayout->addItem(predictionLabel, 1, 0);
gridLayout->addItem(d->mPredictionButton, 1, 1);
+ gridLayout->setContentsMargins(0, 0, 0, 0);
- qreal buttonWidth = 30 + d->languageNameWidth();
- gridLayout->setColumnFixedWidth(0, 300 - buttonWidth);
- gridLayout->setColumnFixedWidth(1, buttonWidth);
-
- qreal buttonHeight = buttonWidth * 0.4;
- gridLayout->setRowFixedHeight(0, buttonHeight);
- gridLayout->setRowFixedHeight(1, buttonHeight);
+ // Width for language button is based on the width of language name string and button margins
+ qreal buttonMargin(20);
+ style.parameter(QString("expr(var(hb-param-margin-gene-left)+var(hb-param-margin-gene-right))"), buttonMargin);
+ gridLayout->setColumnFixedWidth(1, buttonMargin + d->languageNameWidth());
mainLayout->addItem(gridLayout);
mainLayout->addItem(d->mOptionList);
+ mainLayout->setContentsMargins(0, 0, 0, 0);
QGraphicsWidget *content = new QGraphicsWidget(this);
+ content->setContentsMargins(0, 0, 0, 0);
content->setLayout(mainLayout);
setContentWidget(content);
@@ -141,8 +188,10 @@
setTimeout(HbDialog::NoTimeout);
setBackgroundFaded(false);
setDismissPolicy(TapOutside);
+ setContentsMargins(margin, margin, margin, margin);
+ setPreferredWidth(listWidth);
- // Make sure the custom button list never steals focus.
+ // Make sure the input settings list never steals focus.
setFlag(QGraphicsItem::ItemIsPanel, true);
setActive(false);
@@ -155,6 +204,8 @@
connect(settings, SIGNAL(globalInputLanguageChanged(const HbInputLanguage &)), this, SLOT(primaryLanguageChanged(const HbInputLanguage &)));
connect(settings, SIGNAL(globalSecondaryInputLanguageChanged(const HbInputLanguage &)), this, SLOT(secondaryLanguageChanged(const HbInputLanguage &)));
connect(settings, SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(predictionStatusChanged(HbKeyboardSettingFlags, bool)));
+
+ connect(this, SIGNAL(aboutToClose()), this, SLOT(aboutToClose()));
}
/*!
@@ -178,7 +229,7 @@
d->mLanguageButton->setText(d->mPrimaryLanguage.localisedName());
d->mPredictionButton->setText(d->mPredictionValues.at(settings->predictiveInputStatusForActiveKeyboard()));
- QList<HbInputMethodDescriptor> customList = HbInputMethod::listCustomInputMethods();
+ QList<HbInputMethodDescriptor> customList = HbInputMethod::listCustomInputMethods(mainWindow()->orientation(), d->mPrimaryLanguage);
bool showInputMethod = true;
if (customList.count() < 1) {
showInputMethod = false;
@@ -212,6 +263,18 @@
}
/*!
+Closes input method selection if settings is closed
+*/
+void HbInputSettingList::aboutToClose()
+{
+ Q_D(HbInputSettingList);
+
+ if (d->mInputMethodSelectionList) {
+ d->mInputMethodSelectionList->close();
+ }
+}
+
+/*!
Swaps current primary and secondary languages
*/
void HbInputSettingList::languageButtonClicked()
@@ -259,11 +322,10 @@
if (d->mOptionList->row(item) == d->mOptionList->count() - 1) {
emit inputSettingsButtonClicked();
+ close();
} else {
- emit inputMethodsButtonClicked();
+ d->showInputMethodSelectionList();
}
-
- close();
}
/*!
@@ -300,4 +362,13 @@
d->mPredictionButton->setText(d->mPredictionValues.at(status));
}
+/*!
+Closes settings and emits inputMethodSelected signal with given parameter
+*/
+void HbInputSettingList::closeSettings(const HbInputMethodDescriptor &descriptor, const QByteArray &customData)
+{
+ close();
+ emit inputMethodSelected(descriptor, customData);
+}
+
// End of file