Bug 372342 - Face tag area is very short [patch]
Summary: Face tag area is very short [patch]
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Workflow (show other bugs)
Version: 5.2.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-11 12:52 UTC by Alexander Yavorsky
Modified: 2018-03-30 16:34 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0.0


Attachments
short input field for face tag (304.09 KB, image/png)
2016-11-11 12:52 UTC, Alexander Yavorsky
Details
before (634.41 KB, image/png)
2017-02-28 02:04 UTC, Yingjie Liu
Details
after (587.16 KB, image/png)
2017-02-28 02:05 UTC, Yingjie Liu
Details
inc1 (565.32 KB, image/png)
2017-03-01 13:32 UTC, Yingjie Liu
Details
inc2 (569.91 KB, image/png)
2017-03-01 13:32 UTC, Yingjie Liu
Details
inc3 (520.06 KB, image/png)
2017-03-01 13:33 UTC, Yingjie Liu
Details
inc4 (471.42 KB, image/png)
2017-03-01 13:33 UTC, Yingjie Liu
Details
local code patch for the bug (6.42 KB, patch)
2017-03-03 10:12 UTC, Yingjie Liu
Details
code modified and comment added (5.44 KB, patch)
2017-03-06 04:43 UTC, Yingjie Liu
Details
Cannot understand the options (292.28 KB, image/png)
2017-04-10 10:15 UTC, Jānis Elmeris
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Yavorsky 2016-11-11 12:52:14 UTC
Created attachment 102170 [details]
short input field for face tag

Face tag input box is very short for full names (see attachment)
Probably the best solution to make it change size or make it multi line.
Comment 1 Yingjie Liu 2017-02-28 02:03:20 UTC
Hi,
I spent about 1 day time compiling the code and installing it(failed to compile on Ubuntu 15 because of exiv2 version problem, then succeeded on Ubuntu 16). After compiled the code, I started to read it and trying to fix the bug.
This is the qt working flow about face tag input box: 
Face tag input box is object of class AssignNameWidget, when user clicked "show face tags" Action, object of AssignNameWidget will be created by class FaceGroup.
AssignNameWidget inherits QFrame, the input box is QLineEdit inside the QFrame. QLineEdit can't be made multi line, so I changed the size of QFrame. The attachment "before" shows the input box before I change the width of QFrame. QFrame inherits QWidget, so it can use the method setFixedWidth to change its width.
I add the code:
q->setFixedWidth(500);
in utilities\facemanagement\assignnamewidget.cpp void updateLayout()
The input box has been enlarged in width as shown in attachment "after".
There may be other solutions, I'd like to talk with you. Thanks!
Comment 2 Yingjie Liu 2017-02-28 02:04:10 UTC
Created attachment 104253 [details]
before
Comment 3 Yingjie Liu 2017-02-28 02:05:33 UTC
Created attachment 104254 [details]
after
Comment 4 caulier.gilles 2017-02-28 08:08:43 UTC
Hi Lui,

The source code place to investigate is good.

Hard-coding the size of widget in source code is not the right solution.
You don't take a care about font/widget style used in application.

Look in this class :

https://cgit.kde.org/digikam.git/tree/libs/imageproperties/imagepropertiestxtlabel.h#n90

setLinesNumber() adjust the size of text browser used in Cation/Tags tab from right sidebar. Here the height of text view is adjusted. You can code something similar to adjust the width of face tag widget about an amount of characters.

Gilles Caulier
The
Comment 5 Yingjie Liu 2017-03-01 13:32:08 UTC
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));
    }
}
Comment 6 Yingjie Liu 2017-03-01 13:32:34 UTC
Created attachment 104293 [details]
inc1
Comment 7 Yingjie Liu 2017-03-01 13:32:53 UTC
Created attachment 104294 [details]
inc2
Comment 8 Yingjie Liu 2017-03-01 13:33:19 UTC
Created attachment 104295 [details]
inc3
Comment 9 Yingjie Liu 2017-03-01 13:33:44 UTC
Created attachment 104296 [details]
inc4
Comment 10 caulier.gilles 2017-03-01 14:46:46 UTC
Please Make a patch against git/master and attach it to this bug entry. I will review and test.

Gilles Caulier
Comment 11 Yingjie Liu 2017-03-02 09:29:40 UTC
Hi,
I tested the code I add, then I find that the width of input box should change only in the FaceItem class. While in the AssignNameOverlay class, it has to be unchanged. So I the connect of signal textEditChanged and slot slotSetLineNumber can only be added in FaceItem class. So I add a function void addTagsChangeSignal() for adding the connect, and it will be invoked in FaceItem class.
I commited the code and made a pull request to github, but I did not figure out how to add the patch in this bug entry, should I post some files or use different way to call a pull request?
Comment 12 Yingjie Liu 2017-03-02 10:27:19 UTC
Oh, I know. I should use "git format-patch" to generate the patch file after I commit, sorry for less experience. I will take care of it next time.
Comment 13 caulier.gilles 2017-03-02 11:56:55 UTC
Note : there is nothing to do with github. It's a read only repository.

The real git repository is in KDE server!

"git diff > mydiff.patch" Must do the stuff... as it's explained here :

https://www.digikam.org/contrib

Gilles Caulier
Comment 14 Yingjie Liu 2017-03-03 05:51:04 UTC
Hi Gilles,
I cloned the repository from KDE server, added my code, compiled it and committed it. However, I can't push it to the server using git. So I do as the tutorial said:
https://techbase.kde.org/Development/Tutorials/Git/GitQuickStart#Tell_ssh_to_use_this_key
But I can't find a place in my kde account to edit the public ssh keys, so I still can't push the code. Then I read this tutorial:
https://community.kde.org/Infrastructure/Get_a_Developer_Account#How_to_get_read-write_access_to_git.2Fsvn
As it said, I applied for the KDE developer access (uploaded the ssh keys in applying page) and I set your name as Supporter.
Is it necessary to have the KDE developer access to push the code to server? If so, please help my account to have the access. If not, can you tell me another way of how to set to push the code. Thanks!
Yingjie Liu
Comment 15 caulier.gilles 2017-03-03 07:54:56 UTC
No.

You cannot push. You have no right to do it.

A developer account is for student selected for GSoC event. Not now...

Please make a patch of your difference from your local repository :

git diff > mydiff.patch

...and attach this patch to this entry. That all. It's simple no ???

Gilles Caulier
Comment 16 Yingjie Liu 2017-03-03 10:12:37 UTC
Created attachment 104335 [details]
local code patch for the bug
Comment 17 caulier.gilles 2017-03-05 18:40:42 UTC
Comment on attachment 104335 [details]
local code patch for the bug

Why this complex code :

+    connect(this, SIGNAL(textChanged(QString)),
+            this, SLOT(slotTextChanged(QString)));
+
     connect(d->completer, static_cast<void(TagCompleter::*)(const TaggingAction&)>(&TagCompleter::activated),
             [this](const TaggingAction& action){ completerActivated(action); });
 
@@ -192,6 +195,11 @@ void AddTagsLineEdit::slotTextEdited(const QString& text)
     d->completer->update(text);
 }
 
+void AddTagsLineEdit::slotTextChanged(const QString& txt)
+{
+    emit textEditChanged(txt);
+}

This code is enough :

+    connect(this, SIGNAL(textChanged(QString)),
+            this, SIGNAL(textEditChanged(QString)));

and please comment the patch step by step...

Gilles Caulier
Comment 18 Yingjie Liu 2017-03-06 04:43:35 UTC
Created attachment 104396 [details]
code modified and comment added

Hi, 
I modified the code based on your suggestion: connection signal with signal, not through a slot. I will remember this feature.
I commented the code for readability.
If there are problems or somewhere confusing, I will explain it or change the code.
Comment 19 Jānis Elmeris 2017-04-10 10:15:42 UTC
Created attachment 104937 [details]
Cannot understand the options

I'm looking forward to this fix. Else, I cannot understand the difference between options when creating a new person tag, for example, as they are displayed the same in the interface.
Comment 20 Maik Qualmann 2018-03-30 16:11:23 UTC
*** Bug 392527 has been marked as a duplicate of this bug. ***
Comment 21 Maik Qualmann 2018-03-30 16:28:09 UTC
Git commit 6862c1e3491830e2a42493cb4674abb620b2d19d by Maik Qualmann.
Committed on 30/03/2018 at 16:26.
Pushed by mqualmann into branch 'master'.

set a minimum width to the AddTagsComboBox
FIXED-IN: 6.0.0

M  +2    -2    NEWS
M  +1    -0    core/utilities/facemanagement/assignnamewidget.cpp

https://commits.kde.org/digikam/6862c1e3491830e2a42493cb4674abb620b2d19d
Comment 22 Maik Qualmann 2018-03-30 16:34:50 UTC
I think setting a minimum width is the best solution. The width was dependent on the translated text of the buttons. Depending on the language, the input window was larger or smaller. If the dialog grows automatically, as suggested in the patch, this does not work well with the popup hack.

Maik