Пример #1
0
void DlgTagFetcher::updateStack() {
    if (m_data.m_pending) {
        stack->setCurrentWidget(loading_page);
        return;
    } else if (m_networkError == HTTPERROR) {
        stack->setCurrentWidget(networkError_page);
        return;
    } else if (m_networkError == FTWERROR) {
        stack->setCurrentWidget(generalnetworkError_page);
        return;
    } else if (m_data.m_results.isEmpty()) {
        stack->setCurrentWidget(error_page);
        return;
    }
    btnApply->setEnabled(true);
    stack->setCurrentWidget(results_page);

    results->clear();

    addDivider(tr("Original tags"), results);
    addTrack(m_track, -1, results);

    addDivider(tr("Suggested tags"), results);

    int trackIndex = 0;
    foreach (const TrackPointer track, m_data.m_results) {
        addTrack(track, trackIndex++, results);
    }

    // Find the item that was selected last time
    for (int i=0 ; i<results->model()->rowCount() ; ++i) {
        const QModelIndex index = results->model()->index(i, 0);
        const QVariant id = index.data(Qt::UserRole);
        if (!id.isNull() && id.toInt() == m_data.m_selectedResult) {
            results->setCurrentIndex(index);
            break;
        }
    }
}
Пример #2
0
void Segmenter::guessDividers()
{
    // scan through the bgs pixels and add a divider at
    // sep points

    resetDividers();

    QImage image(m_imagebg->pixmap().toImage());
    QList<QRect> whiteregions;

    bool skip = true;
    bool gotwhite = false;
    QPoint whitestart;
    int bottom = image.height() - 1;

    for (int x = 0; x < image.width(); x++) {
        bool iswhite = true;
        for (int y = 0; y < image.height(); y++) {
            // skip white pixels
            if (image.pixel(x, y) != qRgb(255, 255, 255)) {
                iswhite = false;
                if (gotwhite) {
                    QRect region(whitestart, QPoint(x - 1, bottom));
                    whiteregions.append(region);
                    gotwhite = false;
                }
                skip = false;
                break;
            }
        }
        if (iswhite && !skip) {
            if (!gotwhite) {
                gotwhite = true;
                whitestart.rx() = x;
                whitestart.ry() = 0;
            }
        }
    }

    for (int i = 0; i < whiteregions.size(); i++) {
        addDivider(QPointF(whiteregions[i].center().x(), 0));
    }

    update();
}
Пример #3
0
void Segmenter::mousePressEvent (QGraphicsSceneMouseEvent * event)
{
    // left click in the scene with no mods - add a divider
    if (moveMode()) {
        this->QGraphicsScene::mousePressEvent(event);
    } else if (deleteMode()) {
        Divider* todelete = static_cast<Divider*>(this->itemAt(event->scenePos()));
        // TODO: Figure out why this causes a weird crash
        // it's supposed to test if we can delete an intermediate
        // point instead of the whole divider
        //if (!todelete->deletePointAt(event->scenePos())) {
        //    deleteDivider(todelete);
        //}
        deleteDivider(todelete);
    } else if (drawMode() && event->buttons() & Qt::LeftButton) {
        Divider* newdiv = addDivider(m_markerdivider->mapRectToScene(m_captivedivider->boundingRect()).center());
        // set the new div to match the marker poly
        newdiv->setPolygon(m_markerdivider->polygon());        
        // hide the marker and grab the new div - bit dodgy this...
        m_markerdivider->setVisible(false);
        grabDivider(newdiv);
    }
}
void YACReaderMainToolBar::addWideDivider()
{
    mainLayout->addSpacing(3);
    addDivider();
    mainLayout->addSpacing(3);
}
YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent) :
    QWidget(parent)
{
    mainLayout = new QHBoxLayout;

    currentFolder = new QLabel(this);
	currentFolder->setAlignment(Qt::AlignCenter);
	currentFolder->setStyleSheet(" QLabel {color:#404040; font-size:22px; font-weight:bold;}");

	QFont f=currentFolder->font();
	f.setStyleStrategy(QFont::PreferAntialias);
	currentFolder->setFont(f);

	QString qToolButtonStyleSheet = "QToolButton {border:none;}";

    backButton = new QToolButton();
    backButton->setStyleSheet(qToolButtonStyleSheet);


    forwardButton = new QToolButton();
    forwardButton->setStyleSheet(qToolButtonStyleSheet);
	forwardButton->setDisabled(true);

    settingsButton = new QToolButton();
    settingsButton->setStyleSheet(qToolButtonStyleSheet);
	settingsButton->setIconSize(QSize(24,24));

    serverButton = new QToolButton();
    serverButton->setStyleSheet(qToolButtonStyleSheet);
    serverButton->setIconSize(QSize(17,24));


    helpButton = new QToolButton();
    helpButton->setStyleSheet(qToolButtonStyleSheet);
    helpButton->setIconSize(QSize(14,25));

    fullscreenButton = new QToolButton();
    fullscreenButton->setStyleSheet(qToolButtonStyleSheet);
    fullscreenButton->setIconSize(QSize(24,24));


    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);

    mainLayout->addSpacing(12);
    mainLayout->addWidget(backButton);
    addDivider();
    mainLayout->addWidget(forwardButton);

    mainLayout->addSpacing(34);
    mainLayout->addWidget(settingsButton);
    addWideDivider();
    mainLayout->addWidget(serverButton);
    addWideDivider();
    mainLayout->addWidget(helpButton);

    mainLayout->addStretch();

    mainLayout->addWidget(fullscreenButton);
    mainLayout->addSpacing(10);

    setLayout(mainLayout);

    setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
}