Example #1
0
void HelpDialog::refreshLog() const
{
	ui->logBrowser->setPlainText(StelLogger::getLog());
	QScrollBar *sb = ui->logBrowser->verticalScrollBar();
	sb->setValue(sb->maximum());
}
Example #2
0
void KTreeView::KTreeViewPrivate::updateVerticalScrollBar(int value)
{
    QScrollBar *scrollBar = parent->horizontalScrollBar();
    scrollBar->setValue(value);
}
Example #3
0
void CtrlRegisterList::paintEvent(QPaintEvent *)
{

	int numRowsTotal = cpu->GetNumRegsInCategory(category);
	int maxRowsDisplay =rect().bottom()/rowHeight - 1;

	selection = std::min(std::max(selection,0),numRowsTotal);
	curVertOffset = std::max(std::min(curVertOffset,numRowsTotal - maxRowsDisplay),0);

	QScrollBar *bar = findChild<QScrollBar*>("RegListScroll");
	if(bar)
	{
		bar->setMinimum(0);
		bar->setMaximum(numRowsTotal - maxRowsDisplay);
		bar->setPageStep(1);
		bar->setValue(curVertOffset);
	}


	QPainter painter(this);
	painter.setBrush(Qt::white);
	painter.setPen(Qt::white);
	painter.drawRect(rect());

	if (!cpu)
		return;

	QFont normalFont = QFont("Arial", 10);
	painter.setFont(normalFont);

	int width = rect().width();

	QColor bgColor(0xffffff);
	QPen nullPen(bgColor);
	QPen currentPen(QColor(0xFF000000));
	QPen selPen(0x808080);
	QPen textPen;

	QBrush lbr;
	lbr.setColor(bgColor);
	QBrush nullBrush(bgColor);
	QBrush currentBrush(0xFFEfE8);
	QBrush pcBrush(0x70FF70);

	int nc = cpu->GetNumCategories();
	for (int i=0; i<nc; i++)
	{
		painter.setPen(i==category?currentPen:nullPen);
		painter.setBrush(i==category?pcBrush:nullBrush);
		painter.drawRect(width*i/nc,0,width*(i+1)/nc - width*i/nc -1,rowHeight-1);
		QString name = cpu->GetCategoryName(i);
		painter.setPen(currentPen);
		painter.drawText(width*i/nc+1,-3+rowHeight,name);
	}

	int numRows=rect().bottom()/rowHeight;

	for (int i=curVertOffset; i<curVertOffset+numRows; i++)
	{
		int rowY1 = rowHeight*(i-curVertOffset+1);
		int rowY2 = rowHeight*(i-curVertOffset+2)-1;

		lbr.setColor(i==selection?0xffeee0:0xffffff);

		painter.setBrush(currentBrush);
		painter.setPen(nullPen);
		painter.drawRect(0,rowY1,16-1,rowY2-rowY1);

		if (selecting && i == selection)
			painter.setPen(selPen);
		else
			painter.setPen(nullPen);

		QBrush mojsBrush(lbr.color());
		painter.setBrush(mojsBrush);

		painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1);

		// Check for any changes in the registers.
		if (lastPC != cpu->GetPC())
		{
			for (int i = 0, n = cpu->GetNumRegsInCategory(0); i < n; ++i)
			{
				u32 v = cpu->GetRegValue(0, i);
				changedCat0Regs[i] = v != lastCat0Values[i];
				lastCat0Values[i] = v;
			}
			lastPC = cpu->GetPC();
		}

		painter.setBrush(currentBrush);
		if (i<cpu->GetNumRegsInCategory(category))
		{
			QString regName = cpu->GetRegName(category,i);
			textPen.setColor(0x600000);
			painter.setPen(textPen);
			painter.drawText(17,rowY1-3+rowHeight,regName);
			textPen.setColor(0xFF000000);
			painter.setPen(textPen);

			char temp[256];
			cpu->PrintRegValue(category,i,temp);
			if (category == 0 && changedCat0Regs[i])
			{
				textPen.setColor(0x0000FF);
				painter.setPen(textPen);
			}
			else
			{
				textPen.setColor(0x004000);
				painter.setPen(textPen);
			}
			painter.drawText(77,rowY1-3+rowHeight,temp);
		}
	}
}
Example #4
0
bool QtScrollerFilter::eventFilter_QAbstractScrollArea(QAbstractScrollArea *area, QEvent *event)
{
    switch (event->type()) {
    case QtScrollPrepareEvent::ScrollPrepare:
    {
        QtScrollPrepareEvent *se = static_cast<QtScrollPrepareEvent *>(event);
        if (canStartScrollingAt_QAbstractScrollArea(area, se->startPos().toPoint())) {
            QScrollBar *hBar = area->horizontalScrollBar();
            QScrollBar *vBar = area->verticalScrollBar();

            se->setViewportSize(QSizeF(area->viewport()->size()));
            se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum()));
            se->setContentPos(QPointF(hBar->value(), vBar->value()));
            se->accept();
            return true;
        }
        return false;
    }
    case QtScrollEvent::Scroll:
    {
        QtScrollEvent *se = static_cast<QtScrollEvent *>(event);

        QScrollBar *hBar = area->horizontalScrollBar();
        QScrollBar *vBar = area->verticalScrollBar();
        hBar->setValue(se->contentPos().x());
        vBar->setValue(se->contentPos().y());

        QPoint os = overshoot.value(area);
#ifdef Q_WS_WIN
        typedef BOOL (*PtrBeginPanningFeedback)(HWND);
        typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
        typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL);

        static PtrBeginPanningFeedback ptrBeginPanningFeedback = 0;
        static PtrUpdatePanningFeedback ptrUpdatePanningFeedback = 0;
        static PtrEndPanningFeedback ptrEndPanningFeedback = 0;

        if (!ptrBeginPanningFeedback)
            ptrBeginPanningFeedback = (PtrBeginPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback");
        if (!ptrUpdatePanningFeedback)
            ptrUpdatePanningFeedback = (PtrUpdatePanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "UpdatePanningFeedback");
        if (!ptrEndPanningFeedback)
            ptrEndPanningFeedback = (PtrEndPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "EndPanningFeedback");

        if (ptrBeginPanningFeedback && ptrUpdatePanningFeedback && ptrEndPanningFeedback) {
            WId wid = area->window()->winId();

            if (!se->overshootDistance().isNull() && os.isNull())
                ptrBeginPanningFeedback(wid);
            if (!se->overshootDistance().isNull())
                ptrUpdatePanningFeedback(wid, -se->overshootDistance().x(), -se->overshootDistance().y(), false);
            if (se->overshootDistance().isNull() && !os.isNull())
                ptrEndPanningFeedback(wid, true);
        } else
#endif
        {
            QPoint delta = os - se->overshootDistance().toPoint();
            if (!delta.isNull()) {
                ignoreMove = true;
                area->viewport()->move(area->viewport()->pos() + delta);
                ignoreMove = false;
            }
        }
        overshoot[area] = se->overshootDistance().toPoint();
        return true;
    }
    case QEvent::Move: {
        if (!ignoreMove && !overshoot.value(area).isNull()) {
            ignoreMove = true;
            area->viewport()->move(area->viewport()->pos() - overshoot.value(area));
            ignoreMove = false;
        }
        return false;
    }
    default:
        return false;
    }
}
Example #5
0
void VMdEditor::makeBlockVisible(const QTextBlock &p_block)
{
    if (!p_block.isValid() || !p_block.isVisible()) {
        return;
    }

    QScrollBar *vbar = verticalScrollBar();
    if (!vbar || (vbar->minimum() == vbar->maximum())) {
        // No vertical scrollbar. No need to scroll.
        return;
    }

    int height = rect().height();
    QScrollBar *hbar = horizontalScrollBar();
    if (hbar && (hbar->minimum() != hbar->maximum())) {
        height -= hbar->height();
    }

    bool moved = false;

    QAbstractTextDocumentLayout *layout = document()->documentLayout();
    QRectF rect = layout->blockBoundingRect(p_block);
    int y = GETVISUALOFFSETY;
    int rectHeight = (int)rect.height();

    // Handle the case rectHeight >= height.
    if (rectHeight >= height) {
        if (y < 0) {
            // Need to scroll up.
            while (y + rectHeight < height && vbar->value() > vbar->minimum()) {
                moved = true;
                vbar->setValue(vbar->value() - vbar->singleStep());
                rect = layout->blockBoundingRect(p_block);
                rectHeight = (int)rect.height();
                y = GETVISUALOFFSETY;
            }
        } else if (y > 0) {
            // Need to scroll down.
            while (y > 0 && vbar->value() < vbar->maximum()) {
                moved = true;
                vbar->setValue(vbar->value() + vbar->singleStep());
                rect = layout->blockBoundingRect(p_block);
                rectHeight = (int)rect.height();
                y = GETVISUALOFFSETY;
            }

            if (y < 0) {
                // One step back.
                moved = true;
                vbar->setValue(vbar->value() - vbar->singleStep());
            }
        }

        if (moved) {
            qDebug() << "scroll to make huge block visible";
        }

        return;
    }

    while (y < 0 && vbar->value() > vbar->minimum()) {
        moved = true;
        vbar->setValue(vbar->value() - vbar->singleStep());
        rect = layout->blockBoundingRect(p_block);
        rectHeight = (int)rect.height();
        y = GETVISUALOFFSETY;
    }

    if (moved) {
        qDebug() << "scroll page down to make block visible";
        return;
    }

    while (y + rectHeight > height && vbar->value() < vbar->maximum()) {
        moved = true;
        vbar->setValue(vbar->value() + vbar->singleStep());
        rect = layout->blockBoundingRect(p_block);
        rectHeight = (int)rect.height();
        y = GETVISUALOFFSETY;
    }

    if (moved) {
        qDebug() << "scroll page up to make block visible";
    }
}
Example #6
0
void GroupChatForm::onSliderRangeChanged()
{
    QScrollBar* scroll = chatArea->verticalScrollBar();
    if (lockSliderToBottom)
         scroll->setValue(scroll->maximum());
}
Example #7
0
void log_frame::UpdateUI()
{
	const auto start = steady_clock::now();

	// Check TTY logs
	while (const u64 size = std::max<s64>(0, g_tty_size.load() - m_tty_file.pos()))
	{
		std::string buf;
		buf.resize(size);
		buf.resize(m_tty_file.read(&buf.front(), buf.size()));

		if (buf.find_first_of('\0') != -1)
		{
			m_tty_file.seek(s64{0} - buf.size(), fs::seek_mode::seek_cur);
			break;
		}

		if (buf.size() && m_TTYAct->isChecked())
		{
			QTextCursor text_cursor{m_tty->document()};
			text_cursor.movePosition(QTextCursor::End);
			text_cursor.insertText(qstr(buf));
		}

		// Limit processing time
		if (steady_clock::now() >= start + 4ms || buf.empty()) break;
	}

	// Check main logs
	while (const auto packet = s_gui_listener.read->next.load())
	{
		// Confirm log level
		if (packet->sev <= s_gui_listener.enabled)
		{
			QString text;
			switch (packet->sev)
			{
			case logs::level::always: break;
			case logs::level::fatal: text = "F "; break;
			case logs::level::error: text = "E "; break;
			case logs::level::todo: text = "U "; break;
			case logs::level::success: text = "S "; break;
			case logs::level::warning: text = "W "; break;
			case logs::level::notice: text = "! "; break;
			case logs::level::trace: text = "T "; break;
			default: continue;
			}

			// Print UTF-8 text.
			text += qstr(packet->msg);

			// save old log state
			QScrollBar *sb = m_log->verticalScrollBar();
			bool isMax = sb->value() == sb->maximum();
			int sb_pos = sb->value();
			int sel_pos = m_log->textCursor().position();
			int sel_start = m_log->textCursor().selectionStart();
			int sel_end = m_log->textCursor().selectionEnd();

			// clear selection or else it will get colorized as well
			QTextCursor c = m_log->textCursor();
			c.clearSelection();
			m_log->setTextCursor(c);

			// remove the new line because Qt's append adds a new line already.
			text.chop(1);

			QString suffix;
			bool isSame = text == m_old_text;

			// create counter suffix and remove recurring line if needed
			if (m_stack_log)
			{
				if (isSame)
				{
					m_log_counter++;
					suffix = QString(" x%1").arg(m_log_counter);
					m_log->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
					m_log->moveCursor(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor);
					m_log->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor);
					m_log->textCursor().removeSelectedText();
					m_log->textCursor().deletePreviousChar();
				}
				else
				{
					m_log_counter = 1;
					m_old_text = text;
				}
			}

			// add actual log message
			m_log->setTextColor(m_color[static_cast<int>(packet->sev)]);
			m_log->append(text);

			// add counter suffix if needed
			if (m_stack_log && isSame)
			{
				m_log->setTextColor(m_color_stack);
				m_log->insertPlainText(suffix);
			}

			// if we mark text from right to left we need to swap sides (start is always smaller than end)
			if (sel_pos < sel_end)
			{
				std::swap(sel_start, sel_end);
			}

			// reset old text cursor and selection
			c.setPosition(sel_start);
			c.setPosition(sel_end, QTextCursor::KeepAnchor);
			m_log->setTextCursor(c);

			// set scrollbar to max means auto-scroll
			sb->setValue(isMax ? sb->maximum() : sb_pos);
		}

		// Drop packet
		s_gui_listener.pop();

		// Limit processing time
		if (steady_clock::now() >= start + 7ms) break;
	}
}
void MainWindow::appendToLog(QString msg)
{
    ui->parsedOutputPlainTextEdit->appendPlainText(msg);
    QScrollBar *scrollbar = ui->parsedOutputPlainTextEdit->verticalScrollBar();
    scrollbar->setValue(scrollbar->maximum());
}
void LogViewer::addText(const QString &text, int textType)
{
    QString typeStr;
    QString stringToAdd = "";
    moveCursor(QTextCursor::End);
    switch (textType)
    {
        case LogInfo:
            setTextColor( Qt::black );
            //typeStr = "[info ] ";
            typeStr = "";
            break;
        case LogWarn:
            setTextColor( QColor(100,100, 0) );
            //typeStr = "[warn] ";
            typeStr = "";
            break;
        case LogErr:
            setTextColor( Qt::red );
            //typeStr = "[error] ";
            typeStr = "";
            break;
        case LogThreadId:
            setTextColor( QColor(100,100,100) );
            //typeStr = "[thread ] ";
            typeStr = "";
            break;
        case LogTx:
            setTextColor( Qt::blue );
            //typeStr = "[tx   ] ";
            typeStr = "<< ";
            break;
        case LogRx:
            setTextColor( QColor(150,0,255) );
            //typeStr = "[rx   ] ";
            typeStr = ">> ";
            break;
        default:
        setTextColor( Qt::black );
        typeStr = "";
    }

    if ((lastTextType == LogTx) || (lastTextType == LogRx))
    {
        if (textType != lastTextType)
        {
            stringToAdd.append("\r");
            stringToAdd.append(typeStr);
        }
    }
    else
    {
        stringToAdd.append(typeStr);
    }

    stringToAdd.append(text);
    if (!((textType == LogTx) || (textType == LogRx)))
        stringToAdd.append("\r");
    textCursor().insertText(stringToAdd);
    lastTextType = textType;
    QScrollBar *bar = verticalScrollBar();
    bar->setValue(bar->maximum());
}
Example #10
0
void RKProgressControlDialog::scrollDown () {
	RK_TRACE (MISC);

	QScrollBar *bar = output_text->verticalScrollBar ();
	if (bar) bar->setValue (bar->maximum ());
}
void ScriptConsoleView::scrollDown()
{
    QScrollBar *scroll = m_ui->commandsList->verticalScrollBar();
    scroll->setValue(scroll->maximum());
}
Example #12
0
void Console::keyPressEvent(QKeyEvent *e) {
    if (locked)
        return;

    if ((e->key() == Qt::Key_V && e->modifiers() == Qt::ControlModifier))
        QTextEdit::keyPressEvent(e);
    else if (e->key() >= Qt::Key_Space && e->key() <= Qt::Key_BraceRight && e->key() != Qt::Key_QuoteLeft) {
        if (e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::ShiftModifier)
            QTextEdit::keyPressEvent(e);
    }

    else
        switch (e->key()) {
        case Qt::Key_Return:
            onReturn();
            break;

        case Qt::Key_Up:
            historyBack();
            break;
        case Qt::Key_Down:
            historyForward();
            break;

        case Qt::Key_Backspace:
            if (textCursor().positionInBlock() > prompt.length())
                QTextEdit::keyPressEvent(e);
            break;

        case Qt::Key_End:
        case Qt::Key_Delete:
            QTextEdit::keyPressEvent(e);
            break;

        case Qt::Key_Left:
            if (e->modifiers() == Qt::NoModifier) {
                QTextEdit::keyPressEvent(e);

                QTextCursor cursor = textCursor();

                if (cursor.positionInBlock() < prompt.length())
                    cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor);

                setTextCursor(cursor);
            } else if (e->modifiers() == Qt::ControlModifier) {
                QTextEdit::keyPressEvent(e);

                QTextCursor cursor = textCursor();

                if (cursor.positionInBlock() < prompt.length())
                    cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 2);

                setTextCursor(cursor);
            }
            break;

        case Qt::Key_Right:
            if (e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::ControlModifier)
                QTextEdit::keyPressEvent(e);
            break;

        case Qt::Key_Home: {
            QTextCursor cursor = textCursor();
            cursor.movePosition(QTextCursor::StartOfBlock);
            cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, prompt.length());
            setTextCursor(cursor);
        } break;

        //    case Qt::Key_PageUp:
        //    case Qt::Key_PageDown:
        //    {
        //        QTextEdit::keyPressEvent(e);

        //        QTextCursor cursor = textCursor();
        //        cursor.movePosition(QTextCursor::End);
        //        setTextCursor(cursor);
        //    } break;

        case Qt::Key_PageUp: {
            QScrollBar *vbar = verticalScrollBar();
            vbar->setValue(vbar->value() - 15);
        } break;

        case Qt::Key_PageDown: {
            QScrollBar *vbar = verticalScrollBar();
            vbar->setValue(vbar->value() + 15);
        } break;

        //    case Qt::Key_Escape:
        //    {
        //        QTextCursor cursor = textCursor();
        //        cursor.movePosition(QTextCursor::StartOfBlock);
        //        cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
        //        cursor.removeSelectedText();

        //        insertPrompt();
        //    } break;

        default:
            QWidget::keyPressEvent(e);
        }
}
Example #13
0
void QStyleItem::initStyleOption()
{
    QString type = elementType();
    if (m_styleoption)
        m_styleoption->state = 0;

    switch (m_itemType) {
    case Button: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionButton();

            QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
            opt->text = text();
            opt->features = (activeControl() == "default") ?
                            QStyleOptionButton::DefaultButton :
                            QStyleOptionButton::None;
        }
        break;
    case ItemRow: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionViewItemV4();

            QStyleOptionViewItemV4 *opt = qstyleoption_cast<QStyleOptionViewItemV4*>(m_styleoption);
            opt->features = 0;
            if (activeControl() == "alternate")
                opt->features |= QStyleOptionViewItemV2::Alternate;
        }
        break;

    case Splitter: {
            if (!m_styleoption) {
                m_styleoption = new QStyleOption;
            }
        }
        break;

    case Item: {
            if (!m_styleoption) {
                m_styleoption = new QStyleOptionViewItemV4();
            }
            QStyleOptionViewItemV4 *opt = qstyleoption_cast<QStyleOptionViewItemV4*>(m_styleoption);
            opt->features = QStyleOptionViewItemV4::HasDisplay;
            opt->text = text();
            opt->textElideMode = Qt::ElideRight;
            QPalette pal = m_styleoption->palette;
            pal.setBrush(QPalette::Base, Qt::NoBrush);
            m_styleoption->palette = pal;
        }
        break;
    case Header: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionHeader();

            QStyleOptionHeader *opt = qstyleoption_cast<QStyleOptionHeader*>(m_styleoption);
            opt->text = text();
            opt->sortIndicator = activeControl() == "down" ?
                                 QStyleOptionHeader::SortDown
                                     : activeControl() == "up" ?
                                     QStyleOptionHeader::SortUp : QStyleOptionHeader::None;
            if (activeControl() == QLatin1String("beginning"))
                opt->position = QStyleOptionHeader::Beginning;
            else if (activeControl() == QLatin1String("end"))
                opt->position = QStyleOptionHeader::End;
            else if (activeControl() == QLatin1String("only"))
                opt->position = QStyleOptionHeader::OnlyOneSection;
            else
                opt->position = QStyleOptionHeader::Middle;

        }
        break;
    case ToolButton :{
            if (!m_styleoption)
                m_styleoption = new QStyleOptionToolButton();

            QStyleOptionToolButton *opt =
                    qstyleoption_cast<QStyleOptionToolButton*>(m_styleoption);
            opt->subControls = QStyle::SC_ToolButton;
            opt->state |= QStyle::State_AutoRaise;
            opt->activeSubControls = QStyle::SC_ToolButton;
        }
        break;
    case ToolBar: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionToolBar();
        }
        break;
    case Tab: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionTabV3();

            QStyleOptionTabV3 *opt =
                    qstyleoption_cast<QStyleOptionTabV3*>(m_styleoption);
            opt->text = text();
            opt->shape = info() == "South" ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
            if (activeControl() == QLatin1String("beginning"))
                opt->position = QStyleOptionTabV3::Beginning;
            else if (activeControl() == QLatin1String("end"))
                opt->position = QStyleOptionTabV3::End;
            else if (activeControl() == QLatin1String("only"))
                opt->position = QStyleOptionTabV3::OnlyOneTab;
            else
                opt->position = QStyleOptionTabV3::Middle;

        } break;

    case Menu: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionMenuItem();
        }
        break;
    case Frame: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionFrameV3();

            QStyleOptionFrameV3 *opt = qstyleoption_cast<QStyleOptionFrameV3*>(m_styleoption);
            opt->frameShape = QFrame::StyledPanel;
            opt->lineWidth = 1;
            opt->midLineWidth = 1;
        }
        break;
    case TabFrame: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionTabWidgetFrameV2();
            QStyleOptionTabWidgetFrameV2 *opt = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(m_styleoption);
            opt->shape = (info() == "South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
            if (minimum())
                opt->selectedTabRect = QRect(value(), 0, minimum(), height());
            opt->tabBarSize = QSize(minimum() , height());
            // oxygen style needs this hack
            opt->leftCornerWidgetSize = QSize(value(), 0);
        }
        break;
    case MenuItem:
    case ComboBoxItem:
        {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionMenuItem();

            QStyleOptionMenuItem *opt = qstyleoption_cast<QStyleOptionMenuItem*>(m_styleoption);
            opt->checked = false;
            opt->text = text();
            opt->palette = widget()->palette();
        }
        break;
    case CheckBox:
    case RadioButton:
        {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionButton();

            QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
            if (!on())
                opt->state |= QStyle::State_Off;
            opt->text = text();
        }
        break;
    case Edit: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionFrameV3();

            QStyleOptionFrameV3 *opt = qstyleoption_cast<QStyleOptionFrameV3*>(m_styleoption);
            opt->lineWidth = 1; // this must be non-zero
        }
        break;
    case ComboBox :{
            if (!m_styleoption)
                m_styleoption = new QStyleOptionComboBox();
            QStyleOptionComboBox *opt = qstyleoption_cast<QStyleOptionComboBox*>(m_styleoption);
            opt->currentText = text();
        }
        break;
    case SpinBox: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionSpinBox();

            QStyleOptionSpinBox *opt = qstyleoption_cast<QStyleOptionSpinBox*>(m_styleoption);
            opt->frame = true;
            if (value() & 0x1)
                opt->activeSubControls = QStyle::SC_SpinBoxUp;
            else if (value() & (1<<1))
                opt->activeSubControls = QStyle::SC_SpinBoxDown;
            opt->subControls = QStyle::SC_All;
            opt->stepEnabled = 0;
            if (value() & (1<<2))
                opt->stepEnabled |= QAbstractSpinBox::StepUpEnabled;
            if (value() & (1<<3))
                opt->stepEnabled |= QAbstractSpinBox::StepDownEnabled;
        }
        break;
    case Slider:
    case Dial:
        {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionSlider();

            QStyleOptionSlider *opt = qstyleoption_cast<QStyleOptionSlider*>(m_styleoption);
            opt->minimum = minimum();
            opt->maximum = maximum();
            // ### fixme - workaround for KDE inverted dial
            opt->sliderPosition = value();
            opt->singleStep = step();

            if (opt->singleStep)
            {
                qreal numOfSteps = (opt->maximum - opt->minimum) / opt->singleStep;

                // at least 5 pixels between tick marks
                if (numOfSteps && (width() / numOfSteps < 5))
                    opt->tickInterval = qRound((5*numOfSteps / width()) + 0.5)*step();
                else
                    opt->tickInterval = opt->singleStep;
            }
            else // default Qt-components implementation
                opt->tickInterval = opt->maximum != opt->minimum ? 1200 / (opt->maximum - opt->minimum) : 0;

            if (style() == QLatin1String("oxygen") && type == QLatin1String("dial"))
                opt->sliderValue  = maximum() - value();
            else
                opt->sliderValue = value();
            opt->subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
            opt->tickPosition = (activeControl() == "below") ?
                                QSlider::TicksBelow : (activeControl() == "above" ?
                                                       QSlider::TicksAbove:
                                                       QSlider::NoTicks);
            if (opt->tickPosition != QSlider::NoTicks)
                opt->subControls |= QStyle::SC_SliderTickmarks;

            opt->activeSubControls = QStyle::SC_None;
        }
        break;
    case ProgressBar: {
            if (QProgressBar *bar= qobject_cast<QProgressBar*>(widget())){
                bar->setMaximum(maximum());
                bar->setMinimum(minimum());
                if (maximum() != minimum())
                    bar->setValue(1);
            }
            if (!m_styleoption)
                m_styleoption = new QStyleOptionProgressBarV2();

            QStyleOptionProgressBarV2 *opt = qstyleoption_cast<QStyleOptionProgressBarV2*>(m_styleoption);
            opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical;
            opt->minimum = minimum();
            opt->maximum = maximum();
            opt->progress = value();
        }
        break;
    case GroupBox: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionGroupBox();

            QStyleOptionGroupBox *opt = qstyleoption_cast<QStyleOptionGroupBox*>(m_styleoption);
            opt->text = text();
            opt->lineWidth = 1;
            opt->subControls = QStyle::SC_GroupBoxLabel;
            if (sunken()) // Qt draws an ugly line here so I ignore it
                opt->subControls |= QStyle::SC_GroupBoxFrame;
            else
                opt->features |= QStyleOptionFrameV2::Flat;
            if (activeControl() == "checkbox")
                opt->subControls |= QStyle::SC_GroupBoxCheckBox;

            if (QGroupBox *group= qobject_cast<QGroupBox*>(widget())) {
                group->setTitle(text());
                group->setCheckable(opt->subControls & QStyle::SC_GroupBoxCheckBox);
            }
        }
        break;
    case ScrollBar: {
            if (!m_styleoption)
                m_styleoption = new QStyleOptionSlider();

            QStyleOptionSlider *opt = qstyleoption_cast<QStyleOptionSlider*>(m_styleoption);
            opt->minimum = minimum();
            opt->maximum = maximum();
            opt->pageStep = horizontal() ? width() : height();
            opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical;
            opt->sliderPosition = value();
            opt->sliderValue = value();
            opt->activeSubControls = (activeControl() == QLatin1String("up"))
                                     ? QStyle::SC_ScrollBarSubLine :
                                     (activeControl() == QLatin1String("down")) ?
                                     QStyle::SC_ScrollBarAddLine:
                                     QStyle::SC_ScrollBarSlider;

            opt->sliderValue = value();
            opt->subControls = QStyle::SC_All;

            QScrollBar *bar = qobject_cast<QScrollBar *>(widget());
            bar->setMaximum(maximum());
            bar->setMinimum(minimum());
            bar->setValue(value());
        }
        break;
    default:
        break;
    }

    if (!m_styleoption)
        m_styleoption = new QStyleOption();

    m_styleoption->rect = QRect(m_paintMargins, m_paintMargins, width() - 2* m_paintMargins, height() - 2 * m_paintMargins);

    if (isEnabled())
        m_styleoption->state |= QStyle::State_Enabled;
    if (m_active)
        m_styleoption->state |= QStyle::State_Active;
    if (m_sunken)
        m_styleoption->state |= QStyle::State_Sunken;
    if (m_raised)
        m_styleoption->state |= QStyle::State_Raised;
    if (m_selected)
        m_styleoption->state |= QStyle::State_Selected;
    if (m_focus)
        m_styleoption->state |= QStyle::State_HasFocus;
    if (m_on)
        m_styleoption->state |= QStyle::State_On;
    if (m_hover)
        m_styleoption->state |= QStyle::State_MouseOver;
    if (m_horizontal)
        m_styleoption->state |= QStyle::State_Horizontal;

    if (widget()) {
        widget()->ensurePolished();
        if (type == QLatin1String("tab") && style() != QLatin1String("mac")) {
            // Some styles actually check the beginning and end position
            // using widget geometry, so we have to trick it
            widget()->setGeometry(0, 0, width(), height());
            if (activeControl() != "beginning")
                m_styleoption->rect.translate(1, 0); // Don't position at start of widget
            if (activeControl() != "end")
                widget()->resize(200, height());
        }
#ifdef Q_OS_WIN
        else widget()->resize(width(), height());
#endif

        widget()->setEnabled(isEnabled());
        m_styleoption->fontMetrics = widget()->fontMetrics();
        if (!m_styleoption->palette.resolve())
            m_styleoption->palette = widget()->palette();
        if (m_hint.contains("mac.mini")) {
            widget()->setAttribute(Qt::WA_MacMiniSize);
        } else if (m_hint.contains("mac.small")) {
            widget()->setAttribute(Qt::WA_MacSmallSize);
        }
    }
}
Example #14
0
void ChatAreaWidget::onSliderRangeChanged()
{
    QScrollBar* scroll = verticalScrollBar();
    if (lockSliderToBottom)
        scroll->setValue(scroll->maximum());
}
void MainWindow::processFinished( int exitCode, QProcess::ExitStatus exitStatus)
{
    if ( exitStatus == QProcess::CrashExit )
    {
//        QMessageBox::warning( this, tr("Error"), tr("Crashed") );
        cnvOutputStr = cnvOutputStr + "Error:" + ui->listWidget->item(convet_index-1)->text();
        convert_error = true;
    }
    else if ( exitCode != 0 )
    {
//        QMessageBox::warning( this, tr("Error"), tr("Failed") );
        cnvOutputStr = cnvOutputStr + "Error:" + ui->listWidget->item(convet_index-1)->text();
        convert_error = true;
    }
    else
    {
        // 正常終了時の処理
//        ui->textBrowser_status->setText(tr("Convert Success!"));
//    QMessageBox::information(this, tr("Ss5Converter"), tr("Convert success"));
    }

    if (( ui->listWidget->count() > convet_index ))
    {
        QString st = QString("Exec %1/%2").arg(convet_index+1).arg(ui->listWidget->count());
        ui->textBrowser_status->setText(st);     //ステータス
        {
            QString fileName = ui->listWidget->item(convet_index)->text();
            //コンバータの起動
            if (fileName.isEmpty())
            {
                //ファイル名なし
            }
            else
            {
                QString str;
                QString execstr;

        #ifdef Q_OS_WIN32
                // Windows
                execstr = "Ss5Converter.exe";
        #else
                // Mac
                QDir dir = QDir(execPathStr);
                dir.cd("..");
                dir.cd("..");
                dir.cd("..");
                dir.cd("..");
                QString str_current_path = dir.path();
                execstr = str_current_path + "/Ss5Converter";
        #endif
                str = execstr + " \"" + fileName + "\"";
                cnvProcess->start(str); //パスと引数

                convet_index++;
            }
        }
    }
    else
    {
        button_enable(true);
        convert_exec = false;  //コンバート中か
        if ( convert_error == false )
        {
            ui->textBrowser_status->setText(tr("Convert Success!"));
        }
        else
        {
            ui->textBrowser_status->setText(tr("Error"));   //ステータス
            ui->textBrowser_err->setText(cnvOutputStr);
        }
    }
    //カーソルを最終行へ移動
    QScrollBar *sb = ui->textBrowser_err->verticalScrollBar();
    sb->setValue(sb->maximum());

}
void Console::scrollDown()
{
    QScrollBar *vbar = verticalScrollBar();
    vbar->setValue(vbar->maximum());
}
Example #17
0
void LogViewForm::scrollToBottom()
{
	QScrollBar* vsb = logTextEdit->verticalScrollBar();
	vsb->setValue(vsb->maximum());
	logTextEdit->update();
}
Example #18
0
void RPCConsole::scrollToEnd()
{
    QScrollBar *scrollbar = ui->messagesWidget->verticalScrollBar();
    scrollbar->setValue(scrollbar->maximum());
}
Example #19
0
void WaveformView::positionChanged(qint64 milliseconds)
{
	if (fDoc)
	{
		real f = ((real)milliseconds / 1000.0f) * fDoc->Fps();
		int32 frame = PG_FLOOR(f);
		if (frame != fCurFrame)
		{
			if (fAudioStopFrame >= 0)
			{
				if (frame > fAudioStopFrame)
				{
					if (fDoc->GetAudioPlayer())
						fDoc->GetAudioPlayer()->stop();
					fAudioStopFrame = -1;
				}
				else
				{
					fCurFrame = frame;
					emit(frameChanged(fCurFrame));
				}
				update();
			}
			else if (fDragging)
			{
				if (frame > fCurFrame + 1)
				{
					if (fDoc->GetAudioPlayer())
						fDoc->GetAudioPlayer()->stop();
				}
			}
			else
			{
				fCurFrame = frame;
				emit(frameChanged(fCurFrame));
				update();
			}


			QMediaPlayer *audioPlayer = fDoc->GetAudioPlayer();
			if (!fDragging && audioPlayer && audioPlayer->state() == QMediaPlayer::PlayingState)
			{
				if (fScrollArea)
				{
					QScrollBar *scrollBar = fScrollArea->horizontalScrollBar();
					if (scrollBar)
					{
						int frameX = fCurFrame * fFrameWidth;
						int scrollX = scrollBar->value();
						int scrollW = fScrollArea->width();
						if (frameX - scrollX > scrollW)
						{
							scrollBar->setValue(frameX - scrollW / 6);
						}
						else if (frameX - scrollX < 0)
							scrollBar->setValue(frameX);
					}
				}
			}
		}
	}
}