Bo Peng wrote: >> I've also implemented the patch for the qt3 frontend. >> Now Qt3 and Qt4 are an par on Linux and Windows. >> Diff against current svn. > > Thanks. I have not read what Abdel says about the patch. Here is mine: > >> - if (posx != -1 && posy != -1) >> - view.move(QPoint(posx, posy)); >> + view.init(); >> >> + if (width != -1 && height != -1 && posx != -1 && posy != -1) { >> + view.initNormalGeometry(QRect(posx, posy, width, >> height)); >> + view.resize(width, height); >> + view.move(posx, posy); >> + if (maximize) >> + { >> + view.show(); >> + view.setWindowState(Qt::WindowMaximized); >> + } >> + } >> + >> view.show(); >> - view.init(); > > The logic is that width and height should work without valid posx, and > poxy. (saveGeometry controls that).
I wondered if there is a case where the width is saved but not the position, couldn't the pos!=-1 be removed? > Also, why not move if(maximize) out of the scope? (view.show() called > twice). Something like: > view.show() > if max: > setWindowState. > + view.resize(width, height); + view.move(posx, posy); + view.show(); + if (maximize) + { + view.setWindowState(Qt::WindowMaximized); + } + } else + view.show(); + - view.init(); >> +void QtView::initNormalGeometry(const QRect & g) >> +{ >> + normalGeometry_ = g; >> + maxWidth=QApplication::desktop()->width()-20; >> +} >> >> +QRect QtView::qtViewGeometry() const >> +{ >> + QRect rec; >> + // setX/Y changes the size! >> + rec.setX(frameGeometry().x()); >> + rec.setY(frameGeometry().y()); >> + rec.setWidth(geometry().width()); >> + rec.setHeight(geometry().height()); >> + return rec; >> +} >> + >> +void QtView::resizeEvent(QResizeEvent *) >> +{ >> + if (width() > maxWidth) { >> + maxWidth = width(); >> + return; >> + } >> + if (frameGeometry().x() > 0) >> + normalGeometry_ = qtViewGeometry(); >> + >> + std::cout<<maxWidth-normalGeometry_.width()<<", resizeEvent >> :"<<normalGeometry_.x()<<"\n"; >> +} >> + >> +void QtView::moveEvent(QMoveEvent *) >> +{ >> + if (width() < maxWidth && frameGeometry().x() > 0) >> + normalGeometry_ = qtViewGeometry(); >> + std::cout<<maxWidth-normalGeometry_.width()<<", moveEvent >> :"<<normalGeometry_.x()<<"\n"; >> +} >> + >> void QtView::closeEvent(QCloseEvent *) >> { >> + QRect geometry; >> + std::cout<<"maxWidth:"<<maxWidth<<"\n"; >> + std::cout<<"normalGeometry_: "<<normalGeometry_.width()<<"\n"; >> + if (QWidget::geometry().width() < maxWidth) >> + geometry = qtViewGeometry(); >> + else >> + geometry = normalGeometry_; >> + >> + std::cout<<"closeEvent : "<<geometry.width()<<" >> "<<geometry.x() <<"\n\n"; >> + >> Session & session = LyX::ref().session(); >> session.saveSessionInfo("WindowIsMaximized", (isMaximized() ? >> "yes" : "no")); >> // save windows size and position >> - session.saveSessionInfo("WindowWidth", convert<string>(width())); >> - session.saveSessionInfo("WindowHeight", >> convert<string>(height())); >> + session.saveSessionInfo("WindowWidth", >> convert<string>(geometry.width())); >> + session.saveSessionInfo("WindowHeight", >> convert<string>(geometry.height())); >> if (lyxrc.geometry_xysaved) { >> - session.saveSessionInfo("WindowPosX", >> convert<string>(x())); >> - session.saveSessionInfo("WindowPosY", >> convert<string>(y())); >> + session.saveSessionInfo("WindowPosX", >> convert<string>(geometry.x())); >> + session.saveSessionInfo("WindowPosY", >> convert<string>(geometry.y())); >> } >> // trigger LFUN_LYX_QUIT instead of quit directly >> // since LFUN_LYX_QUIT may have more cleanup stuff >> @@ -179,6 +222,8 @@ >> { >> setCaption(qt_("LyX")); >> QMainWindow::show(); >> + if (width()<maxWidth) >> + normalGeometry_ = qtViewGeometry(); >> } >> > > If I remember correctly, you said that geometry can only be correctly > traced in events like resize so you have to handle them. This makes > the code really long for this simple task. Is not there a way/hack to > do that in the close event, such as a hack in triggering resize? wide > guess though. > Please read my answers to Abdel. >> + if (width != -1 && height != -1 && posx != -1 && posy != -1) { > > The same logic problem. > > I will test the patch later. > Thanks! > Cheers, > Bo > > Peter