Skip to content
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

Double title bar in macOS #2968

Closed
candlerb opened this issue Apr 18, 2020 · 10 comments
Closed

Double title bar in macOS #2968

candlerb opened this issue Apr 18, 2020 · 10 comments
Labels
Milestone

Comments

@candlerb
Copy link

Describe the bug
Very minor issue, but in macOS the title bar is doubled, losing a small bit of vertical screen estate, and looking a bit strange since the project title is displayed twice too.

GNS3 version and operating system

  • OS: macOS 10.14.6 (13" Retina Macbook Pro, 2015)
  • GNS3 version 2.2.7
  • Remote gns3-server under Linux

To Reproduce

  1. Start GNS3 GUI
  2. Open a project

Screenshots or videos
image

Additional context
The project shown above has a scene width of 1400px and scene height of 2000px.

@candlerb candlerb added the Bug label Apr 18, 2020
@grossmj grossmj added this to the 2.2.8 milestone Apr 26, 2020
@grossmj
Copy link
Member

grossmj commented Apr 28, 2020

Unfortunately, I couldn't reproduce the problem on macOS 10.15

@grossmj grossmj modified the milestones: 2.2.8, 2.2.9 Apr 28, 2020
@candlerb
Copy link
Author

I got a colleague who has 10.15 to test, and they don't see the double title bar either. Therefore this appears to affect only 10.14.

I don't know anything about qt. However I copied this tutorial, disabled the if __name__ == "main" test, and ran it like this:

$ /Applications/GNS3.app/Contents/MacOS/gns3shell
Python 3.6.5 (default, Jun 17 2018, 12:13:06)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sys
>>> sys.path.append(".")
>>> import qthello
QLayout: Attempting to add QLayout "" to HelloWindow "", which already has a layout

And I got this result:
image

So I do get the double title bar even with this simple test.

Regarding the warning about adding a layout to a window which already has a layout, by adding print statements I can see that it occurs when this is executed:

gridLayout = QGridLayout(self)

I also found this: https://forum.qt.io/topic/53814/qlayout-attempting-to-add-qlayout-to-mainwindow-which-already-has-a-layout-solved/4

  • but AFAICS the sample code already does what it suggests (setCentralWidget)

@candlerb
Copy link
Author

Actually, if I reduce the code to just

class HelloWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.setMinimumSize(QSize(640, 480))
        self.setWindowTitle("Hello world - pythonprogramminglanguage.com")

then I still get the doubled title. And reduced further to:

class HelloWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.setMinimumSize(QSize(640, 480))

then I get an double empty title:

image

@grossmj
Copy link
Member

grossmj commented Apr 28, 2020

Thanks for the research :) I will test on macOS 10.14 and see if I can find a workaround.

@candlerb
Copy link
Author

Hah, I found this and applied it:

--- qthello.py.orig	2020-04-28 12:58:00.000000000 +0100
+++ qthello.py	2020-04-28 13:15:15.000000000 +0100
@@ -7,6 +7,7 @@
 class HelloWindow(QMainWindow):
     def __init__(self):
         QMainWindow.__init__(self)
+        self.setUnifiedTitleAndToolBarOnMac(True)

         self.setMinimumSize(QSize(640, 480))
         self.setWindowTitle("Hello world - pythonprogramminglanguage.com")

The hello world program now renders correctly for me!

Emboldened by the success of setting random options, I then tried

--- ./MacOS/lib/python3.6/gns3/ui/main_window.ui.orig	2020-04-28 13:17:52.000000000 +0100
+++ ./MacOS/lib/python3.6/gns3/ui/main_window.ui	2020-04-28 13:25:19.000000000 +0100
@@ -2,6 +2,9 @@
 <ui version="4.0">
  <class>MainWindow</class>
  <widget class="QMainWindow" name="MainWindow">
+  <property name="unifiedTitleAndToolBarOnMac">
+    <bool>true</bool>
+  </property>
   <property name="windowModality">
    <enum>Qt::NonModal</enum>
   </property>

However, that didn't fix GNS3 :-(

@grossmj
Copy link
Member

grossmj commented Apr 28, 2020

I was suspecting this option could work :)

Changing the .ui file has no effect because it needs to be compiled to a Python file. Try to patch this file instead: https://github.com/GNS3/gns3-gui/blob/master/gns3/ui/main_window_ui.py

@candlerb
Copy link
Author

candlerb commented Apr 28, 2020

There's only the compiled one:

MacBook-Pro-4:GNS3.app $ pwd
/Applications/GNS3.app
MacBook-Pro-4:GNS3.app $ find . -name 'main_window_ui.py*'
./Contents/Resources/lib/python3.6/gns3/ui/main_window_ui.pyc

But I copied the .py file from git, made this patch:

--- /Applications/GNS3.app/Contents/Resources/lib/python3.6/gns3/ui/main_window_ui.py.orig	2020-04-28 13:40:58.000000000 +0100
+++ /Applications/GNS3.app/Contents/Resources/lib/python3.6/gns3/ui/main_window_ui.py	2020-04-28 13:41:35.000000000 +0100
@@ -11,6 +11,7 @@
 class Ui_MainWindow(object):
     def setupUi(self, MainWindow):
         MainWindow.setObjectName("MainWindow")
+        MainWindow.setUnifiedTitleAndToolBarOnMac(True)
         MainWindow.setWindowModality(QtCore.Qt.NonModal)
         MainWindow.resize(986, 716)
         MainWindow.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)

and it works, yay :-)

EDIT: Perhaps this should go upstream as a Qt issue. But as I don't have a Qt dev environment, and indeed don't even know what version of Qt this is, I would leave this to you.

@grossmj
Copy link
Member

grossmj commented Apr 28, 2020

Great! Thanks for helping to fix this 👍

@grossmj grossmj modified the milestones: 2.2.9, 2.2.8 Apr 29, 2020
@grossmj
Copy link
Member

grossmj commented Apr 29, 2020

I have added setUnifiedTitleAndToolBarOnMac(True). Let's wait for the next nightly build and test on various macOS versions.

@grossmj
Copy link
Member

grossmj commented Apr 30, 2020

Seems to be ok with the latest nightly build: https://sourceforge.net/projects/gns-3/files/Nightly%20Builds/2020-04-30/2.2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants