예제 #1
0
void MessageModel::setVisible(bool visible)
{
    if (m_visible != visible) {
        m_visible = visible;
        if (visible) {
            setBadge(0);
            setActiveHighlights(0);
        }
        emit visibleChanged();
    }
}
예제 #2
0
void MessageModel::receive(IrcMessage* message)
{
    MessageData data;
    data.plaintext = m_formatter->formatMessage(message, Qt::PlainText);
    if (!data.plaintext.isEmpty()) {
        data.timestamp = message->timeStamp().toString("hh:mm");
        data.date = message->timeStamp().date();
        data.type = message->type();
        data.own = message->flags() & IrcMessage::Own;
        data.event = (message->type() != IrcMessage::Private && message->type() != IrcMessage::Notice);
        data.sender = message->nick();
        if (!data.event && !data.own) {
            int pos = 0;
            QString nick = message->connection()->nickName();
            QString content = message->property("content").toString();
            while (!data.hilite && (pos = content.indexOf(nick, pos, Qt::CaseInsensitive)) != -1) {
                // #60: more precise nick alerts
                QTextBoundaryFinder finder(QTextBoundaryFinder::Word, content);
                finder.setPosition(pos);
                if (finder.isAtBoundary()) {
                    finder.setPosition(pos + nick.length());
                    data.hilite = finder.isAtBoundary();
                }
                pos += nick.length();
            }
        }
        data.richtext = m_formatter->formatMessage(message, Qt::RichText);
        foreach (const QUrl& url, m_formatter->textFormat()->urls()) {
            QString pretty = url.toString(QUrl::PrettyDecoded | QUrl::RemoveScheme | QUrl::StripTrailingSlash);
            while (pretty.startsWith("/"))
                pretty.remove(0, 1);
            if (!data.urls.contains(pretty)) {
                data.urls += pretty;
                data.rawUrls += url.toString();
            }
        }
        bool seen = (m_current && m_visible) || !message->connection()->isConnected();
        append(data, seen);
        if (!m_current || !m_visible) {
            bool priv = message->property("private").toBool() && !message->property("forwarded").toBool();
            if (data.hilite || priv) {
                setActiveHighlights(m_highlights + 1);
                if (priv)
                    emit messageMissed(data.plaintext);
                else
                    emit messageHighlighted(data.sender, data.plaintext);
            }
            if (!data.event) // TODO: create a setting for this?
                setBadge(m_badge + 1);
        }
    }
예제 #3
0
void MessageModel::setCurrent(bool current)
{
    if (m_current != current) {
        m_current = current;
        if (!current) {
            m_seen.fill(true);
            setSeparator(m_messages.count() - 1);
        } else {
            setBadge(0);
            setActiveHighlights(0);
            if (m_separator == -1)
                setSeparator(m_messages.count() - 1);
        }
        emit currentChanged();
    }
}
예제 #4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_tile(new QtDockTile(this))
{
    ui->setupUi(this);
	ui->menubar->setNativeMenuBar(false);

    ui->actionElementWithIcon->setIcon(QIcon::fromTheme("applications-internet"));
	m_tile->setMenu(ui->menu);

    connect(ui->pushButton, SIGNAL(clicked()), m_tile, SLOT(alert()));
    connect(ui->lineEdit, SIGNAL(textChanged(QString)), m_tile, SLOT(setBadge(QString)));
    connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), m_tile, SLOT(setProgress(int)));

	connect(ui->element, SIGNAL(triggered()), SLOT(actionTriggered()));
	connect(ui->element1, SIGNAL(triggered()), SLOT(actionTriggered()));
	connect(ui->element2, SIGNAL(triggered()), SLOT(actionTriggered()));
	connect(ui->actionElementWithIcon, SIGNAL(triggered()), SLOT(actionTriggered()));
}
void LLFloaterSellLandUI::refreshUI()
{
	LLParcel* parcelp = mParcelSelection->getParcel();
	if (!parcelp) return;

	LLTextureCtrl* snapshot = getChild<LLTextureCtrl>("info_image");
	snapshot->setImageAssetID(mParcelSnapshot);

	getChild<LLUICtrl>("info_parcel")->setValue(parcelp->getName());
	getChild<LLUICtrl>("info_size")->setTextArg("[AREA]", llformat("%d", mParcelActualArea));

	std::string price_str = getChild<LLUICtrl>("price")->getValue().asString();
	bool valid_price = false;
	valid_price = (price_str != "") && LLTextValidate::validateNonNegativeS32(utf8str_to_wstring(price_str));

	if (valid_price && mParcelActualArea > 0)
	{
		F32 per_meter_price = 0;
		per_meter_price = F32(mParcelPrice) / F32(mParcelActualArea);
		std::string type_currency = LLGridManager::getInstance()->getCurrency();
		getChild<LLUICtrl>("price_per_m")->setTextArg("[CUR]", type_currency);
		getChild<LLUICtrl>("price_per_m")->setTextArg("[PER_METER]", llformat("%0.2f", per_meter_price));
		getChildView("price_per_m")->setVisible(TRUE);

		setBadge("step_price", BADGE_OK);
	}
	else
	{
		getChildView("price_per_m")->setVisible(FALSE);

		if ("" == price_str)
		{
			setBadge("step_price", BADGE_NOTE);
		}
		else
		{
			setBadge("step_price", BADGE_ERROR);
		}
	}

	if (mSellToBuyer)
	{
		getChild<LLUICtrl>("sell_to")->setValue("user");
		getChildView("sell_to_agent")->setVisible(TRUE);
		getChildView("sell_to_select_agent")->setVisible(TRUE);
	}
	else
	{
		if (mChoseSellTo)
		{
			getChild<LLUICtrl>("sell_to")->setValue("anyone");
		}
		else
		{
			getChild<LLUICtrl>("sell_to")->setValue("select");
		}
		getChildView("sell_to_agent")->setVisible(FALSE);
		getChildView("sell_to_select_agent")->setVisible(FALSE);
	}

	// Must select Sell To: Anybody, or User (with a specified username)
	std::string sell_to = getChild<LLUICtrl>("sell_to")->getValue().asString();
	bool valid_sell_to = "select" != sell_to &&
		("user" != sell_to || mAuthorizedBuyer.notNull());

	if (!valid_sell_to)
	{
		setBadge("step_sell_to", BADGE_NOTE);
	}
	else
	{
		setBadge("step_sell_to", BADGE_OK);
	}

	bool valid_sell_objects = ("none" != getChild<LLUICtrl>("sell_objects")->getValue().asString());

	if (!valid_sell_objects)
	{
		setBadge("step_sell_objects", BADGE_NOTE);
	}
	else
	{
		setBadge("step_sell_objects", BADGE_OK);
	}

	if (valid_sell_to && valid_price && valid_sell_objects)
	{
		getChildView("sell_btn")->setEnabled(TRUE);
	}
	else
	{
		getChildView("sell_btn")->setEnabled(FALSE);
	}
}
예제 #6
0
void LLFloaterSellLandUI::refreshUI()
{
	LLParcel* parcelp = mParcelSelection->getParcel();
	if (!parcelp) return;

	LLTextureCtrl* snapshot = getChild<LLTextureCtrl>("info_image");
	if (snapshot)
	{
		snapshot->setImageAssetID(mParcelSnapshot);
	}

	childSetText("info_parcel", parcelp->getName());
	childSetTextArg("info_size", "[AREA]", llformat("%d", mParcelActualArea));

	childSetTextArg("price_ld", "[CURRENCY]", gHippoGridManager->getConnectedGrid()->getCurrencySymbol());

	std::string price_str = childGetValue("price").asString();
	bool valid_price = false;
	valid_price = (price_str != "") && LLLineEditor::prevalidateNonNegativeS32(utf8str_to_wstring(price_str));

	if (valid_price && mParcelActualArea > 0)
	{
		F32 per_meter_price = 0;
		per_meter_price = F32(mParcelPrice) / F32(mParcelActualArea);
		childSetTextArg("price_per_m", "[PER_METER]", llformat("%0.2f", per_meter_price));
		childShow("price_per_m");

		setBadge("step_price", BADGE_OK);
	}
	else
	{
		childHide("price_per_m");

		if ("" == price_str)
		{
			setBadge("step_price", BADGE_NOTE);
		}
		else
		{
			setBadge("step_price", BADGE_ERROR);
		}
	}

	if (mSellToBuyer)
	{
		childSetValue("sell_to", "user");
		childShow("sell_to_agent");
		childShow("sell_to_select_agent");
	}
	else
	{
		if (mChoseSellTo)
		{
			childSetValue("sell_to", "anyone");
		}
		else
		{
			childSetValue("sell_to", "select");
		}
		childHide("sell_to_agent");
		childHide("sell_to_select_agent");
	}

	// Must select Sell To: Anybody, or User (with a specified username)
	std::string sell_to = childGetValue("sell_to").asString();
	bool valid_sell_to = "select" != sell_to &&
		("user" != sell_to || mAuthorizedBuyer.notNull());

	if (!valid_sell_to)
	{
		setBadge("step_sell_to", BADGE_NOTE);
	}
	else
	{
		setBadge("step_sell_to", BADGE_OK);
	}

	bool valid_sell_objects = ("none" != childGetValue("sell_objects").asString());

	if (!valid_sell_objects)
	{
		setBadge("step_sell_objects", BADGE_NOTE);
	}
	else
	{
		setBadge("step_sell_objects", BADGE_OK);
	}

	if (valid_sell_to && valid_price && valid_sell_objects)
	{
		childEnable("sell_btn");
	}
	else
	{
		childDisable("sell_btn");
	}
}