Gui::MainWindow Class Reference

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 Types

enum  ConfirmSaveResult {
  Cancel = 0 , Save , SaveAll , Discard ,
  DiscardAll
}
 

Public Member Functions

MDIViewactiveWindow () const
 Returns the active MDI window or 0 if there is none. More...
 
void addWindow (MDIView *view)
 Adds an MDI window view to the main window's workspace and adds a new tab to the tab bar. More...
 
void appendRecentFile (const QString &filename)
 MRU: Appends file to the list of recent files. More...
 
void appendRecentMacro (const QString &filename)
 MRU: Appends macro to the list of recent macros. More...
 
QMenucreatePopupMenu ()
 Returns true that the context menu contains the 'Customize...' menu item. More...
 
bool eventFilter (QObject *o, QEvent *e)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
 MainWindow (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::Window)
 Constructs an empty main window. More...
 
void removeWindow (MDIView *view, bool close=true)
 Removes an MDI window from the main window's workspace and its associated tab without deleting the widget. More...
 
void setActiveWindow (MDIView *view)
 Sets the active window to view. More...
 
void tabChanged (MDIView *view)
 Can be called after the caption of an MDIView has changed to update the tab's caption. More...
 
QList< QWidget * > windows (QMdiArea::WindowOrder order=QMdiArea::CreationOrder) const
 Returns a list of all MDI windows in the worpspace. More...
 
 ~MainWindow ()
 Destroys the object and frees any allocated resources. More...
 
Layout Methods
void loadWindowSettings ()
 Loads the main window settings. More...
 
void saveWindowSettings ()
 Saves the main window settings. More...
 

MIME data handling

enum  StatusType {
}
 
QMimeData * createMimeDataFromSelection () const
 Create mime data from selected objects. More...
 
bool canInsertFromMimeData (const QMimeData *source) const
 Check if mime data contains object data. More...
 
void insertFromMimeData (const QMimeData *source)
 Insert the objects into the active document. More...
 
void loadUrls (App::Document *, const QList< QUrl > &)
 Load files from the given URLs into the given document. More...
 
void setUrlHandler (const QString &scheme, UrlHandler *handler)
 Sets the handler for the given scheme. More...
 
void unsetUrlHandler (const QString &scheme)
 Removes a previously set URL handler for the specified scheme. More...
 
void updateActions (bool delay=false)
 
void showStatus (int type, const QString &message)
 
void updateEditorActions ()
 Updates the standard actions of a text editor such as Cut, Copy, Paste, Undo and Redo. More...
 
void setPaneText (int i, QString text)
 Sets text to the pane in the status bar. More...
 
void arrangeIcons ()
 Arranges all child windows in a horizontal tile pattern. More...
 
void tile ()
 Arranges all child windows in a tile pattern. More...
 
void cascade ()
 Arranges all the child windows in a cascade pattern. More...
 
void closeActiveWindow ()
 Closes the child window that is currently active. More...
 
bool closeAllDocuments (bool close=true)
 Closes all document window. More...
 
int confirmSave (const char *docName, QWidget *parent=nullptr, bool addCheckBox=false)
 Pop up a message box asking for saving document. More...
 
void activateNextWindow ()
 Activates the next window in the child window chain. More...
 
void activatePreviousWindow ()
 Activates the previous window in the child window chain. More...
 
void activateWorkbench (const QString &)
 Just emits the workbenchActivated() signal to notify all receivers. More...
 
void whatsThis ()
 Starts the what's this mode. More...
 
void switchToTopLevelMode ()
 
void switchToDockedMode ()
 
void statusMessageChanged ()
 
void showMessage (const QString &message, int timeout=0)
 
void closeEvent (QCloseEvent *e)
 This method checks if the main window can be closed by checking all open documents and views. More...
 
void showEvent (QShowEvent *e)
 
void hideEvent (QHideEvent *e)
 
void timerEvent (QTimerEvent *)
 
void customEvent (QEvent *e)
 
bool event (QEvent *e)
 
void dropEvent (QDropEvent *e)
 Try to interpret dropped elements. More...
 
void dragEnterEvent (QDragEnterEvent *e)
 Checks if a mime source object can be interpreted. More...
 
void changeEvent (QEvent *e)
 This method is called from the Qt framework automatically whenever a QTranslator object has been installed. More...
 
void timeEvent ()
 
void windowStateChanged (MDIView *)
 
void workbenchActivated (const QString &)
 
void mainWindowClosed ()
 

Splasher and access methods

void startSplasher (void)
 Starts the splasher at startup. More...
 
void stopSplasher (void)
 Stops the splasher after startup. More...
 
QPixmap aboutImage () const
 
QPixmap splashImage () const
 
void showDocumentation (const QString &help)
 Shows the online documentation. More...
 
static MainWindowgetInstance ()
 Gets the one and only instance. More...
 

Detailed Description

The MainWindow class provides a main window with menu bar, toolbars, dockable windows, a status bar and mainly a workspace for the MDI windows.

Author
Werner Mayer

Member Enumeration Documentation

◆ ConfirmSaveResult

Enumerator
Cancel 
Save 
SaveAll 
Discard 
DiscardAll 

◆ StatusType

Enumerator
Err 
Wrn 
Pane 
Msg 
Log 
Tmp 

Constructor & Destructor Documentation

◆ MainWindow()

◆ ~MainWindow()

MainWindow::~MainWindow ( )

Destroys the object and frees any allocated resources.

References Gui::MainWindowP::status.

Member Function Documentation

◆ aboutImage()

◆ activateNextWindow

void MainWindow::activateNextWindow ( )
slot

Activates the next window in the child window chain.

References Gui::MainWindowP::mdiArea.

Referenced by StdCmdActivateNextWindow::activated().

◆ activatePreviousWindow

void MainWindow::activatePreviousWindow ( )
slot

Activates the previous window in the child window chain.

References Gui::MainWindowP::mdiArea.

Referenced by StdCmdActivatePrevWindow::activated().

◆ activateWorkbench

void MainWindow::activateWorkbench ( const QString &  name)
slot

◆ activeWindow()

MDIView * MainWindow::activeWindow ( void  ) const

Returns the active MDI window or 0 if there is none.

References Gui::MainWindowP::activeView.

Referenced by SketcherGui::DrawSketchHandler::activate(), StdCmdPrint::activated(), StdCmdPrintPreview::activated(), StdCmdPrintPdf::activated(), StdCmdEdit::activated(), CmdTestMDI1::activated(), CmdTestMDI2::activated(), CmdTestMDI3::activated(), StdMainFullscreen::activated(), StdViewDockUndockFullscreen::activated(), StdCmdToggleNavigation::activated(), changeEvent(), Gui::SoFCColorGradient::customize(), SketcherGui::DrawSketchHandler::devicePixelRatio(), Gui::Dialog::DlgActivateWindowImp::DlgActivateWindowImp(), Gui::Document::getActiveView(), CmdTestMDI1::isActive(), CmdTestMDI2::isActive(), CmdTestMDI3::isActive(), StdViewDock::isActive(), StdViewUndock::isActive(), StdViewFullscreen::isActive(), StdViewDockUndockFullscreen::isActive(), StdCmdToggleNavigation::isActive(), StdCmdMeasureDistance::isActive(), StdCmdTextureMapping::isActive(), Gui::Dialog::UndoDialog::onFetchInfo(), Gui::Dialog::RedoDialog::onFetchInfo(), TechDrawGui::ViewProviderPage::removeMDIView(), Gui::Application::sendHasMsgToActiveView(), Gui::Application::sendHasMsgToFocusView(), Gui::Application::sendMsgToActiveView(), Gui::Application::sendMsgToFocusView(), Gui::Document::setActiveWindow(), SpreadsheetGui::WorkbenchHelper::setBackgroundColor(), SketcherGui::DrawSketchHandler::setCursor(), SpreadsheetGui::WorkbenchHelper::setForegroundColor(), Gui::Application::slotActiveDocument(), SketcherGui::DrawSketchHandler::suggestedConstraintsPixmaps(), and SketcherGui::DrawSketchHandler::unsetCursor().

◆ addWindow()

◆ appendRecentFile()

void MainWindow::appendRecentFile ( const QString &  filename)

◆ appendRecentMacro()

void MainWindow::appendRecentMacro ( const QString &  filename)

◆ arrangeIcons

void MainWindow::arrangeIcons ( )
slot

Arranges all child windows in a horizontal tile pattern.

References Gui::MainWindowP::mdiArea.

Referenced by StdCmdArrangeIcons::activated().

◆ canInsertFromMimeData()

bool MainWindow::canInsertFromMimeData ( const QMimeData *  source) const

Check if mime data contains object data.

Referenced by StdCmdPaste::isActive().

◆ cascade

void MainWindow::cascade ( )
slot

Arranges all the child windows in a cascade pattern.

References Gui::MainWindowP::mdiArea.

Referenced by StdCmdCascadeWindows::activated().

◆ changeEvent()

void MainWindow::changeEvent ( QEvent e)
protected

◆ closeActiveWindow

void MainWindow::closeActiveWindow ( )
slot

Closes the child window that is currently active.

References Gui::MainWindowP::mdiArea.

Referenced by StdCmdCloseActiveWindow::activated().

◆ closeAllDocuments

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent *  e)
protected

◆ confirmSave

int MainWindow::confirmSave ( const char *  docName,
QWidget parent = nullptr,
bool  addCheckBox = false 
)
slot

◆ createMimeDataFromSelection()

◆ createPopupMenu()

◆ customEvent()

◆ dragEnterEvent()

void MainWindow::dragEnterEvent ( QDragEnterEvent *  e)
protected

Checks if a mime source object can be interpreted.

◆ dropEvent()

void MainWindow::dropEvent ( QDropEvent *  e)
protected

Try to interpret dropped elements.

Drops the event e and tries to open the files.

References App::GetApplication(), and loadUrls().

◆ event()

◆ eventFilter()

bool MainWindow::eventFilter ( QObject o,
QEvent e 
)

Filters events if this object has been installed as an event filter for the watched object.

References Gui::MainWindowP::whatstext, Gui::MainWindowP::whatsthis, and windowStateChanged().

◆ getInstance()

◆ hideEvent()

void MainWindow::hideEvent ( QHideEvent *  e)
protected

◆ insertFromMimeData()

void MainWindow::insertFromMimeData ( const QMimeData *  source)

◆ loadUrls()

void MainWindow::loadUrls ( App::Document doc,
const QList< QUrl > &  urls 
)

Load files from the given URLs into the given document.

If the document is 0 one gets created automatically if needed.

If a url handler is registered that supports its scheme it will be delegated to this handler. This mechanism allows to change the default behaviour.

References Base::Console(), Gui::Dialog::DownloadManager::download(), App::GetApplication(), App::Application::getImportModules(), Gui::Dialog::DownloadManager::getInstance(), Gui::Application::importFrom(), Gui::SelectModule::importHandler(), Gui::Application::Instance, Base::ConsoleSingleton::Message(), Gui::Dialog::DownloadManager::redirectUrl(), and Gui::MainWindowP::urlHandler.

Referenced by dropEvent(), Gui::View3DInventor::dropEvent(), Gui::View3DInventorViewer::dropEvent(), insertFromMimeData(), and WebGui::BrowserView::onDownloadRequested().

◆ loadWindowSettings()

◆ mainWindowClosed

void Gui::MainWindow::mainWindowClosed ( )
signal

Referenced by closeEvent().

◆ removeWindow()

void MainWindow::removeWindow ( Gui::MDIView view,
bool  close = true 
)

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.

References Gui::MainWindowP::mdiArea, showMessage(), updateActions(), and windowStateChanged().

Referenced by CmdTestMDI1::activated(), CmdTestMDI3::activated(), SpreadsheetGui::ViewProviderSheet::beforeDelete(), TechDrawGui::ViewProviderPage::removeMDIView(), Gui::MDIView::setCurrentViewMode(), and SpreadsheetGui::ViewProviderSheet::~ViewProviderSheet().

◆ saveWindowSettings()

◆ setActiveWindow()

◆ setPaneText

◆ setUrlHandler()

void MainWindow::setUrlHandler ( const QString &  scheme,
Gui::UrlHandler handler 
)

Sets the handler for the given scheme.

If setUrlHandler() is used to set a new handler for a scheme which already has a handler, the existing handler is simply replaced with the new one. Since MainWindow does not take ownership of handlers, no objects are deleted when a handler is replaced.

References Gui::MainWindowP::urlHandler.

◆ showDocumentation()

void MainWindow::showDocumentation ( const QString &  help)

◆ showEvent()

void MainWindow::showEvent ( QShowEvent *  e)
protected

◆ showMessage

void MainWindow::showMessage ( const QString &  message,
int  timeout = 0 
)
slot

◆ showStatus()

◆ splashImage()

◆ startSplasher()

◆ statusMessageChanged

void MainWindow::statusMessageChanged ( )
slot

◆ stopSplasher()

void MainWindow::stopSplasher ( void  )

Stops the splasher after startup.

References Gui::MainWindowP::splashscreen.

◆ switchToDockedMode

void MainWindow::switchToDockedMode ( )
slot

◆ switchToTopLevelMode

void MainWindow::switchToTopLevelMode ( )
slot

References Gui::getMainWindow(), and windows().

◆ tabChanged()

void MainWindow::tabChanged ( MDIView view)

Can be called after the caption of an MDIView has changed to update the tab's caption.

References updateActions().

Referenced by Gui::MDIView::changeEvent(), and MainWindow().

◆ tile

void MainWindow::tile ( )
slot

Arranges all child windows in a tile pattern.

References Gui::MainWindowP::mdiArea.

Referenced by StdCmdTileWindows::activated().

◆ timeEvent

void Gui::MainWindow::timeEvent ( )
signal

◆ timerEvent()

void Gui::MainWindow::timerEvent ( QTimerEvent *  )
protected

◆ unsetUrlHandler()

void MainWindow::unsetUrlHandler ( const QString &  scheme)

Removes a previously set URL handler for the specified scheme.

References Gui::MainWindowP::urlHandler.

◆ updateActions()

◆ updateEditorActions

void MainWindow::updateEditorActions ( )
slot

Updates the standard actions of a text editor such as Cut, Copy, Paste, Undo and Redo.

References Gui::Application::commandManager(), Gui::CommandManager::getCommandByName(), Gui::Application::Instance, and Gui::Command::testActive().

Referenced by MainWindow().

◆ whatsThis

void MainWindow::whatsThis ( )
slot

Starts the what's this mode.

◆ windows()

◆ windowStateChanged

void Gui::MainWindow::windowStateChanged ( MDIView )
signal

◆ workbenchActivated

void Gui::MainWindow::workbenchActivated ( const QString &  )
signal

Referenced by activateWorkbench().


The documentation for this class was generated from the following files: