Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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);
}