コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: pajlada/patty
void MainWindow::onMessage(IrcPrivateMessage *message) {
    auto messages = read.getMessages(message->target());
    int messageCount = 150; // Subject to change via settings, currently set as twitch default
    PattyIrcMessage* pattyMsg = PattyIrcMessage::fromMessage(message);
    messages->append(pattyMsg);

    if (message->target() == this->currentChannel) {
        QString html;
        QWebFrame* frame = this->ui->baseChatWindow->page()->mainFrame();
        this->scrollValue = frame->scrollBarValue(Qt::Vertical);
        this->autoScroll = (this->scrollValue >= frame->scrollBarMaximum(Qt::Vertical));
        if (this->autoScroll) {
            while (messages->count() > messageCount) {
                delete messages->takeFirst();
                QWebElement message = frame->findFirstElement("div.message");
                message.removeFromDocument();
            }
        }
        addMessage(pattyMsg);
    } else {
        if (messages->count() > messageCount) {
            delete messages->takeFirst();
        }
    }
}
void CellmlAnnotationViewMetadataNormalViewDetailsWidget::showLastRdfTriple()
{
    // Show our last RDF triple by scrolling to the end of the page

    QWebFrame *outputFrame = mOutputOntologicalTerms->page()->mainFrame();

    outputFrame->setScrollBarValue(Qt::Vertical, outputFrame->scrollBarMaximum(Qt::Vertical));
}
コード例 #3
0
ファイル: qwebframeproto.cpp プロジェクト: xtuple/qt-client
int QWebFrameProto::scrollBarMaximum(Qt::Orientation orientation) const
{
  scriptDeprecated("QWebFrame will not be available in future versions");
  QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
  if (item)
    return item->scrollBarMaximum(orientation);
  return 0;
}
コード例 #4
0
			void ChatTab::AppendMessage (Plugins::IMessage *msg)
			{
				Plugins::ICLEntry *other = qobject_cast<Plugins::ICLEntry*> (msg->OtherPart ());
				if (!other && msg->OtherPart ())
				{
					qWarning () << Q_FUNC_INFO
							<< "message's other part doesn't implement ICLEntry"
							<< msg->GetObject ()
							<< msg->OtherPart ();
					return;
				}

				if (msg->GetDirection () == Plugins::IMessage::DOut &&
						other->GetEntryType () == Plugins::ICLEntry::ETMUC)
					return;

				QWebFrame *frame = Ui_.View_->page ()->mainFrame ();
				bool shouldScrollFurther = (frame->scrollBarMaximum (Qt::Vertical) ==
								frame->scrollBarValue (Qt::Vertical));

				QString body = FormatBody (msg->GetBody (), msg);

				QString string = QString ("%1 ")
						.arg (FormatDate (msg->GetDateTime (), msg));
				string.append (' ');
				switch (msg->GetDirection ())
				{
				case Plugins::IMessage::DIn:
				{
					switch (msg->GetMessageType ())
					{
					case Plugins::IMessage::MTChatMessage:
					case Plugins::IMessage::MTMUCMessage:
					{
						QString entryName = Qt::escape (other->GetEntryName ());
						entryName = FormatNickname (entryName, msg);

						if (body.startsWith ("/me "))
						{
							body = body.mid (3);
							string.append ("*** ");
							string.append (entryName);
							string.append (' ');
						}
						else
						{
							string.append (entryName);
							string.append (": ");
						}
						break;
					}
					case Plugins::IMessage::MTEventMessage:
						string.append ("! ");
						break;
					}
					break;
				}
				case Plugins::IMessage::DOut:
					string.append (FormatNickname ("R", msg));
					string.append (": ");
					break;
				}

				string.append (body);

				QWebElement elem = frame->findFirstElement ("body");
				elem.appendInside (QString ("<div>%1</div").arg (string));

				if (shouldScrollFurther)
					QTimer::singleShot (100,
							this,
							SLOT (scrollToEnd ()));
			}
コード例 #5
0
			void ChatTab::scrollToEnd ()
			{
				QWebFrame *frame = Ui_.View_->page ()->mainFrame ();
				int scrollMax = frame->scrollBarMaximum (Qt::Vertical);
				frame->setScrollBarValue (Qt::Vertical, scrollMax);
			}