void dtkComposerViewLayoutItem::split(void)
{
    if(!d->proxy->view())
        return;

    QSize size = this->size();

    d->a = new dtkComposerViewLayoutItem(this);
    d->b = new dtkComposerViewLayoutItem(this);

    d->splitter->addWidget(d->a);
    d->splitter->addWidget(d->b);

    d->a->d->proxy->setFocus(Qt::OtherFocusReason);
    d->a->d->proxy->setView(d->proxy->view());

    disconnect(d->proxy, SIGNAL(focusedIn()), this, SLOT(onFocusedIn()));
    disconnect(d->proxy, SIGNAL(focusedOut()), this, SLOT(onFocusedOut()));

    delete d->proxy;

    d->proxy = NULL;

    d->footer->hide();

    d->splitter->resize(size);
}
void dtkComposerViewLayoutItem::maximize(void)
{
    if(d->a && d->b)
        return;

    if(this == d->root)
        return;

    d->root->setUpdatesEnabled(false);

    d->root->d->proxy = new dtkComposerViewLayoutItemProxy(d->root);

    d->root->connect(d->root->d->proxy, SIGNAL(focusedIn()), d->root, SLOT(onFocusedIn()));
    d->root->connect(d->root->d->proxy, SIGNAL(focusedOut()), d->root, SLOT(onFocusedOut()));

    d->root->d->splitter->addWidget(d->root->d->proxy);

    d->root->d->proxy->setView(d->proxy->view());
    d->root->d->proxy->setFocus(Qt::OtherFocusReason);

    d->root->d->footer->show();

    d->root->setUpdatesEnabled(true);

    d->root->d->a->deleteLater();
    d->root->d->b->deleteLater();

    d->root->d->a = NULL;
    d->root->d->b = NULL;
}
void dtkComposerViewLayoutItem::clear(void)
{
    if (d->proxy && d->proxy->view()){
        d->proxy->view()->hide();
        emit unfocused(d->proxy->view());
    }
    delete d->proxy;

    d->proxy = new dtkComposerViewLayoutItemProxy(d->root);

    connect(d->proxy, SIGNAL(focusedIn()), this, SLOT(onFocusedIn()));
    connect(d->proxy, SIGNAL(focusedOut()), this, SLOT(onFocusedOut()));

    d->splitter->addWidget(d->proxy);

    d->proxy->setFocus(Qt::OtherFocusReason);

    d->footer->show();

    this->setUpdatesEnabled(true);

    if (d->a)
        d->a->deleteLater();

    if (d->b)
        d->b->deleteLater();

    d->a = NULL;
    d->b = NULL;

    d->label->clear();
    d->close->setEnabled(false);
    d->vertc->setEnabled(false);
    d->horzt->setEnabled(false);
    d->maxmz->setEnabled(false);
}
void dtkComposerViewLayoutItem::unsplit(void)
{
    if(!d->a && !d->b)
        return;

    d->root->setUpdatesEnabled(false);

    if(d->layout->current() == d->a) {

        // qDebug() << __func__ << "Current item is a";

        d->a->deleteLater();

        d->a = NULL;

        if(d->b->d->a && d->b->d->b) {

            // qDebug() << __func__ << "Current item is a, b has children, reparenting";

            dtkComposerViewLayoutItem *a = d->b->d->a; a->d->parent = this;
            dtkComposerViewLayoutItem *b = d->b->d->b; b->d->parent = this;

            a->setParent(this);
            b->setParent(this);

            d->splitter->setOrientation(d->b->d->splitter->orientation());

            d->b->deleteLater();

            d->b = NULL;

            d->a = a;
            d->b = b;

            d->splitter->addWidget(d->a);
            d->splitter->addWidget(d->b);

            dtkComposerViewLayoutItemProxy *child = NULL;

            if(!(child = dtkComposerViewLayoutItemPrivate::firstViewChild(d->a)))
                 child = dtkComposerViewLayoutItemPrivate::firstViewChild(d->b);

            if (child)
                child->setFocus(Qt::OtherFocusReason);

        } else {

            // qDebug() << __func__ << "Current item is a, b has no children, creating a proxy.";

            d->proxy = new dtkComposerViewLayoutItemProxy(this);

            // qDebug() << __func__ << "Current item is a, b has no children, proxy created.";

            connect(d->proxy, SIGNAL(focusedIn()), this, SLOT(onFocusedIn()));
            connect(d->proxy, SIGNAL(focusedOut()), this, SLOT(onFocusedOut()));

            // qDebug() << __func__ << "Current item is a, b has no children, proxy connected.";

            d->splitter->addWidget(d->proxy);

            // qDebug() << __func__ << "Current item is a, b has no children, proxy layout out.";

            // if(!d->b->d->proxy->view())
            //     qDebug() << "VIEW IS NULL";

            // else if(!d->b->d->proxy->view()->widget())
            //     qDebug() << "VIEW'S WIDGET IS NULL";

            d->proxy->setView(d->b->d->proxy->view());

            // qDebug() << __func__ << "Current item is a, b has no children, proxy set up.";

            d->proxy->setFocus(Qt::OtherFocusReason);

            // qDebug() << __func__ << "Current item is a, b has no children, proxy focused.";

            d->b->deleteLater();

            d->b = NULL;

            // if(!d->proxy->view())
            //     qDebug() << "VIEW IS NULL";

            // else if(!d->proxy->view()->widget())
            //     qDebug() << "VIEW'S WIDGET IS NULL";

            // qDebug() << __func__ << "Current item is a, b has no children, b deleted.";

            d->footer->show();

            // qDebug() << __func__ << "Current item is a, b has no children, done.";
        }
    }

    else if(d->layout->current() == d->b) {

        // qDebug() << __func__ << "Current item is b";

        d->b->deleteLater();

        d->b = NULL;

        if(d->a->d->a && d->a->d->b) {

            // qDebug() << __func__ << "Current item is b, a has children, reparenting";

            dtkComposerViewLayoutItem *a = d->a->d->a; a->d->parent = this;
            dtkComposerViewLayoutItem *b = d->a->d->b; b->d->parent = this;

            a->setParent(this);
            b->setParent(this);

            d->splitter->setOrientation(d->a->d->splitter->orientation());

            d->a->deleteLater();

            d->a = NULL;

            d->a = a;
            d->b = b;

            d->splitter->addWidget(d->a);
            d->splitter->addWidget(d->b);

            dtkComposerViewLayoutItemProxy *child = NULL;

            if(!(child = dtkComposerViewLayoutItemPrivate::firstViewChild(d->a)))
                 child = dtkComposerViewLayoutItemPrivate::firstViewChild(d->b);

            if (child)
                child->setFocus(Qt::OtherFocusReason);

        } else {

            // qDebug() << __func__ << "Current item is b, a has no children, creating a proxy.";

            d->proxy = new dtkComposerViewLayoutItemProxy(this);

            connect(d->proxy, SIGNAL(focusedIn()), this, SLOT(onFocusedIn()));
            connect(d->proxy, SIGNAL(focusedOut()), this, SLOT(onFocusedOut()));

            d->splitter->addWidget(d->proxy);

            d->proxy->setView(d->a->d->proxy->view());
            d->proxy->setFocus(Qt::OtherFocusReason);

            d->a->deleteLater();

            d->a = NULL;

            d->footer->show();
        }

    } else {

        qDebug() << DTK_PRETTY_FUNCTION << "Unhandled case.";

    }

    d->root->setUpdatesEnabled(true);
}
dtkComposerViewLayoutItem::dtkComposerViewLayoutItem(dtkComposerViewLayoutItem *parent) : QFrame(parent), d(new dtkComposerViewLayoutItemPrivate)
{
    d->a = NULL;
    d->b = NULL;
    d->q = this;

    d->layout = NULL;

    if((d->parent = parent)) {
        d->root = d->parent->d->root;
        d->layout = d->parent->d->layout;
    } else {
        d->root = this;
    }

    d->proxy = new dtkComposerViewLayoutItemProxy(this);

    d->splitter = new QSplitter(this);
    d->splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    d->splitter->addWidget(d->proxy);

    d->horzt = new QPushButton("Horzt", this);
    d->vertc = new QPushButton("Vertc", this);
    d->close = new QPushButton("Close", this);
    d->maxmz = new QPushButton("Maxmz", this);

    d->label = new QLineEdit(this);
    d->label->setReadOnly(true);

    QHBoxLayout *footer_layout = new QHBoxLayout;
    footer_layout->addWidget(d->label);
    footer_layout->addWidget(d->horzt);
    footer_layout->addWidget(d->vertc);
    footer_layout->addWidget(d->maxmz);
    footer_layout->addWidget(d->close);

    d->footer = new QFrame(this);
    d->footer->setLayout(footer_layout);
    d->footer->setObjectName("dtkComposerViewLayoutItemFooterUnfocused");

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    layout->addWidget(d->splitter);
    layout->addWidget(d->footer);

    this->setAcceptDrops(true);

    connect(d->close, SIGNAL(clicked()), this, SLOT(close()));
    connect(d->horzt, SIGNAL(clicked()), this, SLOT(horzt()));
    connect(d->vertc, SIGNAL(clicked()), this, SLOT(vertc()));
    connect(d->maxmz, SIGNAL(clicked()), this, SLOT(maxmz()));

    connect(d->proxy, SIGNAL(focusedIn()), this, SLOT(onFocusedIn()));
    connect(d->proxy, SIGNAL(focusedOut()), this, SLOT(onFocusedOut()));

    d->proxy->setFocus(Qt::OtherFocusReason);

    d->close->setEnabled(d->parent!=NULL);
    d->vertc->setEnabled(false);
    d->horzt->setEnabled(false);
    d->maxmz->setEnabled(false);
}
void dtkComposerViewLayoutItemProxy::focusOutEvent(QFocusEvent *event)
{
    QFrame::focusOutEvent(event);

    emit focusedOut();
}
Ejemplo n.º 7
0
	SearchWidget::SearchWidget(int _offset, bool _isWithButton, QWidget* _parent)
        : QWidget(_parent)
	{
        if (this->objectName().isEmpty())
            this->setObjectName(QStringLiteral("search_widget"));
        active_ = false;
        parent_search_vertical_layout_ = new QVBoxLayout(this);
        parent_search_vertical_layout_->setContentsMargins(0, 0, 0, 0);
        parent_search_vertical_layout_->setSpacing(0);
        horizontal_search_layout_ = new QHBoxLayout();
        horizontal_search_layout_->setContentsMargins(0, 0, 0, Utils::scale_value(0));
        parent_search_vertical_layout_->addLayout(horizontal_search_layout_);

        horizontal_search_layout_->addSpacing(Utils::scale_value(_offset - 8));

        search_icon_ = new Ui::CustomButton(this, ":/resources/contr_search_100.png");
        search_icon_->setOffsets(Utils::scale_value(8), Utils::scale_value(0));
        search_icon_->setActiveImage(":/resources/contr_search_100_active.png");
        search_icon_->setFixedWidth(Utils::scale_value(34));
        search_icon_->setFixedHeight(Utils::scale_value(53));
        search_icon_->setStyleSheet("border: none;");
        horizontal_search_layout_->addWidget(search_icon_);

        parent_widget_ = new QWidget(this);
        search_vertical_layout_ = new QVBoxLayout(parent_widget_);
        search_vertical_layout_->setContentsMargins(0, Utils::scale_value(5), 0, 0);
        search_edit_ = new LineEditEx(this);
        search_edit_->setProperty("SearchEdit", true);
        search_edit_->setPlaceholderText(QT_TRANSLATE_NOOP("search_widget", "Search"));
        search_edit_->setContentsMargins(Utils::scale_value(6), 0, Utils::scale_value(22), 0);
        search_edit_->setAttribute(Qt::WA_MacShowFocusRect, false);
        search_edit_->setStyleSheet(QString("background-color: transparent"));
        Testing::setAccessibleName(search_edit_, "search_edit");
        search_vertical_layout_->addSpacing(Utils::scale_value(0));
        search_vertical_layout_->addWidget(search_edit_);
        horizontal_search_layout_->addWidget(parent_widget_);

        search_edit_icon_ = new CustomButton(this, ":/resources/contr_compose_100.png");
        search_edit_icon_->setOffsets(Utils::scale_value(0), Utils::scale_value(0));
		search_edit_icon_->setOffsetsForActive(Utils::scale_value(2), Utils::scale_value(0));
        search_edit_icon_->setHoverImage(":/resources/contr_compose_100_hover.png");
        search_edit_icon_->setActiveImage(":/resources/contr_clear_100.png");
        search_edit_icon_->setFixedWidth(Utils::scale_value(50));
        search_edit_icon_->setFixedHeight(Utils::scale_value(53));
		search_edit_icon_->setCursor(Qt::PointingHandCursor);
		search_edit_icon_->setFocusPolicy(Qt::NoFocus);
        search_edit_icon_->setStyleSheet("background-color: transparent;");
        Testing::setAccessibleName(search_edit_icon_, "CreateGroupChat");
		horizontal_search_layout_->addWidget(search_edit_icon_);

        horizontal_line_widget_ = new QWidget(this);
        horizontal_line_widget_->setFixedHeight(Utils::scale_value(1));
        horizontal_line_widget_->setStyleSheet(QString("background-color: #dadada;"));
        parent_search_vertical_layout_->addSpacing(0);
        widget_2_ = new QWidget(this);
        horizontal_layout_2_ = new QHBoxLayout(widget_2_);
        horizontal_layout_2_->setContentsMargins(Utils::scale_value(_isWithButton ? 24 : 16), 0, Utils::scale_value(_isWithButton ? 24 : 60), Utils::scale_value(10));
        horizontal_layout_2_->addWidget(horizontal_line_widget_);
        parent_search_vertical_layout_->addWidget(widget_2_);

        QMetaObject::connectSlotsByName(this);
        connect(search_edit_, SIGNAL(textEdited(QString)), this, SLOT(searchChanged(QString)), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(clicked()), this, SLOT(searchStarted()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(escapePressed()), this, SLOT(searchCompleted()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(enter()), this, SLOT(editEnterPressed()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(upArrow()), this, SLOT(editUpPressed()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(downArrow()), this, SLOT(editDownPressed()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(focusOut()), this, SLOT(focusedOut()), Qt::QueuedConnection);
        connect(search_edit_icon_, SIGNAL(clicked()), this, SLOT(clearPressed()), Qt::QueuedConnection);

		setActive(false);
	}