Changeset 1312


Ignore:
Timestamp:
Jun 10, 2010, 6:02:07 PM (14 years ago)
Author:
garnier
Message:

fix QLabel bug and a crash when del and create tabs

Location:
trunk/source/interfaces
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/interfaces/History

    r1309 r1312  
    1 $Id: History,v 1.143 2010/06/04 15:12:09 lgarnier Exp $
     1$Id: History,v 1.147 2010/06/10 16:01:38 lgarnier Exp $
    22-------------------------------------------------------------------
    33
     
    1818     ----------------------------------------------------------
    1919
    20 4th June  L. Garnier
     2010th June L. Garnier
     21- G4UIQt : Fix crash when del all viewer tabs and create a new one.
     22           Fix widget QLabel strange effect on OSX 10.5
     23
     2410th June L. Garnier
     25- G4UIQt : Improvments on OpenGL tab at initialisation (tab size was
     26  too small). Remove some flicker effect at initialisation. Remove a
     27  compilation warning. Improvment on Cout Filter for Qt3
     28
     298, June, 2010 K.Murakami (interfaces-V09-03-08)
     30- G4VBasicShell : wrong version is in the cvs head.
     31                  back to previous version (1.14) which includes
     32                  a correct bug fix.
     33
     344th June  L. Garnier (interfaces-V09-03-07)
    2135- G4UIQt : Fix recursive repaint on windows and linux
     36  Also fixed compilation problem for Qt3.
    2237- G4VBasicShell : Command completion improvments (was solve in
    2338  v1.14 of G4VBasicShell but don't know why I go one step back)
  • trunk/source/interfaces/basic/include/G4UIQt.hh

    r1305 r1312  
    2525//
    2626//
    27 // $Id: G4UIQt.hh,v 1.22 2010/06/02 15:13:51 lgarnier Exp $
     27// $Id: G4UIQt.hh,v 1.23 2010/06/10 15:37:13 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    195195  QSplitter * fMyVSplitter;
    196196  QSplitter * fHelpVSplitter;
     197  int fLastQTabSizeX;
     198  int fLastQTabSizeY;
    197199
    198200private slots :
  • trunk/source/interfaces/basic/src/G4UIQt.cc

    r1309 r1312  
    2525//
    2626//
    27 // $Id: G4UIQt.cc,v 1.42 2010/06/04 15:12:09 lgarnier Exp $
     27// $Id: G4UIQt.cc,v 1.45 2010/06/10 16:01:38 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    171171  // Set layouts
    172172
    173   // Add a empty tabwidget
    174   fTabWidget = new G4QTabWidget(fMyVSplitter);
    175 #if QT_VERSION >= 0x040500
    176   fTabWidget->setTabsClosable (true);
    177 #endif
    178 
    179 #if QT_VERSION >= 0x040200
    180   fTabWidget->setUsesScrollButtons (true);
    181 #endif
    182 
    183173  QWidget* commandLineWidget = new QWidget(mainWidget);
    184174#if QT_VERSION < 0x040000
     
    212202  layoutCommandLine->addWidget(fCommandLabel);
    213203  layoutCommandLine->addWidget(fCommandArea);
     204  QVBoxLayout *mainLayout;
    214205#if QT_VERSION >= 0x040000
    215   QVBoxLayout *mainLayout = new QVBoxLayout();
    216 #else
    217   QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
     206  mainLayout = new QVBoxLayout();
     207#else
     208  mainLayout = new QVBoxLayout(mainWidget);
    218209#endif
    219210
     
    240231
    241232  fToolBox->setSizePolicy (QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
    242   fTabWidget->setSizePolicy (QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
    243 
    244   QSizePolicy policy = fTabWidget->sizePolicy();
    245 #if QT_VERSION < 0x040000
    246   policy.setHorStretch(1);
    247   policy.setVerStretch(1);
    248 #else
    249   policy.setHorizontalStretch(1);
    250   policy.setVerticalStretch(1);
    251 #endif
    252   fTabWidget->setSizePolicy(policy);
    253233
    254234#if QT_VERSION < 0x040000
     
    261241#if QT_VERSION >= 0x040000
    262242 #if QT_VERSION >= 0x040200
    263   fTabWidget->setVisible(false);
    264243  fEmptyViewerTabLabel->setVisible(false);
    265244 #else
    266   fTabWidget->hide();
    267245  fEmptyViewerTabLabel->hide();
    268246 #endif
    269247#else
    270   fTabWidget->hide();
    271248  fEmptyViewerTabLabel->hide();
    272249#endif
    273250
    274251
    275   //  fMyVSplitter->addWidget(fTabWidget);
    276 
    277   // unset parent fot TabWidget
    278 #if QT_VERSION < 0x040000
    279   fTabWidget->reparent(0,0,QPoint(0,0)); 
    280 #else
     252#if QT_VERSION >= 0x040000
    281253  fMyVSplitter->addWidget(fToolBox);
    282254  fMyVSplitter->addWidget(fEmptyViewerTabLabel);
    283   fTabWidget->setParent(0);
    284255#endif
    285256
     
    324295  // Connect signal
    325296  connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
    326 #if QT_VERSION >= 0x040500
    327   connect(fTabWidget,   SIGNAL(tabCloseRequested(int)), this, SLOT(TabCloseCallback(int)));
    328 #endif
    329   connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
    330297  connect(fToolBox, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int)));
    331298
     
    342309#endif
    343310
    344   // Set visible
    345 #if QT_VERSION >= 0x040000
    346  #if QT_VERSION >= 0x040200
    347   fMainWindow->setVisible(true);
    348  #else
    349   fMainWindow->show();
    350  #endif
    351 #else
    352   fMainWindow->show();
    353 #endif
     311  // Set not visible until session start
     312  fMainWindow->setVisible(false);
    354313
    355314#ifdef G4DEBUG_INTERFACES_BASIC
     
    542501  printf("G4UIQt::AddTabWidget %d %d\n",sizeX, sizeY);
    543502#endif
     503
     504  if (fTabWidget == NULL) {
     505#ifdef G4DEBUG_INTERFACES_BASIC
     506    printf("G4UIQt::AddTabWidget +++++\n");
     507#endif
     508    fTabWidget = new G4QTabWidget(fMyVSplitter);
     509#if QT_VERSION >= 0x040500
     510    fTabWidget->setTabsClosable (true);
     511#endif
     512   
     513#if QT_VERSION >= 0x040200
     514    fTabWidget->setUsesScrollButtons (true);
     515#endif
     516   
     517    fTabWidget->setSizePolicy (QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
     518   
     519    QSizePolicy policy = fTabWidget->sizePolicy();
     520#if QT_VERSION < 0x040000
     521    policy.setHorStretch(1);
     522    policy.setVerStretch(1);
     523#else
     524    policy.setHorizontalStretch(1);
     525    policy.setVerticalStretch(1);
     526#endif
     527    fTabWidget->setSizePolicy(policy);
     528   
     529#if QT_VERSION >= 0x040500
     530    connect(fTabWidget,   SIGNAL(tabCloseRequested(int)), this, SLOT(TabCloseCallback(int)));
     531#endif
     532    connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
     533  }
     534
     535  fLastQTabSizeX = sizeX;
     536  fLastQTabSizeY = sizeY;
     537
    544538  if (!aWidget) {
    545539    return false;
     
    556550#if QT_VERSION < 0x040000
    557551    fEmptyViewerTabLabel->reparent(0,0,QPoint(0,0)); 
    558 #else
    559     fEmptyViewerTabLabel->setParent(0);
     552    fEmptyViewerTabLabel->hide();
     553    delete fEmptyViewerTabLabel;
     554    fEmptyViewerTabLabel = NULL;
     555
     556#else
     557    fEmptyViewerTabLabel->hide();
     558    fEmptyViewerTabLabel->setParent(NULL);
     559    delete fEmptyViewerTabLabel;
     560    fEmptyViewerTabLabel = NULL;
     561
    560562    fMyVSplitter->addWidget(fTabWidget);
    561563#endif
     
    575577#endif
    576578 
    577   fMainWindow->resize(fMainWindow->width()+sizeX-fTabWidget->width(),fMainWindow->height()+sizeY-fTabWidget->height());
     579  if (fMainWindow->isVisible()) {
     580
     581    // get the size of the tabbar
     582    int tabBarX = 0;
     583    int tabBarY = 0;
     584    if (fTabWidget->count() >0) {
     585#if QT_VERSION < 0x040000
     586      tabBarX = fTabWidget->width()-fTabWidget->page(0)->width();
     587      tabBarY = fTabWidget->height()-fTabWidget->page(0)->height();
     588#else
     589      tabBarX = fTabWidget->width()-fTabWidget->widget(0)->width();
     590      tabBarY = fTabWidget->height()-fTabWidget->widget(0)->height();
     591#endif
     592    }
     593
     594    fMainWindow->resize(tabBarX+fMainWindow->width()+sizeX-fTabWidget->width(),tabBarY+fMainWindow->height()+sizeY-fTabWidget->height());
     595  }
    578596
    579597  // Problems with resize. The widgets are not realy drawn at this step,
     
    596614 #if QT_VERSION >= 0x040200
    597615   fTabWidget->setLastTabCreated(fTabWidget->currentIndex());
    598    fMainWindow->setVisible(true);
    599616 #else
    600617   fTabWidget->setLastTabCreated(fTabWidget->currentIndex());
    601    fMainWindow->show();
    602618 #endif
    603619#else
    604620  fTabWidget->setLastTabCreated(fTabWidget->currentPageIndex());
    605   fMainWindow->show();
    606 #endif
    607  
    608 #if QT_VERSION >= 0x040000
    609  #if QT_VERSION >= 0x040200
    610    fTabWidget->setVisible(true);
    611  #else
    612    fTabWidget->show();
    613  #endif
    614 #else
    615    fTabWidget->show();
    616 #endif
    617 
     621#endif
     622 
    618623  return true;
    619624}
     
    642647  fTabWidget->setTabSelected(false);
    643648
    644 #if QT_VERSION >= 0x040000
    645  #if QT_VERSION >= 0x040200
    646    fTabWidget->setVisible(true);
    647  #else
    648    fTabWidget->show();
    649  #endif
    650 #else
    651    fTabWidget->show();
    652 #endif
     649  fTabWidget->setVisible(true);
    653650
    654651  // This will send a paintEvent to OGL Viewers
     
    697694  exitSession = false;
    698695
    699 #if QT_VERSION >= 0x040000
    700  #if QT_VERSION >= 0x040200
    701   fTabWidget->setVisible(true);
    702   fEmptyViewerTabLabel->setVisible(true);
    703  #else
    704   fTabWidget->show();
    705   fEmptyViewerTabLabel->show();
    706  #endif
    707 #else
    708   fTabWidget->show();
    709   fEmptyViewerTabLabel->show();
    710 #endif
    711 
    712 
    713 #if QT_VERSION >= 0x040000
    714  #if QT_VERSION >= 0x040200
     696  if (fEmptyViewerTabLabel != NULL) {
     697    if (fTabWidget->isVisible()) {
     698      fEmptyViewerTabLabel->setVisible(false);
     699    } else {
     700      fEmptyViewerTabLabel->setVisible(true);
     701    }
     702  }
     703
    715704  fMainWindow->setVisible(true);
    716  #else
    717   fMainWindow->show();
    718  #endif
    719 #else
    720   fMainWindow->show();
    721 #endif
     705  // get the size of the tabbar
     706  int tabBarX;
     707  int tabBarY;
     708#if QT_VERSION < 0x040000
     709  tabBarX = fTabWidget->width()-fTabWidget->page(0)->width();
     710  tabBarY = fTabWidget->height()-fTabWidget->page(0)->height();
     711#else
     712  tabBarX = fTabWidget->width()-fTabWidget->widget(0)->width();
     713  tabBarY = fTabWidget->height()-fTabWidget->widget(0)->height();
     714#endif
     715
     716  fMainWindow->resize(tabBarX+fMainWindow->width()+fLastQTabSizeX-fTabWidget->width(),tabBarY+fMainWindow->height()+fLastQTabSizeY-fTabWidget->height());
    722717
    723718#if QT_VERSION < 0x040000
     
    17311726#else
    17321727  QStringList result = fG4cout.filter(text);
    1733 #endif
    1734 
    17351728  fCoutTBTextArea->setPlainText(result.join("\n"));
     1729#endif
     1730
    17361731  fCoutTBTextArea->repaint();
    17371732#if QT_VERSION < 0x040000
     
    20922087
    20932088  if (fTabWidget->count() == 0) {
     2089    if (fEmptyViewerTabLabel == NULL) {
     2090#if QT_VERSION < 0x040000
     2091      fEmptyViewerTabLabel = new QLabel(fToolBox,"         If you want to have a Viewer, please use /vis/open commands. ");
     2092#else
     2093      fEmptyViewerTabLabel = new QLabel("         If you want to have a Viewer, please use /vis/open commands. ");
     2094#endif
     2095    }
     2096
    20942097    fMyVSplitter->addWidget(fEmptyViewerTabLabel);
     2098    fMyVSplitter->show();
     2099    fEmptyViewerTabLabel->show();
    20952100    fTabWidget->setParent(0);
     2101    fTabWidget->setVisible(false);
     2102    delete fTabWidget;
     2103    fTabWidget = NULL;
    20962104  }
    20972105#endif
Note: See TracChangeset for help on using the changeset viewer.