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

Fix recent files #3872

Merged
merged 7 commits into from Nov 4, 2017

Conversation

Projects
None yet
5 participants
@BumblingCoder
Contributor

BumblingCoder commented Oct 10, 2017

This is a quick fix for issue #3741 which causes templates and recent files to not work in KDE.

@BumblingCoder

This comment has been minimized.

Show comment
Hide comment
@BumblingCoder

BumblingCoder Oct 10, 2017

Contributor

This is currently still broken if the & character appears in the file name.

Contributor

BumblingCoder commented Oct 10, 2017

This is currently still broken if the & character appears in the file name.

@tresf

This comment has been minimized.

Show comment
Hide comment
@tresf

tresf Oct 10, 2017

Member

String replacement can most certainly cause other issues. Would it be possible to kill this ridiculous behavior? It's just going to cause more problems.

Here's a solution from the KDE5 bug tracker...

This solution seems to be written for KDE desktop environments only. I assume this is safe, since this problem doesn't occur on Mac or Windows but should be tested on Gnome3, Pantheon, whatever isn't Qt5 based but I would expect the if (!handle) to address non-KDE environments.

cmdrkotori 2017-07-22 05:36:43 UTC
Here's how I solved it. It's a bit ugly.

#include <dlfcn.h>

void Helpers::disableAutoMnemonics(QWidget *widget)
{
    void *handle = dlopen("libKF5WidgetsAddons.so", RTLD_LAZY);
    if (!handle)
        return;
    typedef void (*DisablerFunc)(QWidget *);
    DisablerFunc setNoAccel;
    setNoAccel = reinterpret_cast<DisablerFunc>(dlsym(handle, "_ZN19KAcceleratorManager10setNoAccelEP7QWidget"));
    if (setNoAccel)
        setNoAccel(widget);
    dhandle(handle);
}

Call this function in your object's constructor.

Member

tresf commented Oct 10, 2017

String replacement can most certainly cause other issues. Would it be possible to kill this ridiculous behavior? It's just going to cause more problems.

Here's a solution from the KDE5 bug tracker...

This solution seems to be written for KDE desktop environments only. I assume this is safe, since this problem doesn't occur on Mac or Windows but should be tested on Gnome3, Pantheon, whatever isn't Qt5 based but I would expect the if (!handle) to address non-KDE environments.

cmdrkotori 2017-07-22 05:36:43 UTC
Here's how I solved it. It's a bit ugly.

#include <dlfcn.h>

void Helpers::disableAutoMnemonics(QWidget *widget)
{
    void *handle = dlopen("libKF5WidgetsAddons.so", RTLD_LAZY);
    if (!handle)
        return;
    typedef void (*DisablerFunc)(QWidget *);
    DisablerFunc setNoAccel;
    setNoAccel = reinterpret_cast<DisablerFunc>(dlsym(handle, "_ZN19KAcceleratorManager10setNoAccelEP7QWidget"));
    if (setNoAccel)
        setNoAccel(widget);
    dhandle(handle);
}

Call this function in your object's constructor.

@BumblingCoder

This comment has been minimized.

Show comment
Hide comment
@BumblingCoder

BumblingCoder Oct 10, 2017

Contributor

It looks like that may be the better option. There needs to be some level of string replacement though, because right now files with the & character don't work correctly.

Contributor

BumblingCoder commented Oct 10, 2017

It looks like that may be the better option. There needs to be some level of string replacement though, because right now files with the & character don't work correctly.

Show outdated Hide outdated src/gui/MainWindow.cpp Outdated
Show outdated Hide outdated src/gui/MainWindow.cpp Outdated
@BumblingCoder

This comment has been minimized.

Show comment
Hide comment
@BumblingCoder

BumblingCoder Oct 10, 2017

Contributor

The latest version of this should work on any platform it is needed on.

Contributor

BumblingCoder commented Oct 10, 2017

The latest version of this should work on any platform it is needed on.

BumblingCoder added some commits Oct 10, 2017

Fix & in recent files.
Call into KDE stuff to stop it adding accelerators.
Escape & as && when building the recent file lists, and reverse that when getting the file name.
Show outdated Hide outdated src/CMakeLists.txt Outdated
@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Oct 20, 2017

Member

I don't have KDE but templates and recent files works as it should with this PR applied under linuxmint/mate.

Member

zonkmachine commented Oct 20, 2017

I don't have KDE but templates and recent files works as it should with this PR applied under linuxmint/mate.

@BumblingCoder

This comment has been minimized.

Show comment
Hide comment
@BumblingCoder

BumblingCoder Oct 20, 2017

Contributor

The bug was only present with Qt5 on KDE. The issue is that on KDE Qt loads platform theme stuff that adds accelerators to all of the menu items. I guess it is good to know that it doesn't break things on other desktops though. :)

Contributor

BumblingCoder commented Oct 20, 2017

The bug was only present with Qt5 on KDE. The issue is that on KDE Qt loads platform theme stuff that adds accelerators to all of the menu items. I guess it is good to know that it doesn't break things on other desktops though. :)

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Oct 20, 2017

Member

I guess it is good to know that it doesn't break things on other desktops

Yeah, I tested what I could.

Do you want me to push the rebased version to BumblingCoder:fix-recent-files ?

Member

zonkmachine commented Oct 20, 2017

I guess it is good to know that it doesn't break things on other desktops

Yeah, I tested what I could.

Do you want me to push the rebased version to BumblingCoder:fix-recent-files ?

@BumblingCoder

This comment has been minimized.

Show comment
Hide comment
@BumblingCoder

BumblingCoder Oct 20, 2017

Contributor

I'm fine with you pushing the rebase. The soonest I could do it is about 6 hours from now, and I'm not particularly familiar with git anyway.

Contributor

BumblingCoder commented Oct 20, 2017

I'm fine with you pushing the rebase. The soonest I could do it is about 6 hours from now, and I'm not particularly familiar with git anyway.

@zonkmachine

This comment has been minimized.

Show comment
Hide comment
@zonkmachine

zonkmachine Oct 20, 2017

Member

Aight, fixed! Looks about right... :)

Member

zonkmachine commented Oct 20, 2017

Aight, fixed! Looks about right... :)

@PhysSong

Tested with KDE+Qt5, Ubuntu 16.04. Works as expected. & display issue is also gone. However, you should fix coding styles according to ours.
Note that Ubuntu provides libKF5WidgetsAddons.so.5 only, unless one installs libkf5widgetsaddons-dev. I think it'd better if it works for (K)Ubuntu systems without installing them.
And one more note: we may use QLibrary for this purpose.

Show outdated Hide outdated src/gui/MainWindow.cpp Outdated
Show outdated Hide outdated src/gui/MainWindow.cpp Outdated

BumblingCoder added some commits Nov 3, 2017

Use QLibrary instead of calling dlopen
QLibrary is significantly simpler of code.
We don't extra stuff in the cmake files for QLibrary
Simplify name of loaded library.
QLibrary means you don't need to put "lib" on the front or ".so" on the end.
Show outdated Hide outdated src/gui/MainWindow.cpp Outdated
@@ -64,6 +65,21 @@
#include "lmmsversion.h"
#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BULID_APPLE) && !defined(LMMS_BUILD_HAIKU)

This comment has been minimized.

@PhysSong

PhysSong Nov 3, 2017

Member

Is this check still needed? Since @BumblingCoder switched the loader to QLibrary, it can be removed safely. If there are some reason to keep this, however, leaving is okay, too.

@PhysSong

PhysSong Nov 3, 2017

Member

Is this check still needed? Since @BumblingCoder switched the loader to QLibrary, it can be removed safely. If there are some reason to keep this, however, leaving is okay, too.

This comment has been minimized.

@BumblingCoder

BumblingCoder Nov 3, 2017

Contributor

It should be safe to run the code on all platforms. Pointless on the ones it is disabled on, but safe.

@BumblingCoder

BumblingCoder Nov 3, 2017

Contributor

It should be safe to run the code on all platforms. Pointless on the ones it is disabled on, but safe.

This comment has been minimized.

@tresf

tresf Nov 3, 2017

Member

It saves a few cpu cycles to preprocess it out. I agree with the logic, especially when loading libraries. Why add an unnecessary step to MainWindow for systems which can't experience the bug?

@tresf

tresf Nov 3, 2017

Member

It saves a few cpu cycles to preprocess it out. I agree with the logic, especially when loading libraries. Why add an unnecessary step to MainWindow for systems which can't experience the bug?

This comment has been minimized.

@PhysSong

PhysSong Nov 3, 2017

Member

Why add an unnecessary step to MainWindow for systems which can't experience the bug?

Okay then. Keep it if leaving makes sense.

@PhysSong

PhysSong Nov 3, 2017

Member

Why add an unnecessary step to MainWindow for systems which can't experience the bug?

Okay then. Keep it if leaving makes sense.

Specify the version to make it work on ubuntu.
Ubuntu doesn't ship libKF5WidgetAddons.so, but does ship libKF5WidgetAddons.so.5
@PhysSong

This comment has been minimized.

Show comment
Hide comment
@PhysSong

PhysSong Nov 4, 2017

Member

Merge?

Member

PhysSong commented Nov 4, 2017

Merge?

@tresf

This comment has been minimized.

Show comment
Hide comment
@tresf

tresf Nov 4, 2017

Member

👍

Member

tresf commented Nov 4, 2017

👍

@PhysSong PhysSong merged commit 298f1ec into LMMS:stable-1.2 Nov 4, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@@ -1500,7 +1518,7 @@ void MainWindow::fillTemplatesMenu()
{
m_templatesMenu->addAction(
embed::getIconPixmap( "project_file" ),
( *it ).left( ( *it ).length() - 4 ) );
( *it ).left( ( *it ).length() - 4 ).replace("&", "&&") );

This comment has been minimized.

@lukas-w

lukas-w Apr 11, 2018

Member

Should line 1500 have this change as well?

@lukas-w

lukas-w Apr 11, 2018

Member

Should line 1500 have this change as well?

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