The MainWindow class provides a main window with menu bar, toolbars, dockable windows, a status bar and mainly a workspace for the MDI windows. More...
#include <MainWindow.h>
Public Slots | |
void | activateNextWindow () |
Activates the next window in the child window chain. | |
void | activatePreviousWindow () |
Activates the previous window in the child window chain. | |
void | activateWorkbench (const QString &) |
Just emits the workbenchActivated() signal to notify all receivers. | |
void | arrangeIcons () |
Arranges all child windows in a horizontal tile pattern. | |
void | cascade () |
Arranges all the child windows in a cascade pattern. | |
void | closeActiveWindow () |
Closes the child window that is currently active. | |
void | closeAllWindows () |
Closes all child windows. | |
void | setPaneText (int i, QString text) |
Sets text to the pane in the status bar. | |
void | showMessage (const QString &message, int timeout=0) |
void | switchToDockedMode () |
void | switchToTopLevelMode () |
void | tile () |
Arranges all child windows in a tile pattern. | |
void | whatsThis () |
Starts the what's this mode. | |
Signals | |
void | mainWindowClosed () |
void | timeEvent () |
void | windowStateChanged (MDIView *) |
void | workbenchActivated (const QString &) |
Public Member Functions | |
MDIView * | activeWindow () const |
Returns the active MDI window or 0 if there is none. | |
void | addWindow (MDIView *view) |
Adds an MDI window view to the main window's workspace and adds a new tab to the tab bar. | |
void | appendRecentFile (const QString &filename) |
MRU: Appends file to the list of recent files. | |
QMenu * | createPopupMenu () |
Returns true that the context menu contains the 'Customize. | |
bool | eventFilter (QObject *o, QEvent *e) |
Filters events if this object has been installed as an event filter for the watched object. | |
MainWindow (QWidget *parent=0, Qt::WFlags f=Qt::Window) | |
Constructs an empty main window. | |
void | removeWindow (MDIView *view) |
Removes an MDI window from the main window's workspace and its associated tab without deleting the widget. | |
void | setActiveWindow (MDIView *view) |
Sets the active window to view. | |
void | tabChanged (MDIView *view) |
Can be called after the caption of an MDIView has changed to update the tab's caption. | |
QList< QWidget * > | windows (QMdiArea::WindowOrder order=QMdiArea::CreationOrder) const |
Returns a list of all MDI windows in the worpspace. | |
~MainWindow () | |
Destroys the object and frees any allocated resources. | |
MIME data handling | |
bool | canInsertFromMimeData (const QMimeData *source) const |
Check if mime data contains object data. | |
QMimeData * | createMimeDataFromSelection () const |
Create mime data from selected objects. | |
void | insertFromMimeData (const QMimeData *source) |
Insert the objects into the active document. | |
void | loadUrls (App::Document *, const QList< QUrl > &) |
Load files from the given URLs into the given document. | |
Layout Methods | |
void | loadWindowSettings () |
Loads the main window settings. | |
void | saveWindowSettings () |
Saves the main window settings. | |
Protected Member Functions | |
void | changeEvent (QEvent *e) |
This method is called from the Qt framework automatically whenever a QTranslator object has been installed. | |
void | closeEvent (QCloseEvent *e) |
This method checks if the main window can be closed by checking all open documents and views. | |
void | customEvent (QEvent *e) |
void | dragEnterEvent (QDragEnterEvent *e) |
Checks if a mime source object can be interpreted. | |
void | dropEvent (QDropEvent *e) |
Try to interpret dropped elements. | |
bool | event (QEvent *e) |
void | hideEvent (QHideEvent *e) |
void | showEvent (QShowEvent *e) |
void | timerEvent (QTimerEvent *) |
Splasher and access methods | |
| |
void | showDocumentation (const char *Article=0) |
Shows the online documentation. | |
void | showTipOfTheDay (bool force=false) |
Shows the Tip-of-the-day dialog after startup. | |
QPixmap | splashImage () const |
void | startSplasher (void) |
Starts the splasher at startup. | |
void | stopSplasher (void) |
Stops the splasher after startup. | |
static MainWindow * | getInstance () |
Gets the one and only instance. |
The MainWindow class provides a main window with menu bar, toolbars, dockable windows, a status bar and mainly a workspace for the MDI windows.
Definition at line 69 of file MainWindow.h.
MainWindow::MainWindow | ( | QWidget * | parent = 0 , |
|
Qt::WFlags | f = Qt::Window | |||
) |
Constructs an empty main window.
For default parent is 0, as there usually is no toplevel window there.
Definition at line 235 of file MainWindow.cpp.
References Gui::MainWindowP::actionLabel, Gui::MainWindowP::actionTimer, Gui::MainWindowP::activeView, Gui::MainWindowP::activityTimer, Gui::MainWindowP::assistant, Gui::BitmapFactory(), draftlibs::fcgeo::connect(), getInstance(), Gui::Sequencer::getProgressBar(), Gui::Dialog::DlgOnlineHelpImp::getStartpage(), Gui::DockWindowManager::instance(), Gui::Sequencer::instance(), RobotExample::l, Gui::MainWindowP::mdiArea, Gui::DockWindowManager::registerDockWindow(), result, setActiveWindow(), Gui::MainWindowP::sizeLabel, Gui::MainWindowP::splashscreen, Gui::MainWindowP::status, tabChanged(), Gui::MainWindowP::visibleTimer, Gui::MainWindowP::whatsthis, and Gui::MainWindowP::windowMapper.
MainWindow::~MainWindow | ( | ) |
Destroys the object and frees any allocated resources.
Definition at line 426 of file MainWindow.cpp.
References Gui::MainWindowP::status.
void MainWindow::activateNextWindow | ( | ) | [slot] |
Activates the next window in the child window chain.
Definition at line 509 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea.
Referenced by StdCmdActivateNextWindow::activated().
void MainWindow::activatePreviousWindow | ( | ) | [slot] |
Activates the previous window in the child window chain.
Definition at line 518 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea.
Referenced by StdCmdActivatePrevWindow::activated().
void MainWindow::activateWorkbench | ( | const QString & | name | ) | [slot] |
Just emits the workbenchActivated() signal to notify all receivers.
Definition at line 527 of file MainWindow.cpp.
References workbenchActivated().
Referenced by Gui::Application::activateWorkbench().
MDIView * MainWindow::activeWindow | ( | void | ) | const |
Returns the active MDI window or 0 if there is none.
Definition at line 1065 of file MainWindow.cpp.
References Gui::MainWindowP::activeView.
Referenced by StdCmdSceneInspector::activated(), StdViewBoxZoom::activated(), StdViewZoomOut::activated(), StdViewZoomIn::activated(), StdCmdAxisCross::activated(), StdCmdToggleNavigation::activated(), StdViewScreenShot::activated(), StdViewDockUndockFullscreen::activated(), StdCmdDrawStyle::activated(), StdCmdToggleClipPlane::activated(), StdPerspectiveCamera::activated(), StdOrthographicCamera::activated(), CmdTestMDI3::activated(), CmdTestMDI2::activated(), CmdTestMDI1::activated(), StdCmdPrintPdf::activated(), StdCmdPrintPreview::activated(), StdCmdPrint::activated(), Gui::MDIView::changeEvent(), Gui::SoFCColorGradient::customize(), Gui::Dialog::DlgActivateWindowImp::DlgActivateWindowImp(), Gui::Document::getActiveView(), StdCmdTextureMapping::isActive(), StdCmdMeasureDistance::isActive(), StdCmdAxisCross::isActive(), StdCmdToggleNavigation::isActive(), StdViewDockUndockFullscreen::isActive(), StdCmdToggleClipPlane::isActive(), StdCmdFreezeViews::isActive(), StdPerspectiveCamera::isActive(), StdOrthographicCamera::isActive(), CmdTestMDI3::isActive(), CmdTestMDI2::isActive(), CmdTestMDI1::isActive(), Gui::Dialog::RedoDialog::onFetchInfo(), Gui::Dialog::UndoDialog::onFetchInfo(), Gui::Application::sendHasMsgToActiveView(), and Gui::Application::sendMsgToActiveView().
void MainWindow::addWindow | ( | MDIView * | view | ) |
Adds an MDI window view to the main window's workspace and adds a new tab to the tab bar.
Definition at line 682 of file MainWindow.cpp.
References draftlibs::fcgeo::connect(), Gui::MDIView::getTypeId(), Gui::MainWindowP::mdiArea, draftTools::p, showMessage(), tabChanged(), and windowStateChanged().
Referenced by Gui::Document::createView(), Gui::Dialog::DlgMacroExecuteImp::on_createButton_clicked(), Gui::MDIView::setCurrentViewMode(), Gui::PythonDebugger::showDebugMarker(), Gui::Application::sInsert(), and Gui::Application::sOpen().
void MainWindow::appendRecentFile | ( | const QString & | filename | ) |
MRU: Appends file to the list of recent files.
Definition at line 1136 of file MainWindow.cpp.
References Gui::RecentFilesAction::appendFile().
Referenced by Gui::Application::exportTo(), Gui::Application::importFrom(), Gui::Application::open(), and Gui::Document::saveAs().
void MainWindow::arrangeIcons | ( | ) | [slot] |
Arranges all child windows in a horizontal tile pattern.
Definition at line 464 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea.
Referenced by StdCmdArrangeIcons::activated().
bool MainWindow::canInsertFromMimeData | ( | const QMimeData * | source | ) | const |
Check if mime data contains object data.
Definition at line 1378 of file MainWindow.cpp.
Referenced by StdCmdPaste::isActive().
void MainWindow::cascade | ( | ) | [slot] |
Arranges all the child windows in a cascade pattern.
Definition at line 482 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea.
Referenced by StdCmdCascadeWindows::activated().
void MainWindow::changeEvent | ( | QEvent * | e | ) | [protected] |
This method is called from the Qt framework automatically whenever a QTranslator object has been installed.
This allows to translate all relevant user visible text.
Definition at line 1453 of file MainWindow.cpp.
References Gui::WorkbenchManager::active(), Gui::Application::commandManager(), Gui::CommandManager::getAllCommands(), Gui::WorkbenchManager::instance(), Gui::Application::Instance, Gui::Workbench::retranslate(), and Gui::MainWindowP::sizeLabel.
void MainWindow::closeActiveWindow | ( | ) | [slot] |
Closes the child window that is currently active.
Definition at line 491 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea.
Referenced by StdCmdCloseActiveWindow::activated().
void MainWindow::closeAllWindows | ( | ) | [slot] |
Closes all child windows.
The windows are closed in random order. The operation stops if a window does not accept the close event.
Definition at line 500 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea.
Referenced by StdCmdCloseAllWindows::activated().
void MainWindow::closeEvent | ( | QCloseEvent * | e | ) | [protected] |
This method checks if the main window can be closed by checking all open documents and views.
Definition at line 1071 of file MainWindow.cpp.
References Gui::MainWindowP::activityTimer, Gui::MainWindowP::assistant, Gui::Application::Instance, mainWindowClosed(), saveWindowSettings(), and Gui::Application::tryClose().
QMimeData * MainWindow::createMimeDataFromSelection | ( | ) | const |
Create mime data from selected objects.
Definition at line 1325 of file MainWindow.cpp.
References App::Document::exportObjects(), Base::FileInfo::filePath(), Gui::SelectionSingleton::getCompleteSelection(), Base::FileInfo::getTempFileName(), and Gui::Selection().
Referenced by StdCmdCopy::activated().
QMenu * MainWindow::createPopupMenu | ( | ) |
Returns true that the context menu contains the 'Customize.
..' menu item.
Definition at line 439 of file MainWindow.cpp.
References Gui::WorkbenchManager::active(), Gui::Command::addTo(), macros::cmd, Gui::Application::commandManager(), Gui::Workbench::createMainWindowPopupMenu(), Gui::CommandManager::getCommandByName(), Gui::MenuItem::getItems(), Gui::MenuItem::hasItems(), Gui::Application::Instance, and Gui::WorkbenchManager::instance().
void MainWindow::customEvent | ( | QEvent * | e | ) | [protected] |
Definition at line 1510 of file MainWindow.cpp.
References Gui::MainWindowP::actionLabel, Gui::MainWindowP::actionTimer, Gui::Application::activeDocument(), Gui::Application::Instance, Gui::CustomMessageEvent::Log, Gui::CustomMessageEvent::message(), draftTools::msg(), Gui::Document::setAnnotationViewProvider(), Gui::ViewProviderExtern::setModeByString(), and Gui::CustomMessageEvent::type().
void MainWindow::dragEnterEvent | ( | QDragEnterEvent * | e | ) | [protected] |
Checks if a mime source object can be interpreted.
Definition at line 1315 of file MainWindow.cpp.
void MainWindow::dropEvent | ( | QDropEvent * | e | ) | [protected] |
Try to interpret dropped elements.
Drops the event e and tries to open the files.
Definition at line 1303 of file MainWindow.cpp.
References loadUrls().
bool MainWindow::event | ( | QEvent * | e | ) | [protected] |
Definition at line 546 of file MainWindow.cpp.
References Spaceball::BUTTON_PRESSED, Spaceball::ButtonEvent::ButtonEventType, Spaceball::ButtonEvent::buttonNumber(), Spaceball::ButtonEvent::buttonStatus(), Gui::Application::commandManager(), Gui::CommandBase::getAction(), App::GetApplication(), Gui::CommandManager::getCommandByName(), ParameterGrp::GetGroup(), App::Application::GetUserParameter(), group, Gui::Application::Instance, Gui::CommandManager::runCommandByName(), Spaceball::ButtonEvent::setHandled(), Gui::Action::setIcon(), showDocumentation(), Gui::MainWindowP::whatstext, and Gui::MainWindowP::whatsthis.
bool MainWindow::eventFilter | ( | QObject * | o, | |
QEvent * | e | |||
) |
Filters events if this object has been installed as an event filter for the watched object.
Definition at line 602 of file MainWindow.cpp.
References RobotExample::w, Gui::MainWindowP::whatstext, Gui::MainWindowP::whatsthis, WhatsThis, and windowStateChanged().
MainWindow * MainWindow::getInstance | ( | ) | [static] |
Gets the one and only instance.
Definition at line 433 of file MainWindow.cpp.
Referenced by Gui::getMainWindow(), loadWindowSettings(), MainWindow(), saveWindowSettings(), and setupMainWindow().
void MainWindow::hideEvent | ( | QHideEvent * | e | ) | [protected] |
Definition at line 1103 of file MainWindow.cpp.
References Gui::MainWindowP::visibleTimer.
void MainWindow::insertFromMimeData | ( | const QMimeData * | source | ) |
Insert the objects into the active document.
If no document exists one gets created.
Definition at line 1387 of file MainWindow.cpp.
References App::Application::getActiveDocument(), App::GetApplication(), Gui::MergeDocuments::importObjects(), loadUrls(), and App::Application::newDocument().
Referenced by StdCmdPaste::activated().
void MainWindow::loadUrls | ( | App::Document * | doc, | |
const QList< QUrl > & | url | |||
) |
Load files from the given URLs into the given document.
If the document is 0 one gets created automatically if needed.
Definition at line 1419 of file MainWindow.cpp.
References Base::Console(), App::GetApplication(), App::Application::getImportModules(), App::Document::getName(), Gui::Application::importFrom(), Gui::SelectModule::importHandler(), and Gui::Application::Instance.
Referenced by Gui::View3DInventor::dropEvent(), dropEvent(), and insertFromMimeData().
void MainWindow::loadWindowSettings | ( | ) |
Loads the main window settings.
Definition at line 1183 of file MainWindow.cpp.
References App::Application::Config(), Base::Console(), getInstance(), KDL::max(), Draft::move(), Base::ConsoleSingleton::MsgType_Wrn, RobotExample::pos, and show().
Referenced by Gui::Application::runApplication(), and setupMainWindow().
void Gui::MainWindow::mainWindowClosed | ( | ) | [signal] |
Referenced by closeEvent().
void MainWindow::removeWindow | ( | Gui::MDIView * | view | ) |
Removes an MDI window from the main window's workspace and its associated tab without deleting the widget.
Removes the instance of Gui::MDiView from the main window and sends am event to the parent widget, a QMdiSubWindow to delete itself.
If the main windows does not have such a window nothing happens.
If you want to avoid that the Gui::MDIView instance gets destructed too you must reparent it afterwards, e.g. set parent to NULL.
Definition at line 769 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea, and windowStateChanged().
Referenced by CmdTestMDI3::activated(), CmdTestMDI1::activated(), Gui::MDIView::closeEvent(), and Gui::MDIView::setCurrentViewMode().
void MainWindow::saveWindowSettings | ( | ) |
Saves the main window settings.
Definition at line 1220 of file MainWindow.cpp.
References App::Application::Config(), getInstance(), Gui::DockWindowManager::instance(), RobotExample::pos, and Gui::DockWindowManager::saveState().
Referenced by closeEvent().
void MainWindow::setActiveWindow | ( | MDIView * | view | ) |
Sets the active window to view.
Definition at line 897 of file MainWindow.cpp.
References Gui::MainWindowP::activeView, Gui::Application::Instance, and Gui::Application::viewActivated().
Referenced by Gui::Dialog::DlgActivateWindowImp::accept(), Gui::MDIView::changeEvent(), MainWindow(), Gui::TreeView::mouseDoubleClickEvent(), Gui::TreeWidget::mouseDoubleClickEvent(), Gui::TreeWidget::onActivateDocument(), and Gui::PythonDebugger::showDebugMarker().
void MainWindow::setPaneText | ( | int | i, | |
QString | text | |||
) | [slot] |
Sets text to the pane in the status bar.
Definition at line 1053 of file MainWindow.cpp.
References Gui::MainWindowP::actionLabel, Gui::MainWindowP::actionTimer, and Gui::MainWindowP::sizeLabel.
Referenced by Gui::View3DInventorViewer::printDimension(), Gui::Sequencer::resetData(), and Gui::View3DInventorViewer::~View3DInventorViewer().
void MainWindow::showDocumentation | ( | const char * | Article = 0 |
) |
Shows the online documentation.
Definition at line 538 of file MainWindow.cpp.
References Gui::MainWindowP::assistant, and Gui::Assistant::showDocumentation().
Referenced by StdCmdOnlineHelp::activated(), and event().
void MainWindow::showEvent | ( | QShowEvent * | e | ) | [protected] |
Definition at line 1096 of file MainWindow.cpp.
References Gui::MainWindowP::visibleTimer.
void MainWindow::showMessage | ( | const QString & | message, | |
int | timeout = 0 | |||
) | [slot] |
Definition at line 1472 of file MainWindow.cpp.
References draftTools::msg().
Referenced by StdCmdPrintPdf::activated(), StdCmdPrint::activated(), Gui::SelectionSingleton::addSelection(), addWindow(), Gui::DocumentObjectItem::displayStatusInfo(), Gui::SoFCUnifiedSelection::handleEvent(), Gui::SoFCSelection::handleEvent(), WebGui::BrowserView::onLoadFinished(), WebGui::BrowserView::onLoadStarted(), Gui::Sequencer::resetData(), Gui::Document::saveAs(), Gui::SelectionSingleton::setPreselect(), Gui::SelectionSingleton::setPreselectCoord(), Gui::Sequencer::setText(), and Gui::Sequencer::showRemainingTime().
void MainWindow::showTipOfTheDay | ( | bool | force = false |
) |
Shows the Tip-of-the-day dialog after startup.
Definition at line 1282 of file MainWindow.cpp.
References App::Application::Config(), App::GetApplication(), ParameterGrp::GetGroup(), and App::Application::GetUserParameter().
QPixmap MainWindow::splashImage | ( | ) | const |
Definition at line 1270 of file MainWindow.cpp.
References Gui::BitmapFactory(), App::Application::Config(), and Gui::BitmapFactoryInst::pixmap().
Referenced by startSplasher().
void MainWindow::startSplasher | ( | void | ) |
Starts the splasher at startup.
Definition at line 1243 of file MainWindow.cpp.
References App::Application::Config(), App::GetApplication(), ParameterGrp::GetGroup(), App::Application::GetUserParameter(), splashImage(), and Gui::MainWindowP::splashscreen.
Referenced by Gui::Application::runApplication().
void MainWindow::stopSplasher | ( | void | ) |
Stops the splasher after startup.
Definition at line 1261 of file MainWindow.cpp.
References Gui::MainWindowP::splashscreen.
Referenced by Gui::Application::runApplication().
void MainWindow::switchToDockedMode | ( | ) | [slot] |
Definition at line 1172 of file MainWindow.cpp.
References Gui::MDIView::Child, and Gui::MDIView::setCurrentViewMode().
Referenced by StdCmdUserInterface::activated().
void MainWindow::switchToTopLevelMode | ( | ) | [slot] |
Definition at line 1158 of file MainWindow.cpp.
References Gui::getMainWindow(), and windows().
void MainWindow::tabChanged | ( | MDIView * | view | ) |
Can be called after the caption of an MDIView has changed to update the tab's caption.
Definition at line 818 of file MainWindow.cpp.
References RobotExample::pos.
Referenced by addWindow(), Gui::MDIView::changeEvent(), and MainWindow().
void MainWindow::tile | ( | ) | [slot] |
Arranges all child windows in a tile pattern.
Definition at line 473 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea.
Referenced by StdCmdTileWindows::activated().
void Gui::MainWindow::timeEvent | ( | ) | [signal] |
void Gui::MainWindow::timerEvent | ( | QTimerEvent * | ) | [inline, protected] |
Definition at line 221 of file MainWindow.h.
void MainWindow::whatsThis | ( | ) | [slot] |
Starts the what's this mode.
Definition at line 533 of file MainWindow.cpp.
QList< QWidget * > MainWindow::windows | ( | QMdiArea::WindowOrder | order = QMdiArea::CreationOrder |
) | const |
Returns a list of all MDI windows in the worpspace.
Definition at line 1036 of file MainWindow.cpp.
References Gui::MainWindowP::mdiArea.
Referenced by Gui::Dialog::DlgActivateWindowImp::accept(), Gui::Dialog::DlgActivateWindowImp::DlgActivateWindowImp(), Gui::PythonDebugger::hideDebugMarker(), StdCmdActivatePrevWindow::isActive(), StdCmdActivateNextWindow::isActive(), StdCmdCloseAllWindows::isActive(), StdCmdCloseActiveWindow::isActive(), StdCmdCascadeWindows::isActive(), StdCmdTileWindows::isActive(), StdCmdArrangeIcons::isActive(), Gui::PythonDebugger::showDebugMarker(), and switchToTopLevelMode().
void Gui::MainWindow::windowStateChanged | ( | MDIView * | ) | [signal] |
Referenced by addWindow(), eventFilter(), and removeWindow().
void Gui::MainWindow::workbenchActivated | ( | const QString & | ) | [signal] |
Referenced by activateWorkbench().