* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
#include <MLayout>
#include <MAction>
#include <MWidgetAction>
#include "aboutdialog.h"
#include "mainwindow.h"
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
MainWindow::MainWindow(QGraphicsItem *parent) : MApplicationPage(parent)
{
m_downloader = new MedardDownloader();
m_forecastInitialDateLabel = new MLabel();
m_forecastInitialDateLabel->setAlignment(Qt::AlignCenter);
-// m_forecastInitialDateLabel->setDisabled(true);
+ m_forecastInitialDateLabel->setEnabled(false);
m_forecastDateLabel = new MLabel();
m_forecastDateLabel->setAlignment(Qt::AlignCenter);
delete m_downloader;
}
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
void MainWindow::setupUi()
{
- setAttribute(Qt::WA_LockPortraitOrientation, true);
setWindowTitle(tr("Medard"));
setPannable(false);
mainLayout->addItem(m_forecast);
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+ layout->setContentsMargins(4, 4, 4, 4);
+ layout->setSpacing(8);
mainLayout->addItem(layout);
layout->addItem(m_forecastTypeLabel);
+/* layout->addItem(m_forecastInitialDateLabel); */
layout->addItem(m_forecastDateLabel);
- layout->addItem(m_forecastInitialDateLabel);
layout->addItem(m_downloadRetryButton);
QGraphicsLinearLayout *dayNavigationBox = new QGraphicsLinearLayout(Qt::Horizontal);
}
#endif
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
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()));
int forecastType = settings.value("ForecastType").toInt();
m_downloader->setForecastDomain((MedardDownloader::ForecastDomain) forecastDomain);
-#ifdef Q_WS_MAEMO_6
- m_domainComboBox->setCurrentIndex(forecastDomain);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_forecastDomainComboBox->setCurrentIndex(forecastDomain);
#else
m_domainActionGroup->actions().at(forecastDomain)->setChecked(true);
#endif
void MainWindow::updateNavigationButtons()
{
if ((m_downloader->forecastDateOffset() - 24) < m_downloader->minForecastDateOffset()) {
-// m_minusDayButton->setDisabled(true);
-// m_plusDayButton->setDisabled(false);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_minusDayButton->setEnabled(false);
+ m_plusDayButton->setEnabled(true);
+#else
+ m_minusDayButton->setDisabled(true);
+ m_plusDayButton->setDisabled(false);
+#endif
} else if ((m_downloader->forecastDateOffset() + 24) > m_downloader->maxForecastDateOffset()) {
-// m_minusDayButton->setDisabled(false);
-// m_plusDayButton->setDisabled(true);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_minusDayButton->setEnabled(true);
+ m_plusDayButton->setEnabled(false);
+#else
+ m_minusDayButton->setDisabled(false);
+ m_plusDayButton->setDisabled(true);
+#endif
} else {
-// m_minusDayButton->setDisabled(false);
-// m_plusDayButton->setDisabled(false);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_minusDayButton->setEnabled(true);
+ m_plusDayButton->setEnabled(true);
+#else
+ m_minusDayButton->setDisabled(false);
+ m_plusDayButton->setDisabled(false);
+#endif
}
if ((m_downloader->forecastDateOffset() - 1) < m_downloader->minForecastDateOffset()) {
-// m_minusHourButton->setDisabled(true);
-// m_plusHourButton->setDisabled(false);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_minusHourButton->setEnabled(false);
+ m_plusHourButton->setEnabled(true);
+#else
+ m_minusHourButton->setDisabled(true);
+ m_plusHourButton->setDisabled(false);
+#endif
} else if ((m_downloader->forecastDateOffset() + 1) > m_downloader->maxForecastDateOffset()) {
-// m_minusHourButton->setDisabled(false);
-// m_plusHourButton->setDisabled(true);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_minusHourButton->setEnabled(true);
+ m_plusHourButton->setEnabled(false);
+#else
+ m_minusHourButton->setDisabled(false);
+ m_plusHourButton->setDisabled(true);
+#endif
} else {
-// m_minusHourButton->setDisabled(false);
-// m_plusHourButton->setDisabled(false);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_minusHourButton->setEnabled(true);
+ m_plusHourButton->setEnabled(true);
+#else
+ m_minusHourButton->setDisabled(false);
+ m_plusHourButton->setDisabled(false);
+#endif
}
}
+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 MEEGO_EDITION_HARMATTAN
+ m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::SeaLevelPressure);
+#endif
+ setForecastType(tr("Sea Level Pressure"), MedardDownloader::SeaLevelPressure);
}
void MainWindow::precipitationMenuClicked()
{
- forecastTypeChanged(tr("Precipitation"), MedardDownloader::Precipitation);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::Precipitation);
+#endif
+ setForecastType(tr("Precipitation"), MedardDownloader::Precipitation);
}
void MainWindow::windVelocityMenuClicked()
{
- forecastTypeChanged(tr("Wind Velocity"), MedardDownloader::WindVelocity);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::WindVelocity);
+#endif
+ setForecastType(tr("Wind Velocity"), MedardDownloader::WindVelocity);
}
void MainWindow::cloudinessMenuClicked()
{
- forecastTypeChanged(tr("Cloudiness"), MedardDownloader::Cloudiness);
+#ifdef MEEGO_EDITION_HARMATTAN
+ m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::Cloudiness);
+#endif
+ setForecastType(tr("Cloudiness"), MedardDownloader::Cloudiness);
}
void MainWindow::temperatureMenuClicked()
{
- forecastTypeChanged(tr("Temperature"), MedardDownloader::Temperature);
+#ifdef MEEGO_EDITION_HARMATTAN
+ 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);
+#ifdef MEEGO_EDITION_HARMATTAN
+ dialog->appear(MSceneWindow::DestroyWhenDismissed);
#else
dialog->exec();
#endif
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
+#ifdef MEEGO_EDITION_HARMATTAN
void MainWindow::forecastDomainChanged(int index)
{
m_forecast->clearImage(false);
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)
{
void MainWindow::downloadedFinished(const QString &filename, const QDateTime &date)
{
m_forecast->setImage(filename);
- m_forecastInitialDateLabel->setText(tr("Forecast from:\n") +
- m_downloader->forecastInitialDate().toString("dd.MM.yyyy hh:mm"));
+ m_forecastInitialDateLabel->setText(tr("Forecast from:<br>") +
+ m_downloader->forecastInitialDate().toString("dd.MM.yyyy, hh:mm"));
/* upcase the first letter of name of day */
- QString temp = date.toString("dddd\ndd.MM.yyyy hh:mm");
+ QString temp = date.toString("dddd<br>dd.MM.yyyy, hh:mm");
m_forecastDateLabel->setText(temp.replace(0, 1, temp.at(0).toUpper()));
showNavigationButtons();