//Toggle to automatically scroll to bottom when new item added
void BC_Bulletin::autoScroll()
{
    if (ui->pushButton_3->isChecked())
    {
        connect(this, SIGNAL(itemAdded()), ui->tx, SLOT(scrollToBottom()));
        connect(this, SIGNAL(itemAdded()), ui->fsw, SLOT(scrollToBottom()));
    }
    else
    {
        disconnect(this, SIGNAL(itemAdded()), ui->tx, SLOT(scrollToBottom()));
        disconnect(this, SIGNAL(itemAdded()), ui->fsw, SLOT(scrollToBottom()));
    }
}
Beispiel #2
0
DisplayWidget::DisplayWidget(QWidget* parent) : QWebView(parent) {
    QWidget::setMinimumSize(0, 30);

    // Sections Information
    _currentSection = 0;
    _maxSections = 1;
    _currentCharacterCount = 0;
    _maxCharacterCount = 300000000;
    _scrollToBottom = true;

    // Create WebKit Display
    page()->mainFrame()->load(QUrl("qrc:/webkitdisplay/page.html"));

    // Connect Signals/Slots
    connect(this, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
    connect(page(), SIGNAL(contentsChanged()), SLOT(scrollToBottom()));

    // TODO: Why aren't frames working?
    connect(page(), SIGNAL(frameCreated(QWebFrame *frame)),
	    SLOT(loadFrame(QWebFrame *frame)));

    page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    page()->setContentEditable(false);

    /*
#ifdef USE_JQUERY
    QFile file;
    file.setFileName(":/webkitdisplay/jquery.min.js");
    file.open(QIODevice::ReadOnly);
    _jQuery = file.readAll();
    file.close();
#endif
    */
}
Beispiel #3
0
void ItemViewCategorized::toLastIndex()
{
    QModelIndex index = moveCursor(MoveEnd, Qt::NoModifier);
    clearSelection();
    setCurrentIndex(index);
    scrollToBottom();
}
Beispiel #4
0
Dialog::Dialog(const Application* application, const QString& userId, QWidget* parent) :
    QWidget(parent),
    ui(new Ui::Dialog),
    application(application),
    userId(userId)
{
    unreadInList = QStringList();
    setupUi();

    connect(ui->textEdit
            , SIGNAL(focusIn())
            , this
            , SLOT(markInboxRead()));


    connect(ui->webView->page()->mainFrame()
            , SIGNAL(contentsSizeChanged(QSize))
            , this
            , SLOT(scrollToBottom(QSize)));

    loadHistory(20);

    connect(&application->getLongPollExecutor()
            , SIGNAL(messageRecieved(QString,bool, bool,QString,uint,QString))
            , this
            , SLOT(insertMessage(QString,bool, bool,QString,uint,QString)));
    connect(&application->getLongPollExecutor()
            , SIGNAL(messageIsRead(QString))
            , this
            , SLOT(markMessageIsRead(QString)));
    connect(ui->textEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
    connect(ui->pushButton, SIGNAL(released()), this, SLOT(sendMessage()));
    ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(openAttachment(QUrl)));
}
Beispiel #5
0
void ChatWindow::notificationClicked() {
    if (parentWidget()->isMinimized()) {
        parentWidget()->showNormal();
    }
    if (isHidden()) {
        show();
    }

    // find last mention
    int messageCount = ui->messagesVBoxLayout->count();
    for (unsigned int i = messageCount; i > 0; i--) {
        ChatMessageArea* area = (ChatMessageArea*)ui->messagesVBoxLayout->itemAt(i - 1)->widget();
        QRegularExpression usernameMention(mentionRegex.arg(AccountManager::getInstance().getAccountInfo().getUsername()));
        if (area->toPlainText().contains(usernameMention)) {
            int top = area->geometry().top();
            int height = area->geometry().height();

            QScrollBar* verticalScrollBar = ui->messagesScrollArea->verticalScrollBar();
            verticalScrollBar->setSliderPosition(top - verticalScrollBar->size().height() + height);
            return;
        }
    }
    Application::processEvents();

    scrollToBottom();
}
Beispiel #6
0
void ChatWindow::addTimeStamp() {
    QTimeSpan timePassed = QDateTime::currentDateTime() - lastMessageStamp;
    int times[] = { timePassed.daysPart(), timePassed.hoursPart(), timePassed.minutesPart() };
    QString strings[] = { tr("%n day(s)", 0, times[0]), tr("%n hour(s)", 0, times[1]), tr("%n minute(s)", 0, times[2]) };
    QString timeString = "";
    for (int i = 0; i < 3; i++) {
        if (times[i] > 0) {
            timeString += strings[i] + " ";
        }
    }
    timeString.chop(1);
    if (!timeString.isEmpty()) {
        QLabel* timeLabel = new QLabel(timeString);
        timeLabel->setStyleSheet("color: #333333;"
                                 "background-color: white;"
                                 "font-size: 14px;"
                                 "padding: 4px;");
        timeLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
        timeLabel->setAlignment(Qt::AlignLeft);

        bool atBottom = isNearBottom();

        ui->messagesVBoxLayout->addWidget(timeLabel);
        ui->messagesVBoxLayout->parentWidget()->updateGeometry();

        Application::processEvents();
        numMessagesAfterLastTimeStamp = 0;

        if (atBottom) {
            scrollToBottom();
        }
    }
}
Beispiel #7
0
void ChatWindow::showEvent(QShowEvent* event) {
    QWidget::showEvent(event);

    if (!event->spontaneous()) {
        ui->messagePlainTextEdit->setFocus();
    }
    const QRect parentGeometry = parentWidget()->geometry();
    int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
    int menuBarHeight = Menu::getInstance()->geometry().height();
    int topMargin = titleBarHeight + menuBarHeight;

    setGeometry(parentGeometry.topRight().x() - size().width() + 1, parentGeometry.topRight().y() + topMargin,
                size().width(), parentWidget()->height() - topMargin);

    Application::processEvents();

    scrollToBottom();

#ifdef HAVE_QXMPP
    const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
    if (xmppClient.isConnected()) {
        participantsChanged();
    }
#endif // HAVE_QXMPP
}
Beispiel #8
0
///// append /////////////////////////////////////////////////////////////////
void StatusText::append(const QString& text)
/// Overridden from QTextEdit::append in that it autoamtically positions itself
/// at the last line.
{
  QTextEdit::append(text);
  scrollToBottom();
}
Beispiel #9
0
void *MsgView::processEvent(Event *e)
{
    if ((e->type() == EventSent) || (e->type() == EventMessageReceived)){
        Message *msg = (Message*)(e->param());
        if (msg->contact() != m_id)
            return NULL;
        if (msg->getFlags() & MESSAGE_NOVIEW)
            return NULL;
        bool bAdd = true;
        if (msg->type() == MessageStatus){
            bAdd = false;
            Contact *contact = getContacts()->contact(msg->contact());
            if (contact){
                CoreUserData *data = (CoreUserData*)(contact->getUserData(CorePlugin::m_plugin->user_data_id));
                if (data && data->LogStatus.bValue)
                    bAdd = true;
            }
        }
        if (bAdd && (e->type() == EventMessageReceived)){
            Contact *contact = getContacts()->contact(msg->contact());
            if (contact){
                CoreUserData *data = (CoreUserData*)(contact->getUserData(CorePlugin::m_plugin->user_data_id));
                if (data->OpenNewMessage.bValue)
                    bAdd = false;
            }
        }
        if (bAdd){
            addMessage(msg);
            if (!hasSelectedText())
                scrollToBottom();
        }
    }
    return MsgViewBase::processEvent(e);
}
Beispiel #10
0
void TextShow::resizeEvent(QResizeEvent *e)
{
#ifdef WIN32
	if (inResize()){
		if (!m_timer->isActive()){
			setHScrollBarMode(AlwaysOff);
			setVScrollBarMode(AlwaysOff);
			m_timer->start(100);
		}
		return;
	}
#endif
    QPoint p = QPoint(0, height());
    p = mapToGlobal(p);
    p = viewport()->mapFromGlobal(p);
    int x, y;
    viewportToContents(p.x(), p.y(), x, y);
	int para;
    int pos = charAt(QPoint(x, y), &para);
    QTextEdit::resizeEvent(e);
    if (pos == -1){
        scrollToBottom();
    }else{
        setCursorPosition(para, pos);
        ensureCursorVisible();
    }
	sync();
	viewport()->repaint();
}
Beispiel #11
0
void MsgView::addMessage(ICQMessage *msg, bool bUnread, bool bSet)
{
    if (msg->Id >= MSG_PROCESS_ID) return;
    int x = contentsX();
    int y = contentsY();
    QString s(makeMessage(msg, bUnread));
    if (bSet) curAnchor = QString::number(msg->getUin()) + "." + QString::number(msg->Id);
    unsigned long foreColor = 0;
    unsigned long backColor = 0;
    if (!pMain->UseOwnColors() && (msg->Type() == ICQ_MSGxMSG)){
        ICQMsg *m = static_cast<ICQMsg*>(msg);
        foreColor = m->ForeColor();
        backColor = m->BackColor();
    }
    if (bBack){
        setText(s + text(), curAnchor);
        if (foreColor != backColor)
            setMsgBgColor(msg->getUin(), msg->Id, backColor, 0);
    }else{
        int n = paragraphs();
        if (n > 0) n--;
        append(s);
        if (foreColor != backColor)
            setMsgBgColor(msg->getUin(), msg->Id, backColor, n);
    }
    if (bSet){
        scrollToBottom();
    }else{
        setContentsPos(x, y);
    }
}
Beispiel #12
0
void ChatView::renderMucMessage(const MessageView &mv)
{
	const QString timestr = formatTimeStamp(mv.dateTime());
	QString alerttagso, alerttagsc, nickcolor;
	QString textcolor = palette().color(QPalette::Active, QPalette::Text).name();
	QString icon = useMessageIcons_?
					(QString("<img src=\"%1\" />").arg(mv.isLocal()?"icon:log_icon_delivered":"icon:log_icon_receive")):"";
	if(mv.isAlert()) {
		textcolor = "#FF0000";
		alerttagso = "<b>";
		alerttagsc = "</b>";
	}

	if(mv.isSpooled()) {
		nickcolor = ColorOpt::instance()->color(infomrationalColorOpt).name();
	} else {
		nickcolor = getMucNickColor(mv.nick(), mv.isLocal());
	}

	if(mv.isEmote()) {
		appendText(icon + QString("<font color=\"%1\">").arg(nickcolor) + QString("[%1]").arg(timestr) + QString(" *%1 ").arg(TextUtil::escape(mv.nick())) + alerttagso + mv.formattedText() + alerttagsc + "</font>");
	}
	else {
		if(PsiOptions::instance()->getOption("options.ui.chat.use-chat-says-style").toBool()) {
			appendText(icon + QString("<font color=\"%1\">").arg(nickcolor) + QString("[%1] ").arg(timestr) + QString("%1 says:").arg(TextUtil::escape(mv.nick())) + "</font><br>" + QString("<font color=\"%1\">").arg(textcolor) + alerttagso + mv.formattedText() + alerttagsc + "</font>");
		}
		else {
			appendText(icon + QString("<font color=\"%1\">").arg(nickcolor) + QString("[%1] &lt;").arg(timestr) + TextUtil::escape(mv.nick()) + QString("&gt;</font> ") + QString("<font color=\"%1\">").arg(textcolor) + alerttagso + mv.formattedText() + alerttagsc +"</font>");
		}
	}

	if(mv.isLocal()) {
		scrollToBottom();
	}
}
Beispiel #13
0
void MChatBrowser::appendHtml(const QString &pHtml)
{
	QString jsHtml = pHtml;
	jsHtml.replace("\'", "\\'");
	QString js = QString("appendHtml('%1')").arg(jsHtml);
	page()->mainFrame()->evaluateJavaScript(js);
	scrollToBottom();
}
Beispiel #14
0
void OutputWindow::resizeEvent(QResizeEvent *e)
{
    //Keep scrollbar at bottom of window while resizing, to ensure we keep scrolling
    //This can happen if window is resized while building, or if the horizontal scrollbar appears
    bool atBottom = isScrollbarAtBottom();
    QPlainTextEdit::resizeEvent(e);
    if (atBottom)
        scrollToBottom();
}
void LoggingTableWidget::ScrollToBottom()
{
	if( RowsAdded == false )
	{
		return;
	}
	RowsAdded = false;
	scrollToBottom();
}
Beispiel #16
0
void OutputWindow::appendMessage(const QString &output, OutputFormat format)
{
    const QString out = SynchronousProcess::normalizeNewlines(output);
    setMaximumBlockCount(d->maxLineCount);
    const bool atBottom = isScrollbarAtBottom() || m_scrollTimer.isActive();

    if (format == ErrorMessageFormat || format == NormalMessageFormat) {

        d->formatter->appendMessage(doNewlineEnforcement(out), format);

    } else {

        bool sameLine = format == StdOutFormatSameLine
                     || format == StdErrFormatSameLine;

        if (sameLine) {
            d->scrollToBottom = true;

            int newline = -1;
            bool enforceNewline = d->enforceNewline;
            d->enforceNewline = false;

            if (!enforceNewline) {
                newline = out.indexOf(QLatin1Char('\n'));
                moveCursor(QTextCursor::End);
                if (newline != -1)
                    d->formatter->appendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText
            }

            QString s = out.mid(newline+1);
            if (s.isEmpty()) {
                d->enforceNewline = true;
            } else {
                if (s.endsWith(QLatin1Char('\n'))) {
                    d->enforceNewline = true;
                    s.chop(1);
                }
                d->formatter->appendMessage(QLatin1Char('\n') + s, format);
            }
        } else {
            d->formatter->appendMessage(doNewlineEnforcement(out), format);
        }
    }

    if (atBottom) {
        if (m_lastMessage.elapsed() < 5) {
            m_scrollTimer.start();
        } else {
            m_scrollTimer.stop();
            scrollToBottom();
        }
    }

    m_lastMessage.start();
    enableUndoRedo();
}
void WX_HTML_REPORT_PANEL::Report( const wxString& aText, REPORTER::SEVERITY aSeverity )
{
    REPORT_LINE line;
    line.message = aText;
    line.severity = aSeverity;

    m_report.push_back( line );
    m_htmlView->AppendToPage( generateHtml( line ) );
    scrollToBottom();
}
void QtMessageLogProxyModel::onRowsInserted(const QModelIndex &index, int start, int end)
{
    int rowIndex = end;
    do {
        if (filterAcceptsRow(rowIndex, index)) {
            emit scrollToBottom();
            break;
        }
    } while (--rowIndex >= start);
}
Beispiel #19
0
void NavigableTableView::keyPressEvent(QKeyEvent *event) {
  if(event->key() == Qt::Key_Home) {
    scrollToTop();
  }
  else if(event->key() == Qt::Key_End) {
    scrollToBottom();
  }
  else {
    QTableView::keyPressEvent(event);
  }
}
COutputWindow::COutputWindow(QWidget *parent, const char *name)
   : QDockWindow(parent, name)
{
  // Create and set the main widget (a QTextEdit)
  output = new QTextEdit(this);
  output->setReadOnly(true);
  setWidget(output);
  compiler = 0;
  connect(output, SIGNAL(textChanged()), output, SLOT(scrollToBottom()));
  
}
Beispiel #21
0
OutputStream::int_type OutputStream::overflow(OutputStream::int_type ch)
{    
    if(ch == '\n')
    {
        addLine(m_buffer);
        scrollToBottom();

        m_buffer.clear();
    }
    return ch;
}
Beispiel #22
0
bool CPetConversations::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
	if (_scrollUp.MouseButtonUpMsg(msg->_mousePos) ||
			_scrollDown.MouseButtonUpMsg(msg->_mousePos))
		return true;

	if (_doorBot.MouseButtonUpMsg(msg->_mousePos)) {
		switch (canSummonBot("DoorBot")) {
		case SUMMON_CANT:
			_log.addLine(g_vm->_strings[CANT_SUMMON_DOORBOT], getColor(1));
			break;
		case SUMMON_CAN:
			summonBot("DoorBot");
			return true;
		default:
			break;
		}

		// Scroll to the bottom of the log
		scrollToBottom();
		return true;
	}

	if (_bellBot.MouseButtonUpMsg(msg->_mousePos)) {
		switch (canSummonBot("BellBot")) {
		case SUMMON_CANT:
			_log.addLine(g_vm->_strings[CANT_SUMMON_BELLBOT], getColor(1));
			break;
		case SUMMON_CAN:
			summonBot("BellBot");
			return true;
		default:
			break;
		}

		// Scroll to the bottom of the log
		scrollToBottom();
		return true;
	}

	return false;
}
Beispiel #23
0
bool CPetConversations::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
	if (_scrollUp.MouseButtonUpMsg(msg->_mousePos) ||
			_scrollDown.MouseButtonUpMsg(msg->_mousePos))
		return true;

	if (_doorBot.MouseButtonUpMsg(msg->_mousePos)) {
		switch (canSummonBot("DoorBot")) {
		case SUMMON_CANT:
			_log.addLine("Sadly, it is not possible to summon the DoorBot from this location.", getColor(1));
			break;
		case SUMMON_CAN:
			summonBot("DoorBot");
			return true;
		default:
			break;
		}

		// Scroll to the bottom of the log
		scrollToBottom();
		return true;
	}

	if (_bellBot.MouseButtonUpMsg(msg->_mousePos)) {
		switch (canSummonBot("BellBot")) {
		case SUMMON_CANT:
			_log.addLine("Sadly, it is not possible to summon the BellBot from this location.", getColor(1));
			break;
		case SUMMON_CAN:
			summonBot("BellBot");
			return true;
		default:
			break;
		}

		// Scroll to the bottom of the log
		scrollToBottom();
		return true;
	}

	return false;
}
Beispiel #24
0
void WX_HTML_REPORT_PANEL::refreshView()
{
    wxString html;

    for( const REPORT_LINE& l : m_report )
    {
        html += generateHtml( l );
    }

    m_htmlView->SetPage( addHeader( html ) );
    scrollToBottom();
}
Beispiel #25
0
void MsgViewBase::reload()
{
    QString t;
    vector<Msg_Id> msgs;
    unsigned i;
    for (i = 0; i < (unsigned)paragraphs(); i++){
        QString s = text(i);
        int n = s.find(MSG_ANCHOR);
        if (n < 0)
            continue;
        s = s.mid(n + strlen(MSG_ANCHOR));
        n = s.find("\"");
        if (n < 0)
            continue;
        string client;
        Msg_Id id;
        id.id = messageId(s.left(n), client);
        id.client = client;
        unsigned nn;
        for (nn = 0; nn < msgs.size(); nn++){
            if ((msgs[nn].id == id.id) && (msgs[nn].client == id.client))
                break;
        }
        if (nn >= msgs.size())
            msgs.push_back(id);
    }
    for (i = 0; i < msgs.size(); i++){
        Message *msg = History::load(msgs[i].id, msgs[i].client.c_str(), m_id);
        if (msg == NULL)
            continue;
        t += messageText(msg, false);
        delete msg;
    }
    QPoint p = QPoint(0, height());
    p = mapToGlobal(p);
    p = viewport()->mapFromGlobal(p);
    int x, y;
    viewportToContents(p.x(), p.y(), x, y);
    int para;
    int pos = charAt(QPoint(x, y), &para);
    setText(t);
    if (!CorePlugin::m_plugin->getOwnColors())
        setBackground(0);
    if (pos == -1){
        scrollToBottom();
    }else{
        setCursorPosition(para, pos);
        ensureCursorVisible();
    }
}
void GNUSocialApiConversationTimelineWidget::updateHeight()
{
    int height = 25;
    for (Choqok::UI::PostWidget *wd: postWidgets()) {
        height += wd->height() + 5;
    }
    if (height > choqokMainWindow->height()) {
        height = choqokMainWindow->height();
    }
    resize(width(), height);
    if (!Choqok::AppearanceSettings::useReverseOrder()) {
        scrollToBottom();
    }
}
Beispiel #27
0
void ChatView::appendText(const QString &text)
{
	bool doScrollToBottom = atBottom();
	
	// prevent scrolling back to selected text when 
	// restoring selection
	int scrollbarValue = verticalScrollBar()->value();
	
	PsiTextView::appendText(text);
	
	if (doScrollToBottom)
		scrollToBottom();
	else
		verticalScrollBar()->setValue(scrollbarValue);
}
Beispiel #28
0
bool MChatBrowser::toggleFreeze()
{
	_freeze = !_freeze;

	if(_freeze)
	{
		page()->mainFrame()->evaluateJavaScript("window.frozen = true;");
	}
	else
	{
		page()->mainFrame()->evaluateJavaScript("window.frozen = false;");
	}

	if(!_freeze) scrollToBottom();
	return _freeze;
}
void CvsProcessWidget::slotReceivedOutput( QString someOutput )
{
    kdDebug(9006) << "CvsProcessWidget::slotReceivedOutput(QString)  here!" << endl;
#ifdef MYDCOPDEBUG
    g_dcopOutCounter++;
    kdDebug(9006) << "MYDCOPDEBUG: dcopOutCounter == " << g_dcopOutCounter << endl;
#endif

    QStringList strings = m_outputBuffer.process( someOutput );
    if (strings.count() > 0)
    {
        m_output += strings;
        showOutput( strings );
        scrollToBottom();
    }
}
void CvsProcessWidget::slotReceivedErrors( QString someErrors )
{
    kdDebug(9006) << "CvsProcessWidget::slotReceivedErrors(QString)  here!" << endl;
#ifdef MYDCOPDEBUG
    g_dcopErrCounter++;
    kdDebug(9006) << "MYDCOPDEBUG: dcopErrCounter == " << g_dcopErrCounter << endl;
#endif

    QStringList strings = m_errorBuffer.process( someErrors );
    if (strings.count() > 0)
    {
        m_errors += strings;
        showError( strings );
        scrollToBottom();
    }
}