/* -*- Mode: C++ -*- * meegotouchcp-telephony: a telephony control panel applet * Copyright (c) 2010, Intel Corporation. * * This program is licensed under the terms and conditions of the * Apache License, version 2.0. The full text of the Apache License is at * http://www.apache.org/licenses/LICENSE-2.0 * */ #include "telephonywidget.h" #include "propertyeditor.h" #include "callsettingspropertyeditor.h" #include #include #include #include #include //% "String telling user their current phone number %1 contains the phone number" const QString TelephonyWidget::numberTemplate = qtTrId("My number: %1"); TelephonyWidget::TelephonyWidget(QGraphicsWidget *parent) : DcpWidget(parent) { m_layout = new QGraphicsLinearLayout(Qt::Vertical); QSignalMapper *mapper = new QSignalMapper(this); ManagerProxy *manager = ManagerProxy::instance(); ModemProxy *modem = manager->modem(); //FIXME, when API is changed //to multiple modems, this //needs change SettingsManager *settingsManager = new SettingsManager(modem->path()); ForwardingManager *forwardingManager = new ForwardingManager(modem->path()); m_networkProxy = new NetworkProxy(modem->path()); m_simManager = new SimManager(modem->path()); m_radioSettingsProxy = new RadioSettingsProxy(modem->path()); //% "My number:" QString myNumber = qtTrId("qtn_my_number"); AbstractPropertyEditor *numberPropertyEditor = PropertyEditorFactory::createEditor(m_simManager, "subscriberNumbers", myNumber, "SubscriberNumberPropertyEditor"); Q_ASSERT(numberPropertyEditor); m_layout->addItem(numberPropertyEditor); //% "Send My Caller ID" QString sendCallerId = qtTrId("qtn_send_caller_id"); AbstractPropertyEditor *hideCallerIdEditor = PropertyEditorFactory::createEditor(settingsManager, "hideCallerId", sendCallerId, "CallSettingsPropertyEditor"); Q_ASSERT(hideCallerIdEditor); m_layout->addItem(hideCallerIdEditor); //% "Hear Call Waiting" QString hearCallWaiting = qtTrId("qtn_hear_call_waiting"); AbstractPropertyEditor *callWaitingEditor = PropertyEditorFactory::createEditor(settingsManager, "voiceCallWaiting", hearCallWaiting, "CallSettingsPropertyEditor"); Q_ASSERT(callWaitingEditor); m_layout->addItem(callWaitingEditor); //% "3g" QString threeG = qtTrId("qtn_three_gee"); AbstractPropertyEditor *technologyPropertyEditor = PropertyEditorFactory::createEditor(m_radioSettingsProxy, "technologyPreference", threeG, "RadioSettingsPropertyEditor"); Q_ASSERT(technologyPropertyEditor); m_layout->addItem(technologyPropertyEditor); m_nagItem = new MGConfItem("/apps/dialer/supressContactNag", this); connect(m_nagItem, SIGNAL(valueChanged()), SLOT(nagChanged())); MWidget *widget = new MWidget(); QGraphicsLinearLayout *nagLayout = new QGraphicsLinearLayout(Qt::Horizontal); widget->setLayout(nagLayout); //% "Prompt to add contact" MLabel *label = new MLabel(qtTrId("qtn_contact_nag")); label->setWordWrap(true); nagLayout->addItem(label); m_nagButton = new MButton(); m_nagButton->setViewType(MButton::switchType); m_nagButton->setCheckable(true); nagChanged(); connect(m_nagButton, SIGNAL(toggled(bool)), SLOT(nagButtonToggled(bool))); nagLayout->addItem(m_nagButton); nagLayout->setAlignment(m_nagButton, Qt::AlignVCenter); m_layout->addItem(widget); //% "Forward All Calls" QString forwardAllCalls = qtTrId("qtn_forward_all_calls"); m_unconditional = dynamic_cast(PropertyEditorFactory::createEditor(forwardingManager, "voiceUnconditional", forwardAllCalls, "CallForwardingPropertyEditor")); Q_ASSERT(m_unconditional); connect(m_unconditional, SIGNAL(toggled(bool)), SLOT(unconditionalToggled(bool))); //% "Call Forwarding" m_forwardingButton = new MButton(qtTrId("qtn_call_forwarding_button")); mapper->setMapping(m_forwardingButton, 2); connect(m_forwardingButton, SIGNAL(clicked()), mapper, SLOT(map())); m_layout->addItem(m_unconditional); //% "Set Speed Dial" MButton *button = new MButton(qtTrId("qtn_speed_dial_button")); button->setObjectName("speedDialButton"); mapper->setMapping(button, 3); //FIXME: move to #define or static const int connect(button, SIGNAL(clicked()), mapper, SLOT(map())); m_layout->addItem(button); //% "Call Barring Settings" button = new MButton(qtTrId("qtn_barring_settings_button")); button->setObjectName("barringSettingsButton"); mapper->setMapping(button, 5); //FIXME: not defined connect(button, SIGNAL(clicked()), mapper, SLOT(map())); m_layout->addItem(button); connect(mapper, SIGNAL(mapped(int)), SLOT(mapped(int))); m_layout->addStretch(); setLayout(m_layout); } TelephonyWidget::~TelephonyWidget() { qDebug() << "TelephonyWidget::~TelephonyWidget()"; if (m_forwardingButton) { m_forwardingButton->deleteLater(); } } bool TelephonyWidget::back() { return true; } QString TelephonyWidget::title() const { return "Dialer Settings"; } void TelephonyWidget::mapped(int widgetNumber) { qDebug() << "TelephonyWidget::mapped(" << widgetNumber << ")"; changeWidget(widgetNumber); } void TelephonyWidget::subscriberNumbersChanged(const QStringList &subscriberNumbers) { if (subscriberNumbers.count()) { m_phoneNumberLabel->setText(numberTemplate.arg(subscriberNumbers[0])); } else { qWarning() << "subscriberNumbersChanged but still count is zero"; } } void TelephonyWidget::nagButtonToggled(bool checked) { m_nagItem->set(checked); } void TelephonyWidget::nagChanged() { m_nagButton->setChecked(m_nagItem->value().toBool()); } void TelephonyWidget::unconditionalToggled(bool checked) { if (checked) { m_forwardingButton->hide(); m_layout->removeItem(m_forwardingButton); } else { m_forwardingButton->show(); m_layout->insertItem(6, m_forwardingButton); } }