Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Conversation

@Shatur
Copy link
Contributor

@Shatur Shatur commented Nov 25, 2019

No description provided.

@Shatur Shatur changed the title Use QGuiApplication::setDesktopFileName, closes #1 Use QGuiApplication::setDesktopFileName Nov 25, 2019
@Shatur
Copy link
Contributor Author

Shatur commented Nov 25, 2019

After these changes, setAttribute is used only on Windows. I suggest to create separate functions for each attribute as it done in Qt for most platform-specific functions (desktopFileName, for example) that do nothing on other platforms.

I also noticed that you use tabs instead of spaces, which is forbidden by the Qt coding style, but you decide for yourself.

Copy link
Owner

@Skycoder42 Skycoder42 left a comment

Choose a reason for hiding this comment

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

Please check the comments in the files. Otherwise ready to be merged. I do use tabs on purpose, as it's my personal preference. I am aware of the Qt coding guidelines.

Removing the setAttribute seems like a good idea. If you want, you can add that change as well, but I can do that by myself as well.

@Shatur
Copy link
Contributor Author

Shatur commented Nov 26, 2019

Removing the setAttribute seems like a good idea. If you want, you can add that change as well, but I can do that by myself as well.

If you are busy, then I can do :) If yes, do I need to leave the prefix Win as in enums?

@Skycoder42
Copy link
Owner

Removing the setAttribute seems like a good idea. If you want, you can add that change as well, but I can do that by myself as well.

If you are busy, then I can do :) If yes, do I need to leave the prefix Win as in enums?

That would be cool. I would prefer to keep the "Win" prefix, to make clear those methods work only on windows.

@Shatur
Copy link
Contributor Author

Shatur commented Nov 26, 2019

Sorry for a lot of questions, I just want to implement it as you like :)

  • You install event filter that used only for Windows. Maybe install it only for Windows?
  • New methods instead of setAttribute will be used only for Windows. Should I make empty virtual functions in QTaskbarControlPrivate instead of pure virtual? If yes, will be better to use this approach for setWindow?
  • setWindow is used only for Windows. Maybe do not use Windows prefixes for new methods too?
  • In QX11TaskbarControl in createPrivate you do not specify a parent for the object. Is it a typo?

@Skycoder42
Copy link
Owner

Skycoder42 commented Nov 27, 2019

  1. Sure, if it can be moved easily, why not
  2. Yes please, do it for the new methods and set window as well
  3. The difference is, that setWindow is required on windows, not optional. Also, it's an implementation detail, not a direct visual change. To prevent developers from "skipping" it, I would prefer to keep it as is, but still add the windows prefix for the others
  4. Not a typo, the x11 simply does not need the qptr. It is not the parent, as the private implementations are not QObjects

@Shatur
Copy link
Contributor Author

Shatur commented Nov 30, 2019

Maybe I should add setProgress, setCounter and other methods to QTaskbarControlPrivate as with windowsBadgeIcon, windowsBadgeTextColor and windowsProgressState?

@Skycoder42
Copy link
Owner

No, I would prefer those to stay pure virtual, as they are essential and available on all platforms

@Shatur
Copy link
Contributor Author

Shatur commented Nov 30, 2019

Sorry, it was a typo :) I meant to make getters for progressVisible, progress and other members (like progress(), counter()) instead of access to this members directly as a friend.

@Skycoder42
Copy link
Owner

Still, keep it as is. The private class is just a design choice, see https://en.cppreference.com/w/cpp/language/pimpl

So it's correct that those are accessed via a friend declaration. The virtual methods are only there for the necessary platform abstraction.

@Shatur
Copy link
Contributor Author

Shatur commented Dec 1, 2019

Yes, I know about PIMPL, just suggested for consistency. But I think that you are right, keep it as members will be better.

The last thing that I want to suggest is to add setWindow to QTaskbarControl class as it done in QWinTaskbarButton. This will allow to avoid using extra event filter and user will must to set QWindow in showEvent as for QWinTaskbarButton. It may be useful if user already have showEvent override, custom event filter or already valid QWindow. Also it allow to avoid passing a valid QWidget to the constructor. What do you think?

@Skycoder42
Copy link
Owner

The last thing that I want to suggest is to add setWindow to QTaskbarControl class as it done in QWinTaskbarButton. This will allow to avoid using extra event filter and user will must to set QWindow in showEvent as for QWinTaskbarButton. It may be useful if user already have showEvent override, custom event filter or already valid QWindow. Also it allow to avoid passing a valid QWidget to the constructor. What do you think?

I am torn on this one... I get you point, but I prefer that this is done "automagically" for widgets. Maybe it would be possible to have both? Provide setWidget which uses the widget and registers the eventfilter and a setWindow which ignores/disables the eventfilter and sets the window directly instead. What do you think about that idea

@Shatur
Copy link
Contributor Author

Shatur commented Dec 1, 2019

Sounds good. I will try to implement it :)

@Shatur
Copy link
Contributor Author

Shatur commented Dec 3, 2019

What do you think about this implementation?

I combined it into one function that checks if QWindow is valid and installs event filter if need to wait for initialization. You need to set QWindow only once, so event filter will be removed after initialization. I also changed return to QObject::eventFilter(obj, event); as it done in documentation.

And I removed extra pointer from QTaskbarControlPrivate constructor because it is not needed anymore. Because of this, I changed private members to protected and added _ prefix to avoid conflicts with functions parameters.

Is it okay?

* Use static_cast instead of C-style cast;
* Fix implicit conversion.
Copy link
Owner

@Skycoder42 Skycoder42 left a comment

Choose a reason for hiding this comment

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

We are getting somewhere. I like your idea, but there are still a few things that need to change. Have a look at the comments in the files. Sorry that this takes so long, but big PRs like this one always need some tweaking. If you implement the requested changes, the PR should finally be ready to be merged

@Shatur Shatur requested a review from Skycoder42 December 4, 2019 16:37
@Shatur
Copy link
Contributor Author

Shatur commented Dec 4, 2019

Done! But instead of overload I created a separate QTaskbarControl::setWidget function because of ambiguous (QWidget and QWindow inherit both from QObject).

Copy link
Owner

@Skycoder42 Skycoder42 left a comment

Choose a reason for hiding this comment

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

Almost done. Just two more changes

@Shatur Shatur requested a review from Skycoder42 December 4, 2019 18:54
@Shatur
Copy link
Contributor Author

Shatur commented Dec 4, 2019

Feel free to request any other changes or refactoring.

@Skycoder42 Skycoder42 merged commit 1dedfbc into Skycoder42:master Dec 5, 2019
@Shatur Shatur deleted the desktopfilename branch December 5, 2019 08:05
@Shatur
Copy link
Contributor Author

Shatur commented Dec 5, 2019

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants