Bug 181006 - Konsole won't allow 10% or 20% transparency
Summary: Konsole won't allow 10% or 20% transparency
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 2.2
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-16 20:22 UTC by V. Augustine
Modified: 2009-01-18 01:44 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
quick fix: call qRound instead of casting to int (592 bytes, patch)
2009-01-17 02:43 UTC, Andre Wisplinghoff
Details

Note You need to log in before you can comment on or make changes to this bug.
Description V. Augustine 2009-01-16 20:22:45 UTC
Version:           2.2 (using 4.1.96 (KDE 4.1.96 (KDE 4.2 RC1)), Kubuntu packages)
Compiler:          cc
OS:                Linux (x86_64) release 2.6.27-9-generic

Konsole won't allow me to change the transparency to 10% or 20% -- this is very specific: If I set it to one of those values, it is set to that value -1 (so, 9% or 19%).

# Steps to reproduce

1. Open Konsole
2. Settings -> Edit Current Profile -> Appearance Tab
3. Select "Edit"
4. Drag "Background transparency" slider to 10%
5. Press "OK"
6. Press "Apply"
7. Press "Edit" again
8. Observe that "Background transparency" is set to 9%

This only occurs at 10% and 20%; it does not occur at any other values. It occurs if, instead of pressing "Apply" in 6, you press "OK" and follow steps 2 & 3.

# Expected Behavior

When I set the transparency to 10% or 20%, it should stay at that value.
Comment 1 Andre Wisplinghoff 2009-01-17 02:43:35 UTC
Created attachment 30333 [details]
quick fix: call qRound instead of casting to int

i was unable to test the fix, because I don't have an usable kde build environment set up, but I think i found the issue:

opacity is stored as a floating point number and the operation of muliplying it with 100 and casting it to int sometimes leads to a number one less than is expected - caused by inaccuracy of the floating point number.
why isn't opacity stored as an int? perhaps that would be a better fix.

it can be that <QtGlobal> must be added as an include to make it compile.
Comment 2 Robert Knight 2009-01-18 01:39:10 UTC
SVN commit 912671 by knight:

Fix transparently values of 10%, 20% and others not being
saved and restored correctly in color scheme editor.  Use
qRound() on the opacity float instead of (int) cast.

Patch by Andre Wisplinghoff

BUG:181006



 M  +1 -1      ColorSchemeEditor.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=912671
Comment 3 Robert Knight 2009-01-18 01:44:55 UTC
> why isn't opacity stored as an int? perhaps that would be a better fix.

Qt has two ways of representing alpha - int values from 0 to 255 and floats from 0 to 1.  I thought that 0..1 would be easier to understand when reading the code and/or config files.

> it can be that <QtGlobal> must be added as an include to make it compile.

<QtGlobal> is included by all other Qt includes so any source files which include any Qt or KDE headers will have the declarations from <QtGlobal> available to them.