New tab placed after current tab when middle-clicking
ClosedPublic

Authored by hallas on Feb 21 2019, 2:51 PM.

Details

Summary

New tabs should be placed after the currently active tab when using
middle click.

Test Plan

Open new tab from the places panel using middle click, verify that the
Open new tab from the folders panel using middle click, verify that the
tab is opened after the current tab
Open new tab by middle clicking on the Back button, verify that the tab
is opened after the current tab
Open new tab by middle clicking on the Forward button, verify that the tab
is opened after the current tab

FEATURE: 403690

Diff Detail

Repository
R318 Dolphin
Branch
open_new_tab_after_current_tab_middle_click (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 9107
Build 9125: arc lint + arc unit
hallas created this revision.Feb 21 2019, 2:51 PM
Restricted Application added a project: Dolphin. · View Herald TranscriptFeb 21 2019, 2:51 PM
Restricted Application added a subscriber: kfm-devel. · View Herald Transcript
hallas requested review of this revision.Feb 21 2019, 2:51 PM
hallas added inline comments.Feb 21 2019, 2:54 PM
src/dolphintabwidget.h
33 ↗(On Diff #52209)

@elvisangelaccio - What do you think about having this enum class placed here? Should it have it's own file or is this fine?

ngraham requested changes to this revision.Feb 21 2019, 7:38 PM

Thanks for sending a follow-up patch so quickly!

I tried out your test plan (thanks for that!) and everything works but one thing: if I middle-click the back button, the new tab is opened at the end, not after the current tab.

This revision now requires changes to proceed.Feb 21 2019, 7:38 PM
hallas updated this revision to Diff 52236.Feb 21 2019, 7:58 PM

Fix middle-click on back/forward button

Thanks for sending a follow-up patch so quickly!

I tried out your test plan (thanks for that!) and everything works but one thing: if I middle-click the back button, the new tab is opened at the end, not after the current tab.

Should be fixed now, actually both middle-click on back and forward was broken :/

ngraham accepted this revision.Feb 21 2019, 8:10 PM

Thanks, much better. Putting the DolphinTabPlacement class in dolphintabwidget makes sense to me, but make sure @elvisangelaccio agrees. :)

This revision is now accepted and ready to land.Feb 21 2019, 8:10 PM
hallas added inline comments.Feb 24 2019, 5:23 PM
src/dolphintabwidget.h
33 ↗(On Diff #52209)

@elvisangelaccio - do you have any comments for this?

elvisangelaccio requested changes to this revision.Feb 24 2019, 5:50 PM
elvisangelaccio added inline comments.
src/dolphinmainwindow.h
51

This is a bit weird, never seen forward declarations used for an enum. Why not just #include "dolphintabwidget.h" ?

src/dolphintabwidget.h
33 ↗(On Diff #52209)

No it's fine here. But why make it an enum class? Is it because you wanted to forward declare it? If yes, see my comment above.

This revision now requires changes to proceed.Feb 24 2019, 5:50 PM
hallas added inline comments.Feb 24 2019, 6:36 PM
src/dolphinmainwindow.h
51

We could, I was just trying to minimize the amounts of includes in the header file, I guess that is also the reason for the other forward declarations? One of the arguments for using enum class is specifically that you can forward declare it, it is technically also possible with an unscoped enumeration but you can't do it in all situations.

src/dolphintabwidget.h
33 ↗(On Diff #52209)

Forward declaration is one argument, but also that you get a scope so that the individual enumerators doesn't name clash with anything else. Does KDE have any general guidelines for using/not using this? Should I change it?

src/dolphinmainwindow.h
51

We could, I was just trying to minimize the amounts of includes in the header file, I guess that is also the reason for the other forward declarations?

Those are fine because you don't need to include the whole header if you just need a pointer to the object.
But DolphinTabPlacement is part of the API of DolphinTabWidget, so it's ok to include its header file. Otherwise you have to duplicate a pieace of the API here. As you had to do it in dolphinview.h. Imho this makes the code (and the patch) more complex without gaining anything useful.

src/dolphintabwidget.h
33 ↗(On Diff #52209)

The clash protection is a good argument, but then it's an unrelated change that should go in another commit (and there are many other old-style enums in dolphin which should be ported).

I don't think we have guidelines about enums in KDE, but using enum class for new code makes sense of course.

hallas updated this revision to Diff 52517.Feb 25 2019, 10:33 AM
hallas marked an inline comment as done.

Reverted change of DolphinTabWidget::TabPlacement to enum class.
Rebased.

hallas added inline comments.Feb 25 2019, 10:33 AM
src/dolphintabwidget.h
33 ↗(On Diff #52209)

I have reverted this part of the change, so keeping the enum as an enum and as a type within DolphinTabWidget and then include it in the headers that now require it - hope that is ok :)

ngraham accepted this revision.Feb 25 2019, 4:19 PM

Looks great, works great. @elvisangelaccio?

src/dolphinmainwindow.cpp
1340

We are going to use this lambda in 3 different places. Maybe this calls for a new openNewTabAfterCurrentTab() private slot.

src/dolphinpart.cpp
97 ↗(On Diff #52517)

Why this change? We are not using the TabPlacement argument here, anyway

hallas updated this revision to Diff 53033.Mar 3 2019, 6:24 AM
hallas marked an inline comment as done.

Create dedicated functions in DolphinMainWindow for opening a tab after the current tab and as the last tab.

hallas marked an inline comment as done.Mar 3 2019, 6:24 AM
hallas added inline comments.
src/dolphinmainwindow.cpp
1340

I have create dedicated functions for both cases and use them throughout this class.

src/dolphinpart.cpp
97 ↗(On Diff #52517)

This change has been reverted :)

ngraham accepted this revision.Mar 3 2019, 2:40 PM
This revision is now accepted and ready to land.Mar 9 2019, 10:46 AM
hallas closed this revision.Mar 9 2019, 11:12 AM