예제 #1
0
void MainWidget::centralLayout()
{
    //中央区左侧
    QWidget* central_l = new QWidget;
    central_l->setLayout(new QVBoxLayout);
    central_l->layout()->setMargin(0);
    central_l->layout()->setSpacing(0);
    central_l->layout()->addWidget(createListWidget());
    central_l->layout()->addWidget(createTreeWidget());

    //中央区右侧
    QWidget* central_r = new QWidget;
    central_r->setStyleSheet("QWidget{background-color:white;}");
    central_r->setLayout(new QVBoxLayout);
    central_r->layout()->addWidget(createIconWidget());

    this->m_central->addWidget(central_l);
    this->m_central->addWidget(central_r);

    QList<int> list;
    list<<200<<700;
    this->m_central->setSizes(list);
}
예제 #2
0
파일: itemnotes.cpp 프로젝트: Ack0/CopyQ
ItemNotes::ItemNotes(ItemWidget *childItem, const QString &text, const QByteArray &icon,
                     bool notesAtBottom, bool showIconOnly, bool showToolTip)
    : QWidget( childItem->widget()->parentWidget() )
    , ItemWidget(this)
    , m_notes(NULL)
    , m_icon(NULL)
    , m_childItem(childItem)
    , m_notesAtBottom(notesAtBottom)
    , m_timerShowToolTip(NULL)
    , m_toolTipText()
{
    m_childItem->widget()->setObjectName("item_child");
    m_childItem->widget()->setParent(this);

    if (showIconOnly || !icon.isEmpty())
        m_icon = createIconWidget(icon, this);

    if (!showIconOnly)
        m_notes = new QTextEdit(this);

    QBoxLayout *layout;

    if (showIconOnly) {
        layout = new QHBoxLayout(this);
        layout->addWidget(m_icon, 0, Qt::AlignRight | Qt::AlignTop);
        layout->addWidget(m_childItem->widget());
    } else {
        m_notes->setObjectName("item_child");
        m_notes->setProperty("CopyQ_item_type", "notes");

        m_notes->setReadOnly(true);
        m_notes->setUndoRedoEnabled(false);

        m_notes->setFocusPolicy(Qt::NoFocus);
        m_notes->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        m_notes->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        m_notes->setFrameStyle(QFrame::NoFrame);
        m_notes->setContextMenuPolicy(Qt::NoContextMenu);

        m_notes->viewport()->installEventFilter(this);

        m_notes->setPlainText( text.left(defaultMaxBytes) );

        layout = new QVBoxLayout(this);

        QHBoxLayout *labelLayout = new QHBoxLayout;
        labelLayout->setMargin(0);
        labelLayout->setContentsMargins(notesIndent, 0, 0, 0);

        if (m_icon)
            labelLayout->addWidget(m_icon, 0, Qt::AlignLeft);

        labelLayout->addWidget(m_notes, 1, Qt::AlignLeft);

        if (notesAtBottom) {
            layout->addWidget( m_childItem->widget() );
            layout->addLayout(labelLayout);
        } else {
            layout->addLayout(labelLayout);
            layout->addWidget( m_childItem->widget() );
        }
    }

    if (showToolTip) {
        m_timerShowToolTip = new QTimer(this);
        m_timerShowToolTip->setInterval(250);
        m_timerShowToolTip->setSingleShot(true);
        connect( m_timerShowToolTip, SIGNAL(timeout()),
                 this, SLOT(showToolTip()) );
        m_toolTipText = text;
    }

    layout->setMargin(0);
    layout->setSpacing(0);
}