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
  • What desktop environment are you using? Have you amended the style used by Qt? – gsxruk Jul 28 '18 at 11:12
  • gsxruk, thank you for answering. I do not understand your question. – RalphShnelvar Jul 28 '18 at 14:14
  • (Sorry for the repeat. I took more than 5 minutes to edit this answer.)

    gsxruk, thank you for answering. I do not understand your question.

    I think my answers to your questions are:

    1. Gnome. How does one determine what the desktop environment is for sure?
    2. How does one amend the style used by Qt? Are you referring to https://www.pcsuggest.com/qt5ct-change-qt5-application-style/ ?
    – RalphShnelvar Jul 28 '18 at 14:23
  • If you go to "Settings" and then "About" you will see Gnome somewhere in there if you are using Gnome. Have you changed anything using qt5ct? The reason I ask, is that when I lauch Notepadqq in 16.04 and 18.04, I see no difference in the open/save dialog. – gsxruk Jul 28 '18 at 14:39
  • Sigh. There is nothing in "About" about Gnome in settings.

    You can see what my desktop looks like here: https://pasteboard.co/HwyQRbr.png

    Also, I have not installed or used qt5ct.

    – RalphShnelvar Jul 28 '18 at 14:56
  • And another printscreen: https://pasteboard.co/HwyTYcg.png – RalphShnelvar Jul 28 '18 at 15:03
  • Your 2nd screenshot shows "Gnome 3.28.2". – gsxruk Jul 28 '18 at 15:09
  • Could you provide screenshots of the open/save dialog in 16.04 and 18.04? – gsxruk Jul 28 '18 at 15:10
  • The 18.04 version is here: https://pasteboard.co/HwAIOPi.png. The 16.04 version is here: https://pasteboard.co/HwANesp.png . What I'd prefer would be a combination of both where I have a list of folders PLUS the ability to paste in a full pathname. But in the absence of that, I MUCH prefer the ability to paste in a name. – RalphShnelvar Jul 28 '18 at 19:52
  • In 18.04 you have a native dialog. In 16.04 you have don't have a native dialog. It's a little strange because I have a non-native dialog in both 16.04 and 18.04 (which is what you want). How did you install Notepadqq? Did you install it using the ppa? – gsxruk Jul 29 '18 at 08:51
  • @gsxruk thank you so much for helping me. (1) sudo add-apt-repository ppa:notepadqq-team/notepadqq (2) sudo apt-get update (3) sudo apt-get install notepadqq (4) I followed the instructions in https://tecadmin.net/install-notepadqq-text-editor-ubuntu/ – RalphShnelvar Jul 29 '18 at 10:40
  • As far as I can tell, I did the same installation process in 16.04 as I did in 18.04. – RalphShnelvar Jul 29 '18 at 10:47

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,380
  • I think you'll find those error messages were present anyway. They were on mine in both cases. But that may be a question you need to raise with the developer. – gsxruk Jul 29 '18 at 12:07
  • (I'm sorry I deleted my comment after you answered. Here's my comment again.) Wow, that worked! The only two changes - and they are minor annoyances - are (1) that I can only launch with "notepadqq" rather than "nqq". (2) I'm getting error messages when I launch notepadqq. See https://pasteboard.co/HwH98Tw.png for the error messages. – RalphShnelvar Jul 29 '18 at 12:12
  • (a) @gsxruk, Thank you so much!!! (b) Do you know how to contact the developer? – RalphShnelvar Jul 29 '18 at 12:13
  • A good place to start would be the project website here. You should be able to raise an issue. – gsxruk Jul 29 '18 at 12:18
  • Ok, another problem. "sudo notepadqq --allow-root" no longer works. Sigh. – RalphShnelvar Jul 29 '18 at 12:18
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,380
  • Utterly, absolutely amazing! @gsxruk! It works!!! Thank you, thank you, thank you! – RalphShnelvar Jul 29 '18 at 15:40
  • No problem and pleased it worked for you. And if that's the case, please mark it as the answer. – gsxruk Jul 29 '18 at 15:45
  • I wish I could upvote your answer ... but I have fewer than 15 reputation points. – RalphShnelvar Jul 29 '18 at 15:48
  • While I have your attention, @gsxruk, I am just now reading https://askubuntu.com/questions/270006/why-should-users-never-use-normal-sudo-to-start-graphical-applications . Do you recommend I use gksu/gksudo rather than sudo to launch nqq when I need root privileges? – RalphShnelvar Jul 29 '18 at 16:00
  • I've always been a little unsure on that too and I thought it was deprecated/obsolete these days. I don't really use it, I always use vi when I'm amending root files. This article may be of interest and it looks up to date. – gsxruk Jul 29 '18 at 16:17
  • One other point on notepadqq. It would be worth asking the developer to add an option to disable native dialogs as a feature enhancement. Otherwise, you'll have to do this every time you install Ubuntu fresh. He doesn't have to, but it can't hurt to ask! – gsxruk Jul 29 '18 at 16:19
  • In terms of sudo nqq --allow-root ... I think it is safe. notepadqq seems to even keep different saved state depending on whether --allow-root is used or not. – RalphShnelvar Jul 29 '18 at 17:05
  • In terms of a feature request, I did as you suggested, @gsxruk. See https://github.com/notepadqq/notepadqq/issues/737 . And, again, thank you. – RalphShnelvar Jul 29 '18 at 17:19