Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Slots | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
OliveGlobal Class Reference

The Olive Global class. More...

#include <global.h>

Inheritance diagram for OliveGlobal:

Public Slots

void undo ()
 Undo user's last action. More...
 
void redo ()
 Redo user's last action. More...
 
void paste ()
 Paste contents of clipboard. More...
 
void paste_insert ()
 Paste contents of clipboard, making space for it when possible. More...
 
void new_project ()
 Create new project. More...
 
void OpenProject ()
 Open a project from file. More...
 
void ImportProject (const QString &fn)
 Import project from file. More...
 
void open_recent (int index)
 Open recent project from list. More...
 
bool save_project_as ()
 Shows a save file dialog and saves the project as the resulting filename. More...
 
bool save_project ()
 Saves the current project to file. More...
 
bool can_close_project ()
 Determine whether the current project can be closed. More...
 
void open_export_dialog ()
 Open the Export dialog to trigger an export of the current sequence. More...
 
void open_about_dialog ()
 Open the About Olive dialog. More...
 
void open_debug_log ()
 Open the Debug Log window. More...
 
void open_speed_dialog ()
 Open the Speed/Duration dialog. More...
 
void open_autocut_silence_dialog ()
 Open the auto-cut silence dialog. More...
 
void open_action_search ()
 Open the Action Search overlay. More...
 
void clear_undo_stack ()
 Clears the current undo stack. More...
 
void finished_initialize ()
 Function called when Olive has finished starting up. More...
 
void save_autorecovery_file ()
 Save an auto-recovery file of the current project. More...
 
void open_preferences ()
 Opens the Preferences dialog. More...
 
void set_sequence (SequencePtr s)
 Set the current active Sequence. More...
 

Public Member Functions

 OliveGlobal ()
 OliveGlobal Constructor. More...
 
const QString & get_project_file_filter ()
 Returns the file dialog filter used when interfacing with Olive project files. More...
 
void update_project_filename (const QString &s)
 Change the current active project filename. More...
 
void check_for_autorecovery_file ()
 Check whether an auto-recovery file exists and ask the user if they want to load it. More...
 
void set_rendering_state (bool rendering)
 Set the application state depending on if the user is exporting a video. More...
 
void set_modified (bool modified)
 Set the application's "modified" state. More...
 
bool is_modified ()
 Get application's current "modified" state. More...
 
void load_project_on_launch (const QString &s)
 Set a project to load just after launching. More...
 
QString get_recent_project_list_file ()
 Retrieves the URL of the config file containing the autorecovery projects. More...
 
void load_translation_from_config ()
 (Re)load translation file from olive::config More...
 

Static Public Member Functions

static void SetNativeStyling (QWidget *w)
 Set native UI styling on a given widget. More...
 

Private Member Functions

void OpenProjectWorker (QString fn, bool autorecovery)
 Internal function to handle loading a project from file. More...
 
bool CheckForActiveSequence (bool show_msg=true)
 Returns whether a Sequence is currently active or not, and optionally displays a messagebox if not. More...
 
void LoadProject (const QString &fn, bool autorecovery)
 Create a LoadDialog and start a LoadThread to load data from a project. More...
 
void ClearProject ()
 Indiscriminately clear the project without prompting the user. More...
 

Private Attributes

QString project_file_filter
 File filter used for any file dialogs relating to Olive project files. More...
 
QTimer autorecovery_timer
 Regular interval to save an auto-recovery project. More...
 
bool enable_load_project_on_init
 Internal variable set to TRUE by main() if a project file was set as an argument. More...
 
std::unique_ptr< QTranslator > translator
 Internal translator object that interfaces with the currently loaded language file. More...
 
bool changed_since_last_autorecovery
 Internal variable for whether the project has changed since the last autorecovery. More...
 

Detailed Description

The Olive Global class.

A resource for various global functions used throughout Olive.

Constructor & Destructor Documentation

OliveGlobal::OliveGlobal ( )

OliveGlobal Constructor.

Creates Olive Global object. Also sets some default runtime settings and the application name.

Member Function Documentation

bool OliveGlobal::can_close_project ( )
slot

Determine whether the current project can be closed.

Queried any time the current project is going to be closed (e.g. starting a new project, loading a project, exiting Olive, etc.) If the project has unsaved changes, this function asks the user whether they want to save or not. If the user does, calls save_project() (which may in turn call save_project_as() if the project has never been saved).

Returns
TRUE if the project can be closed. FALSE if not. If the project does NOT have unsaved changes, always returns TRUE. If it does and the user clicks YES, this returns the result of save_project(). If the user clicks NO, this returns TRUE. If the user clicks CANCEL, this returns FALSE.
void OliveGlobal::check_for_autorecovery_file ( )

Check whether an auto-recovery file exists and ask the user if they want to load it.

Usually called on initialization. Checks if an auto-recovery file exists (meaning the last session of Olive didn't close correctly). If it finds one, asks the user if they want to load it. If so, loads the auto-recovery project.

bool OliveGlobal::CheckForActiveSequence ( bool  show_msg = true)
private

Returns whether a Sequence is currently active or not, and optionally displays a messagebox if not.

Checks whether a Sequence is active and can display a messagebox if not to inform users to make one active in order to perform said action.

Returns

TRUE if there is an active Sequence, FALSE if not.

void OliveGlobal::clear_undo_stack ( )
slot

Clears the current undo stack.

Clears all current commands in the undo stack. Mostly used for debugging.

void OliveGlobal::ClearProject ( )
private

Indiscriminately clear the project without prompting the user.

Will clear the entire project without prompting to save. This is dangerous, use new_project() instead for anything initiated by the user.

void OliveGlobal::finished_initialize ( )
slot

Function called when Olive has finished starting up.

Sets up some last things for Olive that must be run after Olive has completed initialization. If a project was loaded as a command line argument, it's loaded here.

const QString & OliveGlobal::get_project_file_filter ( )

Returns the file dialog filter used when interfacing with Olive project files.

Returns
The file filter string used by QFileDialog to limit the files shown to Olive (*.ove) files.
QString OliveGlobal::get_recent_project_list_file ( )

Retrieves the URL of the config file containing the autorecovery projects.

Returns
The URL as a string
void OliveGlobal::ImportProject ( const QString &  fn)
slot

Import project from file.

Imports an Olive project into the current project, effectively merging them.

Parameters
fnThe filename of the project to import.
bool OliveGlobal::is_modified ( )

Get application's current "modified" state.

Currently just a wrapper around MainWindow::isWindowModified(), but use this instead in case it changes. This value is used to determine whether the currently open project has unsaved changes.

Returns

TRUE if the project has been modified since the last save.

void OliveGlobal::load_project_on_launch ( const QString &  s)

Set a project to load just after launching.

Called by main() if Olive was called with a project file as a running argument. Sets up Olive to load the specified project once its finished initializing.

Parameters
sThe URL of the project file to load.
void OliveGlobal::load_translation_from_config ( )

(Re)load translation file from olive::config

void OliveGlobal::LoadProject ( const QString &  fn,
bool  autorecovery 
)
private

Create a LoadDialog and start a LoadThread to load data from a project.

Loads data from an Olive project file creating a LoadDialog to show visual information and a LoadThread to load outside of the main/GUI thread.

All project loading functions eventually lead to this one and there's no reason to use it directly. Instead use one of the following functions:

  • OpenProject() - to check if the current project can be closed and prompt the user for the new project file
  • OpenProjectWorker() - if you already have the filename and wish to close the current project and open it
  • ImportProject() - to import a project file into this one, effectively merging them both
Parameters
fnThe URL of the project file to open
autorecoveryTRUE if this file is an autorecovery file, in which case it's loaded slightly differently
clearTRUE if the current project should be closed before opening, FALSE if the project should be imported into the currently open one.
void OliveGlobal::new_project ( )
slot

Create new project.

Confirms whether the current project can be closed, and if so, clears all current project data and resets program state. Standard File > New behavior.

void OliveGlobal::open_about_dialog ( )
slot

Open the About Olive dialog.

void OliveGlobal::open_action_search ( )
slot

Open the Action Search overlay.

void OliveGlobal::open_autocut_silence_dialog ( )
slot

Open the auto-cut silence dialog.

void OliveGlobal::open_debug_log ( )
slot

Open the Debug Log window.

void OliveGlobal::open_export_dialog ( )
slot

Open the Export dialog to trigger an export of the current sequence.

void OliveGlobal::open_preferences ( )
slot

Opens the Preferences dialog.

void OliveGlobal::open_recent ( int  index)
slot

Open recent project from list.

Triggers a project load from the internal recent projects list.

Parameters
indexIndex in the list of the project file to load
void OliveGlobal::open_speed_dialog ( )
slot

Open the Speed/Duration dialog.

void OliveGlobal::OpenProject ( )
slot

Open a project from file.

Confirms whether the current project can be closed, and if so, shows an open file dialog to allow the user to select a project file and then triggers a project load with it.

void OliveGlobal::OpenProjectWorker ( QString  fn,
bool  autorecovery 
)
private

Internal function to handle loading a project from file.

Start loading a project. Doesn't check if the current project can be closed, doesn't check if the project exists. In most cases, you'll want open_project() to be end-user friendly.

Parameters
fnThe URL to the project to load.
autorecoveryWhether this file is an autorecovery file. If it is, after the load Olive will set the project URL to a new file beside the original project file so that it does not overwrite the original and so that the user is not working on the autorecovery project in Olive's application data directory.
void OliveGlobal::paste ( )
slot

Paste contents of clipboard.

Pastes contents of clipboard. Seeing as several types of data can be copied into the clipboard, this function will automatically determine what type of data is in the clipboard and paste it in the correct location (e.g. clip data will go to the Timeline, effect data will go to Effect Controls).

void OliveGlobal::paste_insert ( )
slot

Paste contents of clipboard, making space for it when possible.

Pastes contents of clipboard (same as paste()). If the clipboard contains clip data, the clips are cut at the current playhead and ripple forward to make space for the clips in the clipboard. Can be considered semi-non-destructive as a result (as opposed to paste() overwriting clips). If the clipboard contains effect data, the functionality is identical to paste().

void OliveGlobal::redo ( )
slot

Redo user's last action.

void OliveGlobal::save_autorecovery_file ( )
slot

Save an auto-recovery file of the current project.

Call this function to save the current state of the project as an auto-recovery project. Called regularly by autorecovery_timer.

bool OliveGlobal::save_project ( )
slot

Saves the current project to file.

If the project has been saved already, this function will overwrite the project file with the current project data. Calls save_project_as() if the file has not been saved before.

Returns
TRUE if the project has been saved before and was successfully overwritten. Otherwise returns the value of save_project_as(). Useful if the user closing an unsaved project, clicks "Yes" to save, we know if they actually saved or not and won't continue closing the project if they didn't.
bool OliveGlobal::save_project_as ( )
slot

Shows a save file dialog and saves the project as the resulting filename.

Shows a save file dialog for the user to save their current project as a different filename from the current one. Also triggered by save_project() if the file hasn't been saved yet.

Returns
TRUE if the user saved the project. FALSE if they cancelled out of the save file dialog. Useful if a user is closing an unsaved project, clicks "Yes" to save, we know if they actually saved or not and won't continue closing the project if they didn't.
void OliveGlobal::set_modified ( bool  modified)

Set the application's "modified" state.

Primarily controls whether the application prompts the user to save the project upon closing or not. Also technically controls whether to create autorecovery files as they'll only be generated if there are unsaved changes.

Parameters
modifiedTRUE if the project has been modified, FALSE if it has not.
void OliveGlobal::set_rendering_state ( bool  rendering)

Set the application state depending on if the user is exporting a video.

Some background functions shouldn't run while Olive is exporting a video. This function will disable/enable them as necessary.

The current functions are as follows:

  • Auto-recovery interval. Olive saves an auto-recovery just before exporting anyway and seeing as the user cannot make changes while rendering, there's no reason to continue saving auto-recovery files.
  • Audio device playback. Olive uses the same internal audio buffer for exporting as it does for playback, but this buffer does not need to be forwarded to the output device when exporting.
Parameters
renderingTRUE if Olive is about to export a video. FALSE if Olive has finished exporting.
void OliveGlobal::set_sequence ( SequencePtr  s)
slot

Set the current active Sequence.

Call this to change the active Sequence (e.g. when the user double clicks a Sequence in the Project panel). This will affect panel_timeline, panel_sequence_viewer, and panel_effect_controls and can then be retrieved using olive::ActiveSequence.

Parameters
sThe Sequence to set as the active Sequence.
void OliveGlobal::SetNativeStyling ( QWidget *  w)
static

Set native UI styling on a given widget.

Parameters
wThe widget to set styling on.
void OliveGlobal::undo ( )
slot

Undo user's last action.

void OliveGlobal::update_project_filename ( const QString &  s)

Change the current active project filename.

Triggered to change the current active project filename. Call this before calling any internal project saving or loading functions in order to set which file to work with (OliveGlobal::open_project() and OliveGlobal::save_project_as() do this automatically). Also updates the main window title to reflect the project filename.

Parameters
sThe URL of the project file to work with. Can be an empty string, in which case Olive will treat the project as an unsaved project.

Member Data Documentation

QTimer OliveGlobal::autorecovery_timer
private

Regular interval to save an auto-recovery project.

bool OliveGlobal::changed_since_last_autorecovery
private

Internal variable for whether the project has changed since the last autorecovery.

Set by set_modified(), which should be called alongside any change made to the project file and is "unset" when an autorecovery file is made. Provides an extra layer of abstraction from the application "modified" state to prevents an autorecovery file saving multiple times if the project hasn't actually changed since the last autorecovery, but still hasn't been saved into the original file yet.

bool OliveGlobal::enable_load_project_on_init
private

Internal variable set to TRUE by main() if a project file was set as an argument.

QString OliveGlobal::project_file_filter
private

File filter used for any file dialogs relating to Olive project files.

std::unique_ptr<QTranslator> OliveGlobal::translator
private

Internal translator object that interfaces with the currently loaded language file.


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