NDEVR
API Documentation
WindowManager.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: WindowManager
29Included in API: True
30Author(s): Tyler Parke
31 *--------------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/DesignObjectDialog.h>
35#include <NDEVR/QCustomDockWidget.h>
36#include <NDEVR/PopupManager.h>
37#include <NDEVR/FileFormat.h>
38#include <QPointer>
39namespace NDEVR
40{
42 struct FileRequest;
43 class QTModelManager;
47 class SettingsDialog;
48 class AboutDialog;
50 class LogManagerDialog;
51 struct ExportRequest;
52 class QTDesignObject;
53 class Keypad;
54 class WidgetInit;
55 class DockInit;
57 typedef AlocatingAlignedBuffer<FactoryParameters, 64> FactoryParameterBuffer;
68 class NDEVR_API WindowManager : public QObject, public PopupManager
69 {
70 Q_OBJECT
71 public:
77 virtual ~WindowManager();
81 virtual QWidget* mainWindow() const = 0;
82
88 void createNewProject(bool show_settings, const PopupInfo& popup_origin = PopupInfo());
89
97 virtual void updateModified() = 0;
105 virtual void clearAll() = 0;
106
117 virtual void userDeleteObjects(const Buffer<UUID>& ids, PopupInfo info);
118
130 virtual void exportFile(ExportRequest request);
131
143 virtual void exportFiles(Buffer<UUID> model, const Buffer<FileRequest>& files, const PopupInfo& popup_origin);
144
145
152 virtual void saveImage(const StringView& image_id, const File& default_file, PopupInfo info);
163 virtual void saveProjectAs(const PopupInfo& popup_origin = PopupInfo());
164
175 virtual void userOpenProject(PopupInfo popup_origin = PopupInfo());
176
182 virtual void userImportFile(PopupInfo popup_origin = PopupInfo());
189 virtual void userImportFile(PopupInfo popup_origin, const Buffer<FileFormat>& formats);
196 virtual void importUserFiles(const Buffer<FileRequest>& files, PopupInfo popup_origin = PopupInfo());
202 virtual void openUserFiles(const Buffer<FileRequest>& files, PopupInfo popup_origin = PopupInfo());
208 virtual void showImportDialogIfNeeded(const Buffer<FileRequest>& file, PopupInfo popup_origin = PopupInfo());
215 virtual void showModelProperties(const ShowPropertiesSettings& settings);
216
222 virtual void closeAll(const PopupInfo& popup_origin = PopupInfo());
223
229 virtual void addCustomDockWidget(DockInit* widget);
230
236 virtual void removeCustomDockWidget(DockInit* widget);
237
241 virtual void showMainScreen();
242
249 virtual void addSettingsMenu(WidgetInit* menu, std::function<void()> reset_to_defaults);
254 virtual void removeSettingsMenu(WidgetInit* menu);
260 virtual void addInitialSetupSettingsMenu(WidgetInit* menu, bool always_show = false);
272 virtual void requestExit(const PopupInfo& popup_origin = PopupInfo());
273
280 virtual void requestExit(QCloseEvent* event, const PopupInfo& popup_origin = PopupInfo());
281
292 virtual void requestExitWithFunction(std::function<void()> exit_function, const PopupInfo& popup_origin = PopupInfo());
293
298 virtual void exit(bool relaunch = false, const StringView& relaunch_options = "--relaunch");
299
305
312
318
324
330
369
370
379 virtual void onNewProjectSelected(const PopupInfo& popup_origin = PopupInfo());
380
390 virtual void onNewProjectSelected(bool show_settings, const PopupInfo& popup_origin = PopupInfo());
396 virtual void createNewProjectNow(bool show_settings, const PopupInfo& popup_origin = PopupInfo());
405 void simulateKeyPress(int key);
410 virtual void setMainWindowCallback(const std::function<void(QWidget*)>& main_window_callback);
414 virtual void recoverLastData() {};
415
416 protected:
458 virtual void hideSplashScreen(const TimeSpan& delay_time, const TimeSpan& fade_time);
462 virtual void layoutAll();
482 void updateFileDialog(const Buffer<UUID>& model, const Buffer<FileFormat>& formats, StringView extension, bool show_recents, bool save_dialog);
492 virtual DropArea defaultDropArea(const QCustomDockWidget* dock_widget) const;
498 virtual SectionWidget* defaultDropReference(const QCustomDockWidget* dock_widget = nullptr) const;
504 FactoryParameterBuffer convertRequest(const Buffer<FileRequest>& requests);
514 protected slots:
519 signals:
533 protected:
534 QPointer<DockWidget<Keypad>> m_key_pad_dock = nullptr;
535 Buffer<std::tuple<WidgetInit*, std::function<void()>>> m_settings_dialogs;
541 std::function<void(QWidget*)> m_main_window_callback;
542
549
555 bool m_is_exiting = false;
556 bool m_has_setup_keypad = false;
557 };
558
559
560}
Shows information about the current software version.
Definition AboutDialog.h:55
Default dialog shown when the user exports an ascii-or custom column style file.
Dialog that allows user to choose import or export options while simultaneously automatically writing...
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
The root class that manages a series of SectionContent that can share the same space or lay out in va...
Manages the creation and lookup of DesignObjectDialog instances for design objects.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Provides a way to optionally lazily initialize widgets when needed but still pass them to container d...
Definition WidgetInit.h:43
A type-safe dock widget that wraps a specific widget type.
A dialog designed to allow the user to navigate a filesytem and select or create one or more files or...
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
Shown after a new installation on a device, allowing the user to familiarize themselves with the envi...
A popup for showing a virtual keyboard or keypad.
Definition Keypad.h:57
A dialog which shows multiple log views, where each log is a tab.
PopupManager()
Constructs a PopupManager.
Provides a wrapper for a widget that can be docked inside a Container or floated as a top-level windo...
A pointer to a DesignObject within a QTModelManager that receives and emits update signals based on t...
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
SectionWidget manages multiple instances of SectionContent.
The main Settings dialog for the application.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Provides a way to lazily initialize widgets when needed but still pass them to container dialogs.
Definition WidgetInit.h:13
virtual void showMainScreen()
Shows the main screen and puts it in front of any windows.
DockWidget< AutoModelFileDialog > * m_import_dock
The import file dialog dock.
void onNewProjectSignal()
Signal emitted when a new project is created.
virtual InitialSetupDialog * initialSetupDialog()
Returns or creates the initial setup dialog.
virtual SettingsDialog * createSettingsDialog()
Creates and returns a new SettingsDialog instance.
virtual AboutDialog * createAboutDialog()
Creates and returns a new AboutDialog instance.
virtual void setMainWindowCallback(const std::function< void(QWidget *)> &main_window_callback)
Sets a callback invoked when the main window is created or changed.
virtual void updateFromWindowOptions()
Updates the window layout and behavior based on the current WindowOptions.
virtual void hideSplashScreen(const TimeSpan &delay_time, const TimeSpan &fade_time)
Hides the splash screen with the specified delay and fade animation.
virtual void showImportDialogIfNeeded(const Buffer< FileRequest > &file, PopupInfo popup_origin=PopupInfo())
Shows the import settings dialog if additional configuration is needed for the file requests.
virtual void userImportFile(PopupInfo popup_origin, const Buffer< FileFormat > &formats)
Called when the user has requested to import a file.
virtual SectionWidget * defaultDropReference(const QCustomDockWidget *dock_widget=nullptr) const
Returns the default section widget to drop relative to.
virtual AsciiModelFileDialog * createAsciiModelFileDialog(bool is_import)
Creates and returns a new AsciiModelFileDialog for import or export.
virtual void exportFiles(Buffer< UUID > model, const Buffer< FileRequest > &files, const PopupInfo &popup_origin)
Called when the user has selected a file format and default data to export.
virtual void importUserFiles(const Buffer< FileRequest > &files, PopupInfo popup_origin=PopupInfo())
Called when the user has requested to import and has selected a file.
virtual void addSettingsMenu(WidgetInit *menu, std::function< void()> reset_to_defaults)
Adds a dialog to the logic such that, should a settings dialog be created, the dialog will be added t...
virtual void saveProjectAs(const PopupInfo &popup_origin=PopupInfo())
Called when the user has selected the project to save and we want to allow them to rename the file Wi...
FileChooserDialog * m_file_chooser
The main file chooser dialog.
QTModelManager * m_model_manager
The model manager providing project data.
virtual FileChooserDialog * createFileChooserDialog()
Creates and returns a new FileChooserDialog instance.
virtual void exportFile(ExportRequest request)
Called when the user exports.
virtual void createNewProjectNow(bool show_settings, const PopupInfo &popup_origin=PopupInfo())
Creates a new project immediately without prompting to save.
virtual void removeSettingsMenu(WidgetInit *menu)
Removes a previously added settings menu from the settings dialog.
Buffer< DockInit * > m_custom_dock_widgets
Custom dock widgets registered by modules.
virtual DockWidget< AutoModelFileDialog > * importerWindow(const Buffer< FileRequest > &requests)
Returns the dialog adjusting the import settings of a given file request.
DockWidget< AsciiModelFileDialog > * m_ascii_import_dock
The ASCII import file dialog dock.
WindowManager(QTModelManager *manager)
Constructs a WindowManager with the given model manager.
void updateFileDialogToProject()
Updates the file dialog to default to the current project directory.
virtual void addProjectFolderToRecents()
Adds the current project folder to the recent directories list.
void initialSetupFinishedSlot()
Slot invoked when the initial setup process has completed.
virtual DockWidget< LogManagerDialog > * logView()
Returns the dialog for viewing all application logs related to the session and project.
void userDataAdded(Buffer< UUID > object)
Signal emitted when user data has been added to the project.
virtual void setupExporterWindow(AutoModelFileDialog *window, Buffer< UUID > model, const Buffer< FileRequest > &file)
Configures an exporter window with the given model objects and file requests.
virtual DockWidget< AsciiModelFileDialog > * asciiExporterWindow(Buffer< UUID > model, const Buffer< FileRequest > &file)
Returns the ASCII exporter dialog configured for the given model and file requests.
bool m_is_exiting
Whether the application is in the process of exiting.
virtual DockWidget< AboutDialog > * aboutDialog()
Returns the about dialog, which details information about the application, and instruction manuals,...
virtual DockWidget< AsciiModelFileDialog > * asciiImporterWindow(const Buffer< FileRequest > &requests)
Returns the ASCII importer dialog configured for the given file requests.
FactoryParameterBuffer convertRequest(const Buffer< FileRequest > &requests)
Converts file requests into a FactoryParameterBuffer for IO processing.
virtual DockWidget< AutoModelFileDialog > * exporterWindow(Buffer< UUID > model, const Buffer< FileRequest > &file)
Returns the dialog adjusting the export settings of a given file request.
FileChooserDialog * m_image_export
File chooser dialog for image export.
virtual void addCustomDockWidget(DockInit *widget)
Adds a widget to be docked in the default location when a project has been loaded.
virtual void userImportFile(PopupInfo popup_origin=PopupInfo())
Called when the user has requested to import a file.
virtual void openUserFiles(const Buffer< FileRequest > &files, PopupInfo popup_origin=PopupInfo())
Opens user-selected files as new projects or adds them to the current project.
virtual void layoutAll()
Performs a full layout pass, arranging all dock widgets and panels.
virtual void requestExitWithFunction(std::function< void()> exit_function, const PopupInfo &popup_origin=PopupInfo())
Prompts the user to confirm an exit and save changes if required.
DockWidget< AboutDialog > * m_about_dock
The about dialog dock.
virtual void onNewProjectSelected(const PopupInfo &popup_origin=PopupInfo())
Creates a new project and shows any relevant information based on WindowOptions.
virtual FileChooserDialog * fileChooser()
Returns the default file chooser dialog used for user selection of files for import or export.
virtual void removeCustomDockWidget(DockInit *widget)
Removes a widget that was added with addCustomDockWidget.
virtual void removeInitialSetupSettingsMenu(WidgetInit *menu)
Removes a previously added initial setup settings menu.
virtual void userOpenProject(PopupInfo popup_origin=PopupInfo())
Called when the user has requested to choose a project file to open.
virtual void exit(bool relaunch=false, const StringView &relaunch_options="--relaunch")
Saves user settings and exits the application, relaunching if requested.
String m_export_image_id
The identifier of the image being exported.
bool m_has_setup_keypad
Whether the on-screen keypad has been initialized.
std::function< void(QWidget *)> m_main_window_callback
Callback invoked when the main window is created.
QPointer< DockWidget< Keypad > > m_key_pad_dock
The docked keypad widget for touch input.
DockWidget< AsciiModelFileDialog > * m_ascii_export_dock
The ASCII export file dialog dock.
DockWidget< SettingsDialog > * m_settings_dock
The settings dialog dock.
virtual void closeAll(const PopupInfo &popup_origin=PopupInfo())
Prompts the user to save changes, if required, then closes everything returning to application initia...
void initKeypad()
Initializes the on-screen keypad for touch input.
virtual LogManagerDialog * createLogView()
Creates and returns a new LogManagerDialog instance.
void simulateKeyPress(int key)
Simulates a key press event as if the user pressed a key on the keyboard.
void lockScreenToWindowSize()
Locks the screen resolution to match the current window size.
virtual QWidget * mainWindow() const =0
Returns the primary window for the application.
Buffer< std::tuple< WidgetInit *, std::function< void()> > > m_settings_dialogs
Registered settings menus and their reset callbacks.
InitialSetupDialog * m_initial_setup_dialog
The initial setup dialog instance.
void createNewProject(bool show_settings, const PopupInfo &popup_origin=PopupInfo())
Creates a new project and shows any relevant information based on show_settings parameter.
virtual void saveImage(const StringView &image_id, const File &default_file, PopupInfo info)
Prompts the user to save an image to a file location.
virtual DockWidget< SettingsDialog > * settingsDialog()
Returns the settings dialog for allowing the user to adjust application specific objects.
virtual DockWidget< AsciiModelFileDialog > * asciiImporterWindow()
Returns the dialog adjusting used for adjust the import settings of a given ascii file request.
virtual void requestExit(QCloseEvent *event, const PopupInfo &popup_origin=PopupInfo())
Prompts the user to confirm an exit and save changes if required.
virtual void recoverLastData()
Attempts to recover data from the last session if it was not properly saved.
virtual void onNewProjectSelected(bool show_settings, const PopupInfo &popup_origin=PopupInfo())
Creates a new project and shows any relevant information based on show_settings parameter.
Buffer< std::tuple< WidgetInit *, bool > > m_initial_settings_dialogs
Registered initial setup menus and their always-show flags.
virtual DockWidget< AutoModelFileDialog > * importerWindow()
Returns the dialog adjusting used for adjust the import settings of a given file request.
virtual void clearAll()=0
Resets the entire display to original initial state, before a project was loaded.
virtual void addInitialSetupSettingsMenu(WidgetInit *menu, bool always_show=false)
Adds a menu to the initial setup dialog shown on first launch.
virtual void updateModified()=0
Called when application should check to see if the project has been modified since last save.
virtual void userDeleteObjects(const Buffer< UUID > &ids, PopupInfo info)
Called when the user deletes objects.
void initialSetupFinishedSignal()
Signal emitted when the initial setup process has completed.
virtual DropArea defaultDropArea(const QCustomDockWidget *dock_widget) const
Returns the default drop area for a given dock widget.
DockWidget< AutoModelFileDialog > * m_export_dock
The export file dialog dock.
virtual void showModelProperties(const ShowPropertiesSettings &settings)
Called when we want to show the dialog for editing a specific object using application default editin...
virtual AutoModelFileDialog * createAutoModelFileDialog(bool is_import)
Creates and returns a new AutoModelFileDialog for import or export.
Dictionary< UUID, QPointer< DockWidget< DesignObjectDialog > > > m_editor_docks
Map of object UUIDs to their editor dock widgets.
void updateFileDialog(const Buffer< UUID > &model, const Buffer< FileFormat > &formats, StringView extension, bool show_recents, bool save_dialog)
Updates the file chooser dialog with format filters and options.
virtual void requestExit(const PopupInfo &popup_origin=PopupInfo())
Prompts the user to confirm an exit and save changes if required.
DesignObjectDialogLookup * m_dialog_lookup
Lookup table for design object editing dialogs.
DockWidget< LogManagerDialog > * m_log_dock
The log manager dialog dock.
The primary namespace for the NDEVR SDK.
DropArea
relates where a widget should be dropped relative to another.
Definition RibbonArea.h:46
Stores information related to exporting specific data from the software.
A FileRequest bundles format data as well as a particular file.
Definition FileFormat.h:101
Class which is used to pass arguments and requests for creating a popup dialog or widget.
Definition PopupInfo.h:16
Stores settings for setting up and displaying a DesignObjectDialog such as whether the dialog is part...