From: Shamus Hammons Date: Thu, 17 Feb 2011 20:06:09 +0000 (+0000) Subject: Fixed problem with MDI activation. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43c13b052d069ba435277d93867380d00c04931f;p=architektonas Fixed problem with MDI activation. --- diff --git a/src/mainapp/applicationwindow.cpp b/src/mainapp/applicationwindow.cpp index 45c96aa..6a3fa71 100644 --- a/src/mainapp/applicationwindow.cpp +++ b/src/mainapp/applicationwindow.cpp @@ -66,14 +66,6 @@ #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); diff --git a/src/mainapp/mdiwindow.cpp b/src/mainapp/mdiwindow.cpp index b3d0ac4..a592c4b 100644 --- a/src/mainapp/mdiwindow.cpp +++ b/src/mainapp/mdiwindow.cpp @@ -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. diff --git a/src/mainapp/mdiwindow.h b/src/mainapp/mdiwindow.h index 31c03e4..e532cc4 100644 --- a/src/mainapp/mdiwindow.h +++ b/src/mainapp/mdiwindow.h @@ -1,10 +1,11 @@ -#ifndef QC_MDIWINDOW_H -#define QC_MDIWINDOW_H +#ifndef __MDIWINDOW_H__ +#define __MDIWINDOW_H__ #include #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 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__