X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmainwindow.cpp;h=c82f413be04138fae6aeae8f83fa3e963bf8d339;hb=46f57ee55633ee3c6009e9daca0529019a80a1a7;hp=0253c38c13b1e477171990ce3b232b50581a8e82;hpb=6ade87a7820c10251a5fe5df1d469c41d219c76b;p=medard diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0253c38..c82f413 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -48,10 +48,12 @@ MainWindow::MainWindow(QGraphicsItem *parent) : MApplicationPage(parent) m_forecastInitialDateLabel = new MLabel(); m_forecastInitialDateLabel->setAlignment(Qt::AlignCenter); + m_forecastInitialDateLabel->setWordWrap(true); // m_forecastInitialDateLabel->setDisabled(true); m_forecastDateLabel = new MLabel(); m_forecastDateLabel->setAlignment(Qt::AlignCenter); + m_forecastDateLabel->setWordWrap(true); m_downloadRetryButton = new MButton(tr("Download again")); m_downloadRetryButton->setPreferredWidth(220); @@ -204,41 +206,57 @@ void MainWindow::setupUi() #ifdef Q_WS_MAEMO_6 void MainWindow::setupMenu() { - QStringList domainsList; - domainsList << tr("Europe") << tr("Czech Republic"); - - MWidgetAction *domainAction = new MWidgetAction(centralWidget()); - domainAction->setLocation(MAction::ApplicationMenuLocation); - - m_domainComboBox = new MComboBox; - m_domainComboBox->setTitle(tr("Domain")); - m_domainComboBox->setIconVisible(false); - m_domainComboBox->addItems(domainsList); - domainAction->setWidget(m_domainComboBox); - addAction(domainAction); - connect(m_domainComboBox, SIGNAL(activated(int)), this, SLOT(forecastDomainChanged(int))); - - MAction *seaLevelPreasureAction = new MAction("icon-m-weather-cloudy", tr("Sea Level Pressure"), this); + QStringList forecastDomainList; + forecastDomainList << tr("Europe") + << tr("Czech Republic"); + + MWidgetAction *forecastDomainAction = new MWidgetAction(centralWidget()); + forecastDomainAction->setLocation(MAction::ApplicationMenuLocation); + + m_forecastDomainComboBox = new MComboBox; + m_forecastDomainComboBox->setTitle(tr("Domain")); + m_forecastDomainComboBox->setStyleName ("CommonComboBox"); + m_forecastDomainComboBox->setIconVisible(false); + m_forecastDomainComboBox->addItems(forecastDomainList); + forecastDomainAction->setWidget(m_forecastDomainComboBox); + addAction(forecastDomainAction); + connect(m_forecastDomainComboBox, SIGNAL(activated(int)), this, SLOT(forecastDomainChanged(int))); + + QStringList forecastTypeList; + forecastTypeList << tr("Sea Level Pressure") + << tr("Precipitation") + << tr("Wind Velocity") + << tr("Cloudiness") + << tr("Temperature"); + + MWidgetAction *forecastTypeAction = new MWidgetAction(centralWidget()); + forecastTypeAction->setLocation(MAction::ApplicationMenuLocation); + + m_forecastTypeComboBox = new MComboBox; + m_forecastTypeComboBox->setTitle(tr("Forecast")); + m_forecastTypeComboBox->setStyleName ("CommonComboBox"); + m_forecastTypeComboBox->setIconVisible(false); + m_forecastTypeComboBox->addItems(forecastTypeList); + forecastTypeAction->setWidget(m_forecastTypeComboBox); + addAction(forecastTypeAction); + connect(m_forecastTypeComboBox, SIGNAL(activated(int)), this, SLOT(forecastTypeChanged(int))); + + MAction *seaLevelPreasureAction = new MAction("icon-m-weather-cloudy", "", this); seaLevelPreasureAction->setLocation(MAction::ToolBarLocation); addAction(seaLevelPreasureAction); connect(seaLevelPreasureAction, SIGNAL(triggered()), this, SLOT(seaLevelPreasureMenuClicked())); - MAction *precipitationAction = new MAction("icon-m-weather-rain", tr("Precipitation"), this); + MAction *precipitationAction = new MAction("icon-m-weather-rain", "", this); precipitationAction->setLocation(MAction::ToolBarLocation); addAction(precipitationAction); connect(precipitationAction, SIGNAL(triggered()), this, SLOT(precipitationMenuClicked())); - MAction *windVelocityAction = new MAction("icon-m-weather-stormy", tr("Wind Velocity"), this); - windVelocityAction->setLocation(MAction::ToolBarLocation); - addAction(windVelocityAction); - connect(windVelocityAction, SIGNAL(triggered()), this, SLOT(windVelocityMenuClicked())); - - MAction *cloudinessAction = new MAction("icon-m-weather-partly-sunny", tr("Cloudinese"), this); + MAction *cloudinessAction = new MAction("icon-m-weather-partly-sunny", "", this); cloudinessAction->setLocation(MAction::ToolBarLocation); addAction(cloudinessAction); connect(cloudinessAction, SIGNAL(triggered()), this, SLOT(cloudinessMenuClicked())); - MAction *temperatureAction = new MAction("icon-m-weather-hot", tr("Temperature"), this); + MAction *temperatureAction = new MAction("icon-m-weather-hot", "", this); temperatureAction->setLocation(MAction::ToolBarLocation); addAction(temperatureAction); connect(temperatureAction, SIGNAL(triggered()), this, SLOT(temperatureMenuClicked())); @@ -301,7 +319,7 @@ void MainWindow::loadSettings() m_downloader->setForecastDomain((MedardDownloader::ForecastDomain) forecastDomain); #ifdef Q_WS_MAEMO_6 - m_domainComboBox->setCurrentIndex(forecastDomain); + m_forecastDomainComboBox->setCurrentIndex(forecastDomain); #else m_domainActionGroup->actions().at(forecastDomain)->setChecked(true); #endif @@ -377,36 +395,69 @@ void MainWindow::updateNavigationButtons() } } +void MainWindow::setForecastType(const QString label, MedardDownloader::ForecastType type) +{ + m_forecastTypeLabel->setText(label); + m_forecast->clearImage(false); + m_downloader->setForecastType(type); + m_downloader->downloadImage(); + + QSettings settings; + settings.setValue("ForecastType", type); +} + +void MainWindow::setForecastDateOffset(int offset) +{ + m_forecast->clearImage(false); + m_downloader->setForecastDateOffset(m_downloader->forecastDateOffset() + offset); + m_downloader->downloadImage(); +} + void MainWindow::seaLevelPreasureMenuClicked() { - forecastTypeChanged(tr("Sea Level Pressure"), MedardDownloader::SeaLevelPressure); +#ifdef Q_WS_MAEMO_6 + m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::SeaLevelPressure); +#endif + setForecastType(tr("Sea Level Pressure"), MedardDownloader::SeaLevelPressure); } void MainWindow::precipitationMenuClicked() { - forecastTypeChanged(tr("Precipitation"), MedardDownloader::Precipitation); +#ifdef Q_WS_MAEMO_6 + m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::Precipitation); +#endif + setForecastType(tr("Precipitation"), MedardDownloader::Precipitation); } void MainWindow::windVelocityMenuClicked() { - forecastTypeChanged(tr("Wind Velocity"), MedardDownloader::WindVelocity); +#ifdef Q_WS_MAEMO_6 + m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::WindVelocity); +#endif + setForecastType(tr("Wind Velocity"), MedardDownloader::WindVelocity); } void MainWindow::cloudinessMenuClicked() { - forecastTypeChanged(tr("Cloudiness"), MedardDownloader::Cloudiness); +#ifdef Q_WS_MAEMO_6 + m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::Cloudiness); +#endif + setForecastType(tr("Cloudiness"), MedardDownloader::Cloudiness); } void MainWindow::temperatureMenuClicked() { - forecastTypeChanged(tr("Temperature"), MedardDownloader::Temperature); +#ifdef Q_WS_MAEMO_6 + m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::Temperature); +#endif + setForecastType(tr("Temperature"), MedardDownloader::Temperature); } void MainWindow::aboutMenuClicked() { AboutDialog *dialog = new AboutDialog(); #ifdef Q_WS_MAEMO_6 - dialog->appear(scene(), MSceneWindow::DestroyWhenDismissed); + dialog->appear(MSceneWindow::DestroyWhenDismissed); #else dialog->exec(); #endif @@ -422,40 +473,22 @@ void MainWindow::downloadAgainClicked() void MainWindow::plusDayClicked() { - forecastDateOffsetChanged(+24); + setForecastDateOffset(+24); } void MainWindow::minusDayClicked() { - forecastDateOffsetChanged(-24); + setForecastDateOffset(-24); } void MainWindow::plusHourClicked() { - forecastDateOffsetChanged(+1); + setForecastDateOffset(+1); } void MainWindow::minusHourClicked() { - forecastDateOffsetChanged(-1); -} - -void MainWindow::forecastTypeChanged(const QString label, MedardDownloader::ForecastType type) -{ - m_forecastTypeLabel->setText(label); - m_forecast->clearImage(false); - m_downloader->setForecastType(type); - m_downloader->downloadImage(); - - QSettings settings; - settings.setValue("ForecastType", type); -} - -void MainWindow::forecastDateOffsetChanged(int offset) -{ - m_forecast->clearImage(false); - m_downloader->setForecastDateOffset(m_downloader->forecastDateOffset() + offset); - m_downloader->downloadImage(); + setForecastDateOffset(-1); } #ifdef Q_WS_MAEMO_6 @@ -473,6 +506,32 @@ void MainWindow::forecastDomainChanged(int index) QSettings settings; settings.setValue("ForecastDomain", index); } + +void MainWindow::forecastTypeChanged(int index) +{ + switch ((MedardDownloader::ForecastType) index) { + case MedardDownloader::SeaLevelPressure: + setForecastType(tr("Sea Level Pressure"), MedardDownloader::SeaLevelPressure); + break; + + case MedardDownloader::Precipitation: + setForecastType(tr("Precipitation"), MedardDownloader::Precipitation); + break; + + case MedardDownloader::WindVelocity: + setForecastType(tr("Wind Velocity"), MedardDownloader::WindVelocity); + break; + + case MedardDownloader::Cloudiness: + setForecastType(tr("Cloudiness"), MedardDownloader::Cloudiness); + break; + + case MedardDownloader::Temperature: + setForecastType(tr("Temperature"), MedardDownloader::Temperature); + break; + } +} + #else void MainWindow::forecastDomainChanged(QAction *action) {