Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / qt / Tutorial / src / ApplicationTut.cxx
CommitLineData
7fd59977 1#include "ApplicationTut.h"
2#include "DocumentTut.h"
3
4#include <QFileDialog>
5#include <QStatusBar>
6
7ApplicationTut::ApplicationTut()
8 : ApplicationCommonWindow( )
9{
10 createMakeBottleOperation();
11}
12
13ApplicationTut::~ApplicationTut()
14{
15}
16
17void 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
34void 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
50void 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
59QString ApplicationTut::getTutResourceDir()
60{
61 static QString resDir( ::getenv( "CSF_TuturialResourcesDefaults" ) );
62 return resDir;
63}
64