Changeset 1312 for trunk/source/interfaces/basic/src
- Timestamp:
- Jun 10, 2010, 6:02:07 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/interfaces/basic/src/G4UIQt.cc
r1309 r1312 25 25 // 26 26 // 27 // $Id: G4UIQt.cc,v 1.4 2 2010/06/04 15:12:09lgarnier Exp $27 // $Id: G4UIQt.cc,v 1.45 2010/06/10 16:01:38 lgarnier Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 171 171 // Set layouts 172 172 173 // Add a empty tabwidget174 fTabWidget = new G4QTabWidget(fMyVSplitter);175 #if QT_VERSION >= 0x040500176 fTabWidget->setTabsClosable (true);177 #endif178 179 #if QT_VERSION >= 0x040200180 fTabWidget->setUsesScrollButtons (true);181 #endif182 183 173 QWidget* commandLineWidget = new QWidget(mainWidget); 184 174 #if QT_VERSION < 0x040000 … … 212 202 layoutCommandLine->addWidget(fCommandLabel); 213 203 layoutCommandLine->addWidget(fCommandArea); 204 QVBoxLayout *mainLayout; 214 205 #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); 218 209 #endif 219 210 … … 240 231 241 232 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 < 0x040000246 policy.setHorStretch(1);247 policy.setVerStretch(1);248 #else249 policy.setHorizontalStretch(1);250 policy.setVerticalStretch(1);251 #endif252 fTabWidget->setSizePolicy(policy);253 233 254 234 #if QT_VERSION < 0x040000 … … 261 241 #if QT_VERSION >= 0x040000 262 242 #if QT_VERSION >= 0x040200 263 fTabWidget->setVisible(false);264 243 fEmptyViewerTabLabel->setVisible(false); 265 244 #else 266 fTabWidget->hide();267 245 fEmptyViewerTabLabel->hide(); 268 246 #endif 269 247 #else 270 fTabWidget->hide();271 248 fEmptyViewerTabLabel->hide(); 272 249 #endif 273 250 274 251 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 281 253 fMyVSplitter->addWidget(fToolBox); 282 254 fMyVSplitter->addWidget(fEmptyViewerTabLabel); 283 fTabWidget->setParent(0);284 255 #endif 285 256 … … 324 295 // Connect signal 325 296 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback())); 326 #if QT_VERSION >= 0x040500327 connect(fTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(TabCloseCallback(int)));328 #endif329 connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));330 297 connect(fToolBox, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int))); 331 298 … … 342 309 #endif 343 310 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); 354 313 355 314 #ifdef G4DEBUG_INTERFACES_BASIC … … 542 501 printf("G4UIQt::AddTabWidget %d %d\n",sizeX, sizeY); 543 502 #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 544 538 if (!aWidget) { 545 539 return false; … … 556 550 #if QT_VERSION < 0x040000 557 551 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 560 562 fMyVSplitter->addWidget(fTabWidget); 561 563 #endif … … 575 577 #endif 576 578 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 } 578 596 579 597 // Problems with resize. The widgets are not realy drawn at this step, … … 596 614 #if QT_VERSION >= 0x040200 597 615 fTabWidget->setLastTabCreated(fTabWidget->currentIndex()); 598 fMainWindow->setVisible(true);599 616 #else 600 617 fTabWidget->setLastTabCreated(fTabWidget->currentIndex()); 601 fMainWindow->show();602 618 #endif 603 619 #else 604 620 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 618 623 return true; 619 624 } … … 642 647 fTabWidget->setTabSelected(false); 643 648 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); 653 650 654 651 // This will send a paintEvent to OGL Viewers … … 697 694 exitSession = false; 698 695 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 715 704 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()); 722 717 723 718 #if QT_VERSION < 0x040000 … … 1731 1726 #else 1732 1727 QStringList result = fG4cout.filter(text); 1733 #endif1734 1735 1728 fCoutTBTextArea->setPlainText(result.join("\n")); 1729 #endif 1730 1736 1731 fCoutTBTextArea->repaint(); 1737 1732 #if QT_VERSION < 0x040000 … … 2092 2087 2093 2088 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 2094 2097 fMyVSplitter->addWidget(fEmptyViewerTabLabel); 2098 fMyVSplitter->show(); 2099 fEmptyViewerTabLabel->show(); 2095 2100 fTabWidget->setParent(0); 2101 fTabWidget->setVisible(false); 2102 delete fTabWidget; 2103 fTabWidget = NULL; 2096 2104 } 2097 2105 #endif
Note: See TracChangeset
for help on using the changeset viewer.