]> Shamusworld >> Repos - architektonas/commitdiff
Fixed problem with MDI activation.
authorShamus Hammons <jlhamm@acm.org>
Thu, 17 Feb 2011 20:06:09 +0000 (20:06 +0000)
committerShamus Hammons <jlhamm@acm.org>
Thu, 17 Feb 2011 20:06:09 +0000 (20:06 +0000)
src/mainapp/applicationwindow.cpp
src/mainapp/mdiwindow.cpp
src/mainapp/mdiwindow.h

index 45c96aaa9ea126730e9b774d3828152b31f98951..6a3fa71df35331dcba076281b1c42de222473744 100644 (file)
 #include "mdiwindow.h"
 
 ApplicationWindow * ApplicationWindow::appWindow = NULL;
-
-#ifndef QC_APP_ICON
-# define QC_APP_ICON "qcad.png"
-#endif
-#ifndef QC_APP_ICON16
-# define QC_APP_ICON16 "qcad16.png"
-#endif
-
 extern QSplashScreen * splash;
 
 /**
@@ -89,7 +81,7 @@ ApplicationWindow::ApplicationWindow():
 
 #warning "!!! Need to create new application icon !!!"
        DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon");
-       setWindowIcon(QIcon(":/res/" QC_APP_ICON));
+       setWindowIcon(QIcon(":/res/qcad.png"));
        CreateQtActions(this);
 
        DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler");
@@ -1053,7 +1045,7 @@ void ApplicationWindow::initActions()
 
        // Help menu:
        //
-       helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this);
+       helpAboutApp = new QAction(QIcon("qcad16.png"), tr("&About Architektonas"), this);
 //    helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this);
        helpAboutApp->setStatusTip(tr("About the application"));
        //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
@@ -1476,6 +1468,7 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * sw)
 //which means the subwindow is NOT being activated!!!
 //     MDIWindow * m = getMDIWindow();
        MDIWindow * m = (MDIWindow *)sw;
+//     MDIWindow * m = (MDIWindow *)(sw->widget());
        DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
        DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X",
                (m ? m->getDocument() : 0));
@@ -1539,6 +1532,8 @@ printf("slotWindowActivated(QMdiSubWindow *): currentWindow=%08X...\n", (uint)wo
        // Disable/Enable menu and toolbar items
 //This is odd... why do this when you can just call the function directly? It's
 //IN this class after all...
+//In this case it makes a little sense, as the signal is connected to all the actions'
+//setEnabled() function calls.
        emit(windowsChanged(m != NULL && m->getDocument() != NULL));
 
        DEBUG->print("ApplicationWindow::slotWindowActivated end");
@@ -1830,6 +1825,11 @@ printf("MDIWindow=%08X, QMdiSubWindow=%08X\n", (uint)w, (uint)sw);
 //w->setFocus();
 //w->activateWindow();
 //w->raise();
+//will wok?
+/*printf("FileNew: Setting active subwindow... (w=%08X)\n", (uint)w);
+workspace->setActiveSubWindow(w);
+printf("FileNew: Workspace active window = %08X\n", (uint)(workspace->activeSubWindow()));
+//*/
 
 //not anymore... #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
 //Hm, this should be called when the window is actually activated by the QMdiArea...
@@ -2252,6 +2252,7 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for
                ret = true;
        }
 #else
+//#warning "ApplicationWindow::slotFileExport(): Need to port to Qt4... !!! FIX !!!"
 //     QImage image = buffer->toImage();
 //     QImageWriter writer;
 //     writer.setFileName(name);
index b3d0ac4cb50e1b9ca862a6b084551eb7b58e406e..a592c4bd6bc1f1d9ab335646b3e57c841174f2c2 100644 (file)
@@ -33,15 +33,24 @@ int MDIWindow::idCounter = 0;
  * @param parent Parent widget. Usually a workspace (QMdiArea).
  */
 MDIWindow::MDIWindow(Document * doc, QWidget * parent, const char * name/*= NULL*/,
-       Qt::WindowFlags wflags/*= Qt::WDestructiveClose*/):
-       QMdiSubWindow(parent, Qt::SubWindow), owner(false)//, forceClosing(false)
+       Qt::WindowFlags wflags/*= Qt::SubWindow*/):
+       QMdiSubWindow(parent, Qt::SubWindow), 
+owner(false)
 #warning "!!! wflags is ignored !!!"
 {
 // This warning not longer occurs...!
 //This warning is most likely coming from the QMdiSubWindow() constructor above...
 //#warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
        initDoc(doc);
-       initView();
+
+       graphicView = new QG_GraphicView(document, this);
+//Let's see if the trouble is in the graphicView...
+//And it is... So... How to fix this???
+       setWidget(graphicView);
+//THIS was the problem... Somehow, setting focus on the this widget was screwing
+//*everything* about the MDI system up!
+//     graphicView->setFocus();
+
        id = idCounter++;
        parentWindow = NULL;
 
@@ -208,20 +217,6 @@ void MDIWindow::initDoc(Document * doc)
        }
 }
 
-/**
- * Initialize the view.
- */
-void MDIWindow::initView()
-{
-       // This is only called once: In the MDIWindow constructor.
-       DEBUG->print("MDIWindow::initView()");
-
-//     graphicView = new QC_GraphicView(document, this);
-       graphicView = new QG_GraphicView(document, this);
-       setWidget(graphicView);
-       graphicView->setFocus();
-}
-
 /**
  * Called when the current pen (color, style, width) has changed.
  * Sets the active pen for the document in this MDI window.
index 31c03e4aa606f800d2a75022bfb558012fb2aa4d..e532cc4474642ca088cb49dfc9679623484eaa06 100644 (file)
@@ -1,10 +1,11 @@
-#ifndef QC_MDIWINDOW_H
-#define QC_MDIWINDOW_H
+#ifndef __MDIWINDOW_H__
+#define __MDIWINDOW_H__
 
 #include <QtGui>
 #include "document.h"
 #include "layerwidget.h"
 #include "pentoolbar.h"
+//#include "qg_graphicview.h"
 
 class EventHandler;
 class QG_GraphicView;
@@ -15,6 +16,7 @@ class QG_GraphicView;
  * @author Andrew Mustun
  */
 class MDIWindow: public QMdiSubWindow
+//class MDIWindow: public QG_GraphicView
 {
        Q_OBJECT
 
@@ -24,7 +26,6 @@ class MDIWindow: public QMdiSubWindow
                ~MDIWindow();
 
                void initDoc(Document * doc = NULL);
-               void initView();
 
        public slots:
                void slotPenChanged(Pen p);
@@ -32,7 +33,6 @@ class MDIWindow: public QMdiSubWindow
                bool slotFileOpen(const QString & fileName, RS2::FormatType type);
                bool slotFileSave(bool & cancelled);
                bool slotFileSaveAs(bool & cancelled);
-//WAS:         bool slotFileClose(bool force);
                bool slotFileClose(void);
                void slotFilePrint(void);
 
@@ -46,9 +46,7 @@ class MDIWindow: public QMdiSubWindow
                MDIWindow * getPrintPreview();
                void setParentWindow(MDIWindow * p);
                int getId();
-//WAS:         bool closeMDI(bool force, bool ask = true);
                bool CloseMDI(void);
-//             void setForceClosing(bool on);
 
                friend std::ostream & operator<<(std::ostream & os, MDIWindow & w);
 
@@ -70,19 +68,13 @@ class MDIWindow: public QMdiSubWindow
                Document * document;
                /** Does the window own the document? */
                bool owner;
-               /**
-               * List of known child windows that show blocks of the same drawing.
-               */
+               /** List of known child windows that show blocks of the same drawing. */
                QList<MDIWindow *> childWindows;
                /**
                * Pointer to parent window which needs to know if this window
                * is closed or NULL.
                */
                MDIWindow * parentWindow;
-               /**
-               * If flag is set, the user will not be asked about closing this file.
-               */
-//             bool forceClosing;
 };
 
-#endif
+#endif // __MDIWINDOW_H__