[Qt-creator] support for multiple top-level windows?

Joel Nordell joel.nordell at chloridepower.com
Tue Jun 9 20:34:45 CEST 2009


Hello all,

What you think about adding support for multiple top-level windows to  
Qt Creator?  I use two displays on my workstation, and having just a  
single monolithic window is too limiting to me.  (It doesn't allow me  
to make use of both monitors.)  I've briefly looked into what it would  
take to modify Qt Creator to support an "Open in Separate Window" menu  
action, and here is a VERY rough patch to illustrate the idea.  The  
patch needs a lot of work, and is nowhere near usable at this point,  
but hopefully it is enough to give an idea of what I'm thinking.

Does anyone else have any thoughts/opinions on this?

Regards,

Joel Nordell
Senior Software Engineer, Connectivity Solutions
CHLORIDE North America
27944 N. Bradley Rd.
Libertyville IL 60048-9700
Tel: 847-816-6000
Fax: 847-680-5124



========== PATCH IS BELOW ==========

Index: src/plugins/coreplugin/editormanager/editormanager.cpp
===================================================================
--- src/plugins/coreplugin/editormanager/editormanager.cpp	(original  
1.1.0)
+++ src/plugins/coreplugin/editormanager/editormanager.cpp	(working  
copy)
@@ -154,6 +154,7 @@
      QAction *m_goBackAction;
      QAction *m_goForwardAction;
      QAction *m_openInExternalEditorAction;
+    QAction *m_newWindowAction;
      QAction *m_splitAction;
      QAction *m_splitSideBySideAction;
      QAction *m_removeCurrentSplitAction;
@@ -334,6 +335,14 @@
      mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
      connect(m_d->m_goForwardAction, SIGNAL(triggered()), this,  
SLOT(goForwardInNavigationHistory()));

+    m_d->m_newWindowAction = new QAction(tr("Open in Separate  
Window"), this);
+    cmd = am->registerAction(m_d->m_newWindowAction,  
Constants::NEW_WINDOW, editManagerContext);
+#ifndef Q_OS_MAC
+    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+N")));
+#endif
+    mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
+    connect(m_d->m_newWindowAction, SIGNAL(triggered()), this,  
SLOT(openInNewWindow()));
+
      m_d->m_splitAction = new QAction(tr("Split"), this);
      cmd = am->registerAction(m_d->m_splitAction, Constants::SPLIT,  
editManagerContext);
  #ifndef Q_OS_MAC
@@ -1791,6 +1800,17 @@
      return duplicate;
  }

+void EditorManager::openInNewWindow()
+{
+    SplitterOrView *view = 0;
+    IEditor *duplicate = duplicateEditor(m_d->m_currentEditor);
+    if (duplicate) {
+        view = new SplitterOrView(duplicate);
+        view->setAttribute(Qt::WA_DeleteOnClose, true);
+        view->resize(m_d->m_currentEditor->widget()->width(), m_d- 
 >m_currentEditor->widget()->height());
+        view->show();
+    }
+}
+
  void EditorManager::split(Qt::Orientation orientation)
  {
      SplitterOrView *view = m_d->m_currentView;
Index: src/plugins/coreplugin/editormanager/editormanager.h
===================================================================
--- src/plugins/coreplugin/editormanager/editormanager.h	(original  
1.1.0)
+++ src/plugins/coreplugin/editormanager/editormanager.h	(working copy)
@@ -216,6 +216,7 @@
      void removeCurrentSplit();
      void removeAllSplits();
      void gotoOtherSplit();
+    void openInNewWindow();

  private:
      QList<IFile *> filesForEditors(QList<IEditor *> editors) const;
Index: src/plugins/coreplugin/coreconstants.h
===================================================================
--- src/plugins/coreplugin/coreconstants.h	(original 1.1.0)
+++ src/plugins/coreplugin/coreconstants.h	(working copy)
@@ -121,6 +121,7 @@
  const char * const MINIMIZE_WINDOW       = "QtCreator.MinimizeWindow";
  const char * const ZOOM_WINDOW           = "QtCreator.ZoomWindow";

+const char * const NEW_WINDOW            = "QtCreator.NewWindow";
  const char * const SPLIT                 = "QtCreator.Split";
  const char * const SPLIT_SIDE_BY_SIDE    =  
"QtCreator.SplitSideBySide";
  const char * const REMOVE_CURRENT_SPLIT  =  
"QtCreator.RemoveCurrentSplit";




More information about the Qt-creator-old mailing list