0

I have two versions of Ubuntu running on different VMs under VMWare workstation: 16.04 and 18.04.

I really dislike the file open/save interface I have on 18.05 and I like the one I have on 16.04. I assume the issue is the different versions of Qt running.

On 16.04 I seem to be running Notepadqq v.1.4.2 and Qt 5.5.1

On 18.04 I seem to be running Notepadqq v.1.4.2 and Qt 5.9.5

That is, the same version of Notepadqq but different versions of Qt.

When I do a

whereis qt

in both VMs, I get "nothing" back. All I see is

qt:

Is my assumption correct? Is the cause of the different file open/save GUI due to a difference in qt versions or is it a difference in OS (16.04 v 18.04) versions?

If it is a difference in Qt versions, how do I go from Qt version 5.9.5 back to 5.5.1 in my 18.04 VM?

RalphShnelvar
  • 113
  • 1
  • 6

2 Answers2

0

I'm not 100% sure why, but it looks like the application GUI behaves differently when installed using the PPA compared to when it is installed as a snap. I have seen this with another application.

If you carry out the following steps, you should end up with notepadqq using a non-native open/save dialog in Ubuntu 18.04.

Uninstall the current notepadqq

sudo apt remove notepadqq

Clean up the system by removing the PPA

sudo add-apt-repository -r ppa:notepadqq-team/notepadqq
sudo apt update

Install notepadqq as a snap

sudo snap install notepadqq

Launch notepadqq and check the open/save dialog. On my system, the non-native dialog appears.

gsxruk
  • 1,390
0

A second option.

The only way I can think of to ensure this works as you require is to modify the source code and build notepadqq yourself. This is because, Qt decides if a native dialog is used unless the developer overrides this behaviour (which isn't the case here).

These steps will guide you through this process.

Remove the notepadqq snap

sudo snap remove notepadqq

Install prerequisites

sudo apt install git build-essential
sudo apt install qt5-default qttools5-dev-tools qtwebengine5-dev libqt5websockets5-dev libqt5svg5 libqt5svg5-dev

Download the notepadqq source

cd ~/Downloads
git clone --recursive https://github.com/notepadqq/notepadqq.git

Create the patch file

I've written a patch file to make it easier to make the required modifications. This patch file will force the use of a non-native dialog.

Open a new file in a text editor, copy the following and then paste it into the text editor. Save the document as notepadqq.patch in ~/Downloads. Make sure you copy the entire file exactly.

--- mainwindow.cpp  2018-07-29 13:42:51.758184000 +0100
+++ mainwindow_patched.cpp  2018-07-29 13:53:06.888952000 +0100
@@ -845,7 +845,7 @@
                                 tr("Open"),
                                 defaultUrl,
                                 tr("All files (*)"),
-                                0, 0);
+                                0, QFileDialog::DontUseNativeDialog);

     if (fileNames.empty())
         return;
@@ -866,7 +866,7 @@
     BackupServicePauser bsp; bsp.pause();

     // Select directory
-    QString folder = QFileDialog::getExistingDirectory(this, tr("Open Folder"), defaultUrl.toLocalFile(), 0);
+    QString folder = QFileDialog::getExistingDirectory(this, tr("Open Folder"), defaultUrl.toLocalFile(), QFileDialog::DontUseNativeDialog);
     if (folder.isEmpty())
         return;

@@ -1052,7 +1052,7 @@
                            tr("Save as"),
                            getSaveDialogDefaultFileName(tabWidget, tab).toLocalFile(),
                            tr("Any file (*)"),
-                           nullptr, nullptr);
+                           nullptr, QFileDialog::DontUseNativeDialog);

     if (filename != "") {
         m_settings.General.setLastSelectedDir(QFileInfo(filename).absolutePath());
@@ -2463,7 +2463,7 @@
     // See https://github.com/notepadqq/notepadqq/issues/654
     BackupServicePauser bsp; bsp.pause();

-    QString file = QFileDialog::getOpenFileName(this, tr("Extension"), QString(), "Notepadqq extensions (*.nqqext)");
+    QString file = QFileDialog::getOpenFileName(this, tr("Extension"), QString(), "Notepadqq extensions (*.nqqext)", nullptr, QFileDialog::DontUseNativeDialog);
     if (!file.isNull()) {
         Extensions::InstallExtension *installExt = new Extensions::InstallExtension(file, this);
         installExt->exec();
@@ -2547,7 +2547,7 @@
                            tr("Open Session..."),
                            recentFolder,
                            tr("Session file (*.xml);;Any file (*)"),
-                           0, 0);
+                           0, QFileDialog::DontUseNativeDialog);

     if (filePath.isEmpty())
         return;
@@ -2574,6 +2574,7 @@
     dialog.setFileMode(QFileDialog::AnyFile);
     dialog.setDefaultSuffix("xml");
     dialog.setAcceptMode(QFileDialog::AcceptSave);
+    dialog.setOption(QFileDialog::DontUseNativeDialog);

     if (!dialog.exec())
         return;

Apply the patch file

cd ~/Downloads
patch ~/Downloads/notepadqq/src/ui/mainwindow.cpp notepadqq.patch

Build and install notepadqq

cd ~/Downloads/notepadqq
./configure --prefix /usr
make
sudo make install

To make command nqq work (optional)

sudo ln -s /usr/bin/notepadqq /usr/bin/nqq

Launch notepadqq. Now, you should have what you had before but the open/save dialog should be non-native.

I did notice that the icon for notepadqq does not appear. If I find out how to fix that, I'll update the answer.

Hope that helps.

Update for icon

It looks like the icon cache has to be updated as follows.

sudo gtk-update-icon-cache /usr/share/icons/hicolor/

The icon is displayed correctly once this command has been executed.

gsxruk
  • 1,390