Skip to content
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QMenuBar>
#include <QMessageBox>
#include <QShortcut>
#include <QLibrary>
#include <QSplitter>
#include <QUrl>
#include <QWhatsThis>
Expand Down Expand Up @@ -64,6 +65,21 @@

#include "lmmsversion.h"

#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BULID_APPLE) && !defined(LMMS_BUILD_HAIKU)
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Member

Choose a reason for hiding this comment

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

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

Okay then. Keep it if leaving makes sense.

//Work around an issue on KDE5 as per https://bugs.kde.org/show_bug.cgi?id=337491#c21
void disableAutoKeyAccelerators(QWidget* mainWindow)
{
using DisablerFunc = void(*)(QWidget*);
QLibrary kf5WidgetsAddon("KF5WidgetsAddons");
Copy link
Member

Choose a reason for hiding this comment

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

Good, but it may not work on Ubuntu if libkf5widgetsaddons-dev is not installed. A simple solution is here:

// try with version number(for some systems like Ubuntu)
if (!kf5WidgetsAddon.load())
{
	kf5WidgetsAddon.setFileNameAndVersion("KF5WidgetsAddons", 5);
	kf5WidgetsAddon.load();
}

Copy link
Member

Choose a reason for hiding this comment

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

@BumblingCoder May I push a commit addressing this? Or you may do that yourself if you want.

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 you want to pull this tonight you can do it, otherwise I can deal with it tomorrow evening. I think it is safe to always try to load version 5 though, so we could just throw the 5 in the constructor.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is safe to always try to load version 5 though, so we could just throw the 5 in the constructor.

I'm not quite sure, but it should work if libKF5WidgetsAddons.so.5 exists. Since the bug is a KDE 5 + Qt 5 issue, that looks safe for me. I'll wait for you, since you said you can do that tomorrow.

DisablerFunc setNoAccelerators =
reinterpret_cast<DisablerFunc>(kf5WidgetsAddon.resolve("_ZN19KAcceleratorManager10setNoAccelEP7QWidget"));
if(setNoAccelerators)
{
setNoAccelerators(mainWindow);
}
kf5WidgetsAddon.unload();
}
#endif


MainWindow::MainWindow() :
Expand All @@ -76,6 +92,9 @@ MainWindow::MainWindow() :
m_metronomeToggle( 0 ),
m_session( Normal )
{
#if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BULID_APPLE) && !defined(LMMS_BUILD_HAIKU)
disableAutoKeyAccelerators(this);
#endif
setAttribute( Qt::WA_DeleteOnClose );

QWidget * main_widget = new QWidget( this );
Expand Down Expand Up @@ -836,8 +855,8 @@ void MainWindow::createNewProjectFromTemplate( QAction * _idx )
ConfigManager::inst()->factoryTemplatesDir() :
ConfigManager::inst()->userTemplateDir();

Engine::getSong()->createNewProjectFromTemplate(
dirBase + _idx->text() + ".mpt" );
const QString f = dirBase + _idx->text().replace("&&", "&") + ".mpt";
Engine::getSong()->createNewProjectFromTemplate(f);
}
}

Expand Down Expand Up @@ -888,7 +907,7 @@ void MainWindow::updateRecentlyOpenedProjectsMenu()
}

m_recentlyOpenedProjectsMenu->addAction(
embed::getIconPixmap( "project_file" ), *it );
embed::getIconPixmap( "project_file" ), it->replace("&", "&&") );
#ifdef LMMS_BUILD_APPLE
m_recentlyOpenedProjectsMenu->actions().last()->setIconVisibleInMenu(false); // QTBUG-44565 workaround
m_recentlyOpenedProjectsMenu->actions().last()->setIconVisibleInMenu(true);
Expand All @@ -904,12 +923,11 @@ void MainWindow::updateRecentlyOpenedProjectsMenu()




void MainWindow::openRecentlyOpenedProject( QAction * _action )
{
if ( mayChangeProject(true) )
{
const QString & f = _action->text();
const QString f = _action->text().replace("&&", "&");
setCursor( Qt::WaitCursor );
Engine::getSong()->loadProject( f );
setCursor( Qt::ArrowCursor );
Expand Down Expand Up @@ -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("&", "&&") );
Copy link
Member

Choose a reason for hiding this comment

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

Should line 1500 have this change as well?

#ifdef LMMS_BUILD_APPLE
m_templatesMenu->actions().last()->setIconVisibleInMenu(false); // QTBUG-44565 workaround
m_templatesMenu->actions().last()->setIconVisibleInMenu(true);
Expand Down