[digikam] [Bug 372342] Face tag area is very short

Yingjie Liu bugzilla_noreply at kde.org
Wed Mar 1 13:32:08 GMT 2017


https://bugs.kde.org/show_bug.cgi?id=372342

--- Comment #5 from Yingjie Liu <1127553236 at qq.com> ---
Hi,
I changed the program based on your tip.
The input box will increase by the user input, see attachment “inc1”, “inc2”,
“inc3”, “inc4”. The method is as follows:
An object of AssignNameWidget will be constructed after the user add the region
of face, and it contains an object of AddTagsComboBox. In AddTagsComboBox,
there is an AddTagsLineEdit instance “lineEdit”. When the text in lineEdit is
changed, it will emit textChanged(const QString& str), I add a slot to handle
it:
connect(this, SIGNAL(textChanged(QString)), this,
SLOT(slotTextChanged(QString)));
the slot slotTextChanged(QString) will emit another signal to AddTagsComboBox:
void AddTagsLineEdit::slotTextChanged(const QString& txt)
{
    emit textEditChanged(txt);
}
The AddTagsComboBox class will catch the signal and handle it by sending
another signal to AssignNameWidget to tell it the text in lineEdit has changed:
connect(d->lineEdit, SIGNAL(textEditChanged(QString)), this,
SLOT(slotLineEditTextChanged(QString)));
void AddTagsComboBox::slotLineEditTextChanged(const QString& txt)
{
    emit textEditChanged(txt);
}
In the function void AssignNameWidget::Private::setupAddTagsWidget(T* const
widget) of class AssignNameWidget it will handle the signal, I add a line of
connect in this function:
q->connect(widget, SIGNAL(textEditChanged(QString)), q,
SLOT(slotSetLineNumber(QString)));
the slot void slotSetLineNumber(const QString & str) will increase the size of
input box based on the size of str:
void AssignNameWidget::slotSetLineNumber(const QString & str)
{
    int new_width = fontMetrics().width(str);
    int line_width, del_width = 35;

    if(d->comboBox)
    {
        line_width = d->comboBox->getlineWidth();
    }
    else if(d->lineEdit)
    {
        line_width = d->lineEdit->width();
    }
    else
    {
        return ;
    }
    if(line_width>new_width+del_width)
    {
        return ;
    }
    else
    {
        d->q->setFixedWidth(d->q->width()+new_width-(line_width-del_width));
    }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Digikam-devel mailing list