void WeatherPlugin::updateButton() { if ((getTime() == 0) || (m_bar == NULL)) return; const char **xpm = xpms[getIcon()]; if (xpm){ IconDef icon; icon.name = "weather"; icon.xpm = xpm; Event eIcon(EventAddIcon, &icon); eIcon.process(); } QString text = unquoteText(getButtonText()); QString tip = getTipText(); text = replace(text); tip = replace(tip); Command cmd; cmd->id = CmdWeather; cmd->param = m_bar; Event e(EventCommandWidget, cmd); CToolButton *btn = (CToolButton*)e.process(); if (btn == NULL) return; btn->setTextLabel(text); btn->repaint(); QToolTip::add(btn, tip); }
void WeatherPlugin::updateButton() { if ((getTime() == 0) || (m_bar == NULL)) return; const char **xpm = xpms[getIcon()]; if (xpm){ IconDef icon; icon.name = "weather"; icon.xpm = xpm; Event eIcon(EventAddIcon, &icon); eIcon.process(); } QString text = unquoteText(getButtonText()); QString tip = getTipText(); QString ftip = getForecastText(); text = replace(text); tip = replace(tip); if (getForecast()) tip = QString("<table><tr><td>") + tip + "</td><td>"; unsigned n = (getForecast() + 1) / 2; if (n < 3) n = getForecast(); for (m_day = 1; m_day <= getForecast(); m_day++){ tip += forecastReplace(ftip); const char **xpm = xpms[atol(getDayIcon(m_day))]; if (xpm){ string url = "weather"; url += number(m_day); IconDef icon; icon.name = url.c_str(); icon.xpm = xpm; Event eIcon(EventAddIcon, &icon); eIcon.process(); } if (--n == 0){ tip += "</td><td>"; n = (getForecast() + 1) / 2; } } if (getForecast()) tip += "</td></tr></table>"; tip += "<br>\nWeather data provided by weather.com"; tip += QChar((unsigned short)176); Command cmd; cmd->id = CmdWeather; cmd->param = m_bar; Event e(EventCommandWidget, cmd); CToolButton *btn = (CToolButton*)e.process(); if (btn == NULL) return; btn->setTextLabel(text); btn->repaint(); QToolTip::add(btn, tip); }
void WeatherPlugin::updateButton() { if ((getTime() == 0) || (m_bar == NULL)) return; weather_icon = "weather"; weather_icon += number(getIcon()); Command cmd; cmd->id = CmdWeather; cmd->text = I18N_NOOP("Not connected"); cmd->icon = weather_icon.c_str(); cmd->bar_id = BarWeather; cmd->bar_grp = 0x1000; cmd->flags = BTN_PICT | BTN_DIV; Event eCmd(EventCommandChange, cmd); eCmd.process(); QString text = unquoteText(getButtonText()); QString tip = getTipText(); QString ftip = getForecastText(); text = replace(text); tip = replace(tip); if (getForecast()) tip = QString("<table><tr><td>") + tip + "</td><td>"; unsigned n = (getForecast() + 1) / 2; if (n < 3) n = getForecast(); for (m_day = 1; m_day <= getForecast(); m_day++){ tip += forecastReplace(ftip); if (--n == 0){ tip += "</td><td>"; n = (getForecast() + 1) / 2; } } if (getForecast()) tip += "</td></tr></table>"; tip += "<br>\nWeather data provided by weather.com"; tip += QChar((unsigned short)174); Command cmdw; cmdw->id = CmdWeather; cmdw->param = m_bar; Event e(EventCommandWidget, cmdw); CToolButton *btn = (CToolButton*)e.process(); if (btn == NULL) return; btn->setTextLabel(text); btn->repaint(); QToolTip::add(btn, tip); }
void WeatherPlugin::updateButton() { if ((getTime() == 0) || (m_bar == NULL)) return; Command cmd; cmd->id = CmdWeather; cmd->text = I18N_NOOP("Not connected"); cmd->icon = "weather" + QString::number(getIcon()); cmd->bar_id = BarWeather; cmd->bar_grp = 0x1000; cmd->flags = BTN_PICT | BTN_DIV; EventCommandChange(cmd).process(); QString text = unquoteText(getButtonText()); QString tip = getTipText(); QString ftip = i18n("<br><b>Forecast for</b><br>\n"); ftip +=getForecastText(); text = replace(text); tip = replace(tip); if (getForecast()) tip = QString("<table><tr><td>") + tip + "</td><td>"; unsigned n = (getForecast() + 1) / 2; if (n < 3) n = getForecast(); for (m_day = 1; m_day <= getForecast(); m_day++) { tip += forecastReplace(ftip); if (--n == 0) { tip += "</td><td>"; n = (getForecast() + 1) / 2; } } if (getForecast()) tip += "</td></tr></table>"; tip += "<br>\n"+i18n("weather", "Weather data provided by weather.com®"); Command cmdw; cmdw->id = CmdWeather; cmdw->param = m_bar; EventCommandWidget eWidget(cmdw); eWidget.process(); CToolButton *btn = dynamic_cast<CToolButton*>(eWidget.widget()); if (btn == NULL) return; btn->setTextLabel(text); btn->repaint(); QToolTip::add(btn, tip); }
void WeatherPlugin::updateButton() { if ((getTime() == 0) || (m_bar == NULL)) return; const char **xpm = NULL; QString conditions(getConditions()); if (conditions == "Overcast"){ xpm = overcast; }else if (conditions == "Fog"){ xpm = fog; }else if (conditions == "Storm"){ xpm = storm; }else if (conditions == "Rain"){ xpm = rain; }else if (conditions == "Snow"){ xpm = snow; }else if (conditions == "Cloudy"){ xpm = snow; }else if (conditions == "Clear"){ xpm = isDay() ? day : night; }else if (conditions == "Partial cloudy"){ xpm = isDay() ? day_cloudy : night_cloudy; } if (xpm){ IconDef icon; icon.name = "weather"; icon.xpm = xpm; Event eIcon(EventAddIcon, &icon); eIcon.process(); } QString text = unquoteText(getButtonText()); QString tip = getTipText(); text = replace(text); tip = replace(tip); Command cmd; cmd->id = CmdWeather; cmd->param = m_bar; Event e(EventCommandWidget, cmd); CToolButton *btn = (CToolButton*)e.process(); if (btn == NULL) return; btn->setTextLabel(text); btn->repaint(); QToolTip::add(btn, tip); }