kvirc / KVIrc

The KVIrc IRC Client
http://www.kvirc.net/
GNU General Public License v2.0
232 stars 76 forks source link

KVIInputEditor/KviTopicWidget: Can not edit end of a string where control codes applied (text width calculated incorrectly) #1849

Closed Heufneutje closed 8 years ago

Heufneutje commented 8 years ago

Without formatting: screenshot 2016-01-17 10 40 50 As you can see this works fine. I can see my cursor on the right side of the input bar and the entire thing fits.

With formatting: screenshot 2016-01-17 10 41 27 You can't really tell from this screenshot, but my cursor is actually behind the buttons and this is as far as it lets me scroll, making it impossible to see the last characters of the topic without resizing the window.

My executable information output:

KVIrc 4.9.1 'Aria'

Runtime Info:
System name: Windows Release : 6.2.9200
System version: Windows 8 (x64) (Build 9200)
Architecture: Intel64 Family 6 Model 42 Stepping 7
Qt version: 5.5.1
Qt theme: windowsvista

Build Info:
Build date: 2016-01-04 11:37:23 UTC
Sources date: 20160102
Revision number: git-6037-gb307f8b
System name: Windows-6.3.9600
CPU name: AMD64
Build command: C:/Program Files (x86)/CMake/bin/cmake.exe
Build flags: 
   MANDIR=share/man
   CMAKE_INSTALL_PREFIX=C:/projects/kvirc/build/release
   Threads=Win32
Compiler name: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe
Compiler flags: /DWIN32 /D_WINDOWS /W3 /GR /EHsc
Qt version: 5.5.1

Merging duplicate issue #1881 reported on 24/02/2016

Originally reported by @VFiber over at IRC. 4 days ago.

If a really long block of text exists with formatting (colors/bold etc) and you want to edit it by double clicking it inn topic bar or write into input line, no matter how much you press → on keyboard You wont be able to reach the end.

Requirements to duplicate: A really long sentence with colors/bold

Maye this will work. the color codes/bold wouldnt paste in here but the topic below even on the input line you couldnt see the end when pasting the topic in input line.

e.g. FAILS due to the kvirc color/formatting codes


9~~Welcome to blablabla - Some other funky words- __ Because we can write a really long topic - TO SCREW THIS UP!!!__ | Visit the IRC Channel __ 15Try this - Crazy List <ITAM A> - THIS OTHER - ITEM B ~~ 9 /j #SOMECRAZYIRC-CHAN for Chat, Help, and BANANA MUESLY!!! __ All INFORMATION On this really long topic can be found at https://wwwthisisatopicthatwonwork.com
KVIrc 4.9.1 'Aria'

Runtime Info:
System name: Linux 3.13.0-76-generic
System version: #120-Ubuntu SMP Mon Jan 18 15:59:10 UTC 2016
Architecture: x86_64
Qt version: 5.2.1
Qt theme: fusion

Build Info:
Build date: 2016-02-21 21:25:48 UTC
Sources date: 20160102
Revision number: git-6240-gaedefa9
System name: Linux-3.13.0-76-generic
CPU name: x86_64
Build command: /usr/bin/cmake
Build flags: 
   MANDIR=man
   CMAKE_INSTALL_PREFIX=/usr
   LIB_SUFFIX=/x86_64-linux-gnu
   Threads=POSIX
Compiler name: /usr/bin/c++
Compiler flags: N/A
Qt version: 5.2.1
Heufneutje commented 8 years ago

Just to be sure I updated to the latest dev snapshot and the problem persists.

KVIrc 4.9.1 'Aria'

Runtime Info:
System name: Windows Release : 6.2.9200
System version: Windows 8 (x64) (Build 9200)
Architecture: Intel64 Family 6 Model 42 Stepping 7
Qt version: 5.5.1
Qt theme: windowsvista

Build Info:
Build date: 2016-01-17 08:09:16 UTC
Sources date: 20160102
Revision number: git-6151-g7b05702
System name: Windows-6.3.9600
CPU name: AMD64
Build command: C:/Program Files (x86)/CMake/bin/cmake.exe
Build flags: 
   MANDIR=share/man
   CMAKE_INSTALL_PREFIX=C:/projects/kvirc/build/release
   Threads=Win32
Compiler name: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/cl.exe
Compiler flags: /DWIN32 /D_WINDOWS /W3 /GR /EHsc
Qt version: 5.5.1
Heufneutje commented 8 years ago

I just found out that the normal input bar is also affected by this bug.

un1versal commented 8 years ago

you dont need formatting for that on input bar paste a really long something into it and watch

Heufneutje commented 8 years ago

That one I was aware of. But it's also affected by the formatting, making the result even worse.

un1versal commented 8 years ago

VFiber commented 10 hours ago in #1881

It seems it affects every input field where control codes are allowed (topic and chan single line input as well).

Investigated a bit but couldn't find a solution (however I think I was able to isolate the problem).

If the text is wider than the displayed editor any control code char pushes the width wider than it can be scrolled if we are at the end of the text (does not scroll to the end of the string correctly, characters and the cursor "slips" under the control buttons).

A wild guess: probably the text bounding rect doesn't count with the invisible control chars (CC), but since the draw itself is overridden with https://github.com/kvirc/KVIrc/blob/master/src/kvirc/ui/KviInputEditor.cpp#L835 and the CC's are painted directly into the widget, the bounding rect calculated incorrectly. Solution could be overriding the correct QWidget method that handles this kind of calculations, but I am not that familiar with Qt to figure out which one.


un1versal commented 9 hours ago in #1881

VFiber commented 10 hours ago in #1881 It seems it affects every input field where control codes are allowed (topic and chan single line input as well).

Confirmed

No idea what solution is, but this is basic functionality that must be fixed before any final release is made.

un1versal commented 8 years ago

Actually it seems is the cursor goes behind the UI elements (per say) its out of sight/hidden but it does reach the end of the text.

Heufneutje commented 8 years ago

Yup, that's what I found as well.

Heufneutje commented 8 years ago

I can confirm this works correctly for me on the input bar and the topic bar now. Thanks!