ab0156d80733c8b8d03373c3ae5b36741472b6cd
[occt.git] / samples / qt / Tutorial / src / ApplicationTut.cxx
1 #include "ApplicationTut.h"
2 #include "DocumentTut.h"
3
4 #include <QFileDialog>
5 #include <QStatusBar>
6
7 ApplicationTut::ApplicationTut()
8     : ApplicationCommonWindow( )
9 {
10   createMakeBottleOperation();
11 }
12
13 ApplicationTut::~ApplicationTut()
14 {
15 }
16
17 void ApplicationTut::createMakeBottleOperation(){
18         QPixmap MakeBottleIcon;
19         QString dir = getTutResourceDir() + QString( "/" );
20   MakeBottleIcon = QPixmap( dir+QObject::tr( "ICON_MAKE_BOTTLE" ) );
21         
22   QAction * MakeBottleAction = new QAction( MakeBottleIcon, QObject::tr("TBR_MAKEBOT"), this );
23   MakeBottleAction->setToolTip( QObject::tr( "TBR_MAKEBOT" ) );
24   MakeBottleAction->setStatusTip( QObject::tr("TBR_MAKEBOT") );
25   MakeBottleAction->setShortcut( QObject::tr( "CTRL+M" ) );
26         connect( MakeBottleAction, SIGNAL( activated() ) , this, SLOT( onMakeBottleAction() ) );
27         
28         myMakeBottleBar = addToolBar( tr( "Make Bottle" ) );
29   insertToolBar( getCasCadeBar(), myMakeBottleBar );
30   myMakeBottleBar->addAction( MakeBottleAction );
31         myMakeBottleBar->hide();
32 }
33
34 void ApplicationTut::updateFileActions()
35 {
36   if ( getWorkspace()->windowList().isEmpty() )
37   {
38           if ( !isDocument() )
39                 {
40       myMakeBottleBar->show();
41     }
42     else
43     {
44       myMakeBottleBar->hide();
45     }
46   }
47   ApplicationCommonWindow::updateFileActions();
48 }
49
50 void ApplicationTut::onMakeBottleAction()
51 {
52         QWorkspace* ws = ApplicationCommonWindow::getWorkspace();
53   DocumentTut* doc = (DocumentTut*)((MDIWindow*)ws->activeWindow())->getDocument();
54         statusBar()->showMessage( QObject::tr("INF_MAKE_BOTTLE"), 5000 );
55         doc->onMakeBottle();
56         statusBar()->showMessage(QObject::tr("INF_DONE"));
57 }
58
59 QString ApplicationTut::getTutResourceDir()
60 {
61     static QString resDir( ::getenv( "CSF_TuturialResourcesDefaults" ) );
62     return resDir;
63 }
64