Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1127 #1457

Merged
merged 9 commits into from
Mar 6, 2017
Merged

Fixes #1127 #1457

merged 9 commits into from
Mar 6, 2017

Conversation

ketanhwr
Copy link
Contributor

@ketanhwr ketanhwr commented Feb 28, 2017

I've added the eye feature as mentioned in #1127
I took reference from what @IMMZ had previously done and fixed some additional requests that @bjorn made. I've attached a screenshot of what I've done and the eye is symmetric vertically.

Screenshot

Copy link
Member

@bjorn bjorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for starting up this change again! I have some additional comments for you though. :-)

We really need a closed eye icon on the invisible layers. Otherwise you would not even guess that you can click on that empty area to make the layer visible again.

The eye is not centered and way too small on HiDpi screens:

selection_149

What you could do here is just draw the icon larger depending on the DPI, though of course that won't look very nice either. Use QPaintDevice::devicePixelRatio to determine an appropriate scale factor. Ideally, we'll have a more detailed icon to use instead for high-resolution screens (I'll be looking at using the new icons done for GIMP).

Finally, we'll eventually need a different solution than overriding the drawCheck function, because there will be two check states: visible and locked. This doesn't mean we can't use this method for drawing the eye icon for now though.


protected:
void drawCheck(QPainter *painter, const QStyleOptionViewItem &option,
const QRect &rect, Qt::CheckState state) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mark this virtual function override with the C++11 override keyword.

@ketanhwr
Copy link
Contributor Author

@bjorn, the image is not exactly visible. Can you update the link? And I'll try to make the changes requested :)

@bjorn
Copy link
Member

bjorn commented Feb 28, 2017

the image is not exactly visible. Can you update the link? And I'll try to make the changes requested :)

Hmm, the image is uploaded to GitHub and is displaying fine for me. What do you mean with "not exactly visible"?

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 1, 2017

It's now visible, I don't know it wasn't visible to me few hours back.

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 1, 2017

@bjorn 've marked the function with the override keyword and I've added another icon to make the invisible layers. Here is a screenshot of the same.

Screenshot

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 1, 2017

And instead of drawing a larger icon, won't it be alright if we could just shift the origin of the icon a bit down? That'll look pretty good and won't seem odd.

@bjorn
Copy link
Member

bjorn commented Mar 1, 2017

And instead of drawing a larger icon, won't it be alright if we could just shift the origin of the icon a bit down? That'll look pretty good and won't seem odd.

Yes, centering the icon will be fine for now as well, though it'll need to be scaled properly before the next release. But I can do this later.

Can you look into also using this eye icon in the Objects view? It also features checkboxes to toggle visibility.

const QRect &rect, Qt::CheckState state) const override;

private:
QPixmap visiblePixmap, invisiblePixmap;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use:

    QPixmap mVisiblePixmap;
    QPixmap mInvisiblePixmap;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry about that, I totally forgot!

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 1, 2017

Okay, I'll make the changes 👍

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 1, 2017

I've added the eye icon in object dock as well. I'll try to fix the origin thing, but I'm not sure how to reproduce it so it'll take some time. Apart from this, is everything else fine?

Copy link
Member

@bjorn bjorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some final (I hope) comments on the code. :-)

*/

#include "layerdock.h"
#include "eyevisibilitydelegate.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention, but a cpp file should always include its own header first. This is mainly to make sure all headers include their own dependencies.

{
Q_UNUSED(option)
if (state == Qt::Checked)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding style: Please don't use { and } for single-line bodies (also for multi-line bodies, they should not be on their own line, except for functions).

class QAbstractProxyModel;
class QLabel;
class QModelIndex;
class QUndoStack;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clean up the includes and forward declarations. You do not need mapdocument.h, QDockWidget, etc.

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 1, 2017

@bjorn can you look into the icon problem now? I think changing the size of icon from 12x12 to 16x16 fixes the issue. I've also made the changes in the code that you reviewed :)

@bjorn
Copy link
Member

bjorn commented Mar 1, 2017

I'll give the patch another try in the evening.

Sorry to be nitpicking, but I think you can also remove includes for QTreeView and QApplication.

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 1, 2017

If it's a learning experience for me, then it's not nitpicking 😄

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 2, 2017

@bjorn did you take a look into the patch?

@bjorn
Copy link
Member

bjorn commented Mar 2, 2017

Sorry, a lot of things came up yesterday evening, I'll try it again this evening!

Copy link
Member

@bjorn bjorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot on my machine at 96 DPI shows two problems:

selection_151

  • The icon is cut off, because by default the space available for the check is only 14x14px (see qfusionstyle.cpp line 3133 (values for PM_IndicatorWidth and PM_IndicatorHeight end up as the size of the rectangle passed into drawCheck).

  • The icon is barely visible for selected rows. I like the new icon (did you do it yourself?), but I think the eye does need the white part to be opaque (or the color of the icon should follow the text color).

I think also it would be nice if for the invisible layers, the eye icon was faded out a little (not the red line). I wonder if we can have the line in black then, since red is not going to work nicely in combination with a red selection color.

See also my inline comments.

* Copyright 2008-2017, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
* Copyright 2010, Andrew G. Crowell <overkill9999@gmail.com>
* Copyright 2010, Jeff Bland <jksb@member.fsf.org>
* Copyright 2011, Stefan Beller <stefanbeller@googlemail.com>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a clean list of authors here, this list makes no sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

/*
* eyevisibilitydelegate.h
* Copyright 2008-2013, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
* Copyright 2010, Andrew G. Crowell <overkill9999@gmail.com>
Copy link
Member

@bjorn bjorn Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix list of authors here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (state == Qt::Checked)
painter->drawPixmap(rect, mVisiblePixmap, QRect(0, 0, rect.width(), rect.height()));
else if (state == Qt::Unchecked)
painter->drawPixmap(rect, mInvisiblePixmap, QRect(0, 0, rect.width(), rect.height()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For drawPixmap, the second rectangle you pass in is the source rectangle. This has nothing to do with rect and should always just be the full image (which means you can just remove it, and rely on the drawImage overload the only specifies the target rectangle instead). The icon should automatically render larger at a higher DPI then, and it would also fix this "cut off" problem, meaning that you can probably keep the 16x16px icon you have now (though it may look blurry when drawn scaled to 14x14px).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that was a stupid mistake :/

@@ -236,7 +236,8 @@ SOURCES += aboutdialog.cpp \
utils.cpp \
varianteditorfactory.cpp \
variantpropertymanager.cpp \
zoomable.cpp
zoomable.cpp \
eyevisibilitydelegate.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this list of files sorted alphabetically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 3, 2017

I took the icon from the Noun Project, they've a great bunch of icons! I didn't realise my mistake in drawPixmap one, but I've fixed it now. The icon looks pretty good now.

@bjorn bjorn merged commit 2f3a7cd into mapeditor:master Mar 6, 2017
@bjorn
Copy link
Member

bjorn commented Mar 6, 2017

Alright, I've merged this, but I did spend some time looking for an alternative icon because I wasn't very happy with this one. Eventually I went with the Tango icon used by Inkscape. I also added a higher resolution one, because a 14x14px scaled one didn't look so great on my screen. See change 6db4285.

Thanks for your efforts!

@ketanhwr
Copy link
Contributor Author

ketanhwr commented Mar 6, 2017

The icon looks better, and I didn't know about QIcon, thanks! 😄

@ketanhwr ketanhwr deleted the eye-icon branch March 6, 2017 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants