7fd59977 |
1 | #include "ApplicationTut.h" |
2 | #include "DocumentTut.h" |
3 | |
1fa16152 |
4 | #include <OSD_Environment.hxx> |
5 | |
55a40de8 |
6 | #include <Standard_WarningsDisable.hxx> |
7fd59977 |
7 | #include <QFileDialog> |
8 | #include <QStatusBar> |
861a7b03 |
9 | #include <QMdiSubWindow> |
55a40de8 |
10 | #include <Standard_WarningsRestore.hxx> |
7fd59977 |
11 | |
12 | ApplicationTut::ApplicationTut() |
13 | : ApplicationCommonWindow( ) |
14 | { |
15 | createMakeBottleOperation(); |
16 | } |
17 | |
18 | ApplicationTut::~ApplicationTut() |
19 | { |
20 | } |
21 | |
22 | void ApplicationTut::createMakeBottleOperation(){ |
23 | QPixmap MakeBottleIcon; |
24 | QString dir = getTutResourceDir() + QString( "/" ); |
25 | MakeBottleIcon = QPixmap( dir+QObject::tr( "ICON_MAKE_BOTTLE" ) ); |
26 | |
27 | QAction * MakeBottleAction = new QAction( MakeBottleIcon, QObject::tr("TBR_MAKEBOT"), this ); |
28 | MakeBottleAction->setToolTip( QObject::tr( "TBR_MAKEBOT" ) ); |
29 | MakeBottleAction->setStatusTip( QObject::tr("TBR_MAKEBOT") ); |
30 | MakeBottleAction->setShortcut( QObject::tr( "CTRL+M" ) ); |
3cb77da4 |
31 | connect( MakeBottleAction, SIGNAL( triggered() ) , this, SLOT( onMakeBottleAction() ) ); |
7fd59977 |
32 | |
33 | myMakeBottleBar = addToolBar( tr( "Make Bottle" ) ); |
34 | insertToolBar( getCasCadeBar(), myMakeBottleBar ); |
35 | myMakeBottleBar->addAction( MakeBottleAction ); |
36 | myMakeBottleBar->hide(); |
37 | } |
38 | |
39 | void ApplicationTut::updateFileActions() |
40 | { |
861a7b03 |
41 | if ( getWorkspace()->subWindowList().isEmpty() ) |
7fd59977 |
42 | { |
43 | if ( !isDocument() ) |
44 | { |
45 | myMakeBottleBar->show(); |
46 | } |
47 | else |
48 | { |
49 | myMakeBottleBar->hide(); |
50 | } |
51 | } |
52 | ApplicationCommonWindow::updateFileActions(); |
53 | } |
54 | |
55 | void ApplicationTut::onMakeBottleAction() |
56 | { |
861a7b03 |
57 | QMdiArea* ws = ApplicationCommonWindow::getWorkspace(); |
58 | DocumentTut* doc = (DocumentTut*)( qobject_cast<MDIWindow*>( ws->activeSubWindow()->widget() )->getDocument() ); |
7fd59977 |
59 | statusBar()->showMessage( QObject::tr("INF_MAKE_BOTTLE"), 5000 ); |
60 | doc->onMakeBottle(); |
61 | statusBar()->showMessage(QObject::tr("INF_DONE")); |
62 | } |
63 | |
64 | QString ApplicationTut::getTutResourceDir() |
65 | { |
1fa16152 |
66 | static QString resDir (OSD_Environment ("CSF_TutorialResourcesDefaults").Value().ToCString()); |
67 | if (resDir.isEmpty()) |
68 | resDir = QString (OSD_Environment ("CSF_OCCTResourcePath").Value().ToCString()) + "/samples"; |
861a7b03 |
69 | return resDir; |
7fd59977 |
70 | } |