switched global to unique ptr and renamed olive namespace
This commit is contained in:
+38
-38
@@ -43,9 +43,9 @@
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
|
||||
QSharedPointer<OliveGlobal> Olive::Global;
|
||||
QString Olive::ActiveProjectFilename;
|
||||
QString Olive::AppName;
|
||||
std::unique_ptr<OliveGlobal> olive::Global;
|
||||
QString olive::ActiveProjectFilename;
|
||||
QString olive::AppName;
|
||||
|
||||
OliveGlobal::OliveGlobal() {
|
||||
// sets current app name
|
||||
@@ -53,7 +53,7 @@ OliveGlobal::OliveGlobal() {
|
||||
#ifdef GITHASH
|
||||
version_id = QString(" | %1").arg(GITHASH);
|
||||
#endif
|
||||
Olive::AppName = QString("Olive (February 2019 | Alpha%1)").arg(version_id);
|
||||
olive::AppName = QString("Olive (February 2019 | Alpha%1)").arg(version_id);
|
||||
|
||||
// set the file filter used in all file dialogs pertaining to Olive project files.
|
||||
project_file_filter = tr("Olive Project %1").arg("(*.ove)");
|
||||
@@ -68,10 +68,10 @@ const QString &OliveGlobal::get_project_file_filter() {
|
||||
|
||||
void OliveGlobal::update_project_filename(const QString &s) {
|
||||
// set filename to s
|
||||
Olive::ActiveProjectFilename = s;
|
||||
olive::ActiveProjectFilename = s;
|
||||
|
||||
// update main window title to reflect new project filename
|
||||
Olive::MainWindow->updateTitle();
|
||||
olive::MainWindow->updateTitle();
|
||||
}
|
||||
|
||||
void OliveGlobal::check_for_autorecovery_file() {
|
||||
@@ -101,7 +101,7 @@ void OliveGlobal::set_rendering_state(bool rendering) {
|
||||
}
|
||||
|
||||
void OliveGlobal::load_project_on_launch(const QString& s) {
|
||||
Olive::ActiveProjectFilename = s;
|
||||
olive::ActiveProjectFilename = s;
|
||||
enable_load_project_on_init = true;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ void OliveGlobal::new_project() {
|
||||
panel_project->new_project();
|
||||
|
||||
// clear undo stack
|
||||
Olive::UndoStack.clear();
|
||||
olive::UndoStack.clear();
|
||||
|
||||
// empty current project filename
|
||||
update_project_filename("");
|
||||
@@ -129,7 +129,7 @@ void OliveGlobal::new_project() {
|
||||
}
|
||||
|
||||
void OliveGlobal::open_project() {
|
||||
QString fn = QFileDialog::getOpenFileName(Olive::MainWindow, tr("Open Project..."), "", project_file_filter);
|
||||
QString fn = QFileDialog::getOpenFileName(olive::MainWindow, tr("Open Project..."), "", project_file_filter);
|
||||
if (!fn.isEmpty() && can_close_project()) {
|
||||
open_project_worker(fn, false);
|
||||
}
|
||||
@@ -139,20 +139,20 @@ void OliveGlobal::open_recent(int index) {
|
||||
QString recent_url = recent_projects.at(index);
|
||||
if (!QFile::exists(recent_url)) {
|
||||
if (QMessageBox::question(
|
||||
Olive::MainWindow,
|
||||
olive::MainWindow,
|
||||
tr("Missing recent project"),
|
||||
tr("The project '%1' no longer exists. Would you like to remove it from the recent projects list?").arg(recent_url),
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
recent_projects.removeAt(index);
|
||||
panel_project->save_recent_projects();
|
||||
}
|
||||
} else if (Olive::Global.data()->can_close_project()) {
|
||||
} else if (can_close_project()) {
|
||||
open_project_worker(recent_url, false);
|
||||
}
|
||||
}
|
||||
|
||||
bool OliveGlobal::save_project_as() {
|
||||
QString fn = QFileDialog::getSaveFileName(Olive::MainWindow, tr("Save Project As..."), "", project_file_filter);
|
||||
QString fn = QFileDialog::getSaveFileName(olive::MainWindow, tr("Save Project As..."), "", project_file_filter);
|
||||
if (!fn.isEmpty()) {
|
||||
if (!fn.endsWith(".ove", Qt::CaseInsensitive)) {
|
||||
fn += ".ove";
|
||||
@@ -165,7 +165,7 @@ bool OliveGlobal::save_project_as() {
|
||||
}
|
||||
|
||||
bool OliveGlobal::save_project() {
|
||||
if (Olive::ActiveProjectFilename.isEmpty()) {
|
||||
if (olive::ActiveProjectFilename.isEmpty()) {
|
||||
return save_project_as();
|
||||
} else {
|
||||
panel_project->save_project(false);
|
||||
@@ -174,13 +174,13 @@ bool OliveGlobal::save_project() {
|
||||
}
|
||||
|
||||
bool OliveGlobal::can_close_project() {
|
||||
if (Olive::MainWindow->isWindowModified()) {
|
||||
if (olive::MainWindow->isWindowModified()) {
|
||||
QMessageBox* m = new QMessageBox(
|
||||
QMessageBox::Question,
|
||||
tr("Unsaved Project"),
|
||||
tr("This project has changed since it was last saved. Would you like to save it before closing?"),
|
||||
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,
|
||||
Olive::MainWindow
|
||||
olive::MainWindow
|
||||
);
|
||||
m->setWindowModality(Qt::WindowModal);
|
||||
int r = m->exec();
|
||||
@@ -195,13 +195,13 @@ bool OliveGlobal::can_close_project() {
|
||||
}
|
||||
|
||||
void OliveGlobal::open_export_dialog() {
|
||||
if (Olive::ActiveSequence == nullptr) {
|
||||
QMessageBox::information(Olive::MainWindow,
|
||||
if (olive::ActiveSequence == nullptr) {
|
||||
QMessageBox::information(olive::MainWindow,
|
||||
tr("No active sequence"),
|
||||
tr("Please open the sequence you wish to export."),
|
||||
QMessageBox::Ok);
|
||||
} else {
|
||||
ExportDialog e(Olive::MainWindow);
|
||||
ExportDialog e(olive::MainWindow);
|
||||
e.exec();
|
||||
}
|
||||
}
|
||||
@@ -210,12 +210,12 @@ void OliveGlobal::finished_initialize() {
|
||||
if (enable_load_project_on_init) {
|
||||
|
||||
// if a project was set as a command line argument, we load it here
|
||||
if (QFileInfo::exists(Olive::ActiveProjectFilename)) {
|
||||
open_project_worker(Olive::ActiveProjectFilename, false);
|
||||
if (QFileInfo::exists(olive::ActiveProjectFilename)) {
|
||||
open_project_worker(olive::ActiveProjectFilename, false);
|
||||
} else {
|
||||
QMessageBox::critical(Olive::MainWindow,
|
||||
QMessageBox::critical(olive::MainWindow,
|
||||
tr("Missing Project File"),
|
||||
tr("Specified project '%1' does not exist.").arg(Olive::ActiveProjectFilename),
|
||||
tr("Specified project '%1' does not exist.").arg(olive::ActiveProjectFilename),
|
||||
QMessageBox::Ok);
|
||||
update_project_filename(nullptr);
|
||||
}
|
||||
@@ -233,7 +233,7 @@ void OliveGlobal::finished_initialize() {
|
||||
}
|
||||
|
||||
void OliveGlobal::save_autorecovery_file() {
|
||||
if (Olive::MainWindow->isWindowModified()) {
|
||||
if (olive::MainWindow->isWindowModified()) {
|
||||
panel_project->save_project(true);
|
||||
qInfo() << "Auto-recovery project saved";
|
||||
}
|
||||
@@ -243,21 +243,21 @@ void OliveGlobal::open_preferences() {
|
||||
panel_sequence_viewer->pause();
|
||||
panel_footage_viewer->pause();
|
||||
|
||||
PreferencesDialog pd(Olive::MainWindow);
|
||||
pd.setup_kbd_shortcuts(Olive::MainWindow->menuBar());
|
||||
PreferencesDialog pd(olive::MainWindow);
|
||||
pd.setup_kbd_shortcuts(olive::MainWindow->menuBar());
|
||||
pd.exec();
|
||||
}
|
||||
|
||||
void OliveGlobal::open_project_worker(const QString& fn, bool autorecovery) {
|
||||
update_project_filename(fn);
|
||||
panel_project->load_project(autorecovery);
|
||||
Olive::UndoStack.clear();
|
||||
olive::UndoStack.clear();
|
||||
}
|
||||
|
||||
void OliveGlobal::undo() {
|
||||
// workaround to prevent crash (and also users should never need to do this)
|
||||
if (!panel_timeline->importing) {
|
||||
Olive::UndoStack.undo();
|
||||
olive::UndoStack.undo();
|
||||
update_ui(true);
|
||||
}
|
||||
}
|
||||
@@ -265,37 +265,37 @@ void OliveGlobal::undo() {
|
||||
void OliveGlobal::redo() {
|
||||
// workaround to prevent crash (and also users should never need to do this)
|
||||
if (!panel_timeline->importing) {
|
||||
Olive::UndoStack.redo();
|
||||
olive::UndoStack.redo();
|
||||
update_ui(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OliveGlobal::paste() {
|
||||
if (Olive::ActiveSequence != nullptr) {
|
||||
if (olive::ActiveSequence != nullptr) {
|
||||
panel_timeline->paste(false);
|
||||
}
|
||||
}
|
||||
|
||||
void OliveGlobal::paste_insert() {
|
||||
if (Olive::ActiveSequence != nullptr) {
|
||||
if (olive::ActiveSequence != nullptr) {
|
||||
panel_timeline->paste(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OliveGlobal::open_about_dialog() {
|
||||
AboutDialog a(Olive::MainWindow);
|
||||
AboutDialog a(olive::MainWindow);
|
||||
a.exec();
|
||||
}
|
||||
|
||||
void OliveGlobal::open_debug_log() {
|
||||
Olive::DebugDialog->show();
|
||||
olive::DebugDialog->show();
|
||||
}
|
||||
|
||||
void OliveGlobal::open_speed_dialog() {
|
||||
if (Olive::ActiveSequence != nullptr) {
|
||||
SpeedDialog s(Olive::MainWindow);
|
||||
for (int i=0;i<Olive::ActiveSequence->clips.size();i++) {
|
||||
Clip* c = Olive::ActiveSequence->clips.at(i);
|
||||
if (olive::ActiveSequence != nullptr) {
|
||||
SpeedDialog s(olive::MainWindow);
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
Clip* c = olive::ActiveSequence->clips.at(i);
|
||||
if (c != nullptr && is_clip_selected(c, true)) {
|
||||
s.clips.append(c);
|
||||
}
|
||||
@@ -305,10 +305,10 @@ void OliveGlobal::open_speed_dialog() {
|
||||
}
|
||||
|
||||
void OliveGlobal::clear_undo_stack() {
|
||||
Olive::UndoStack.clear();
|
||||
olive::UndoStack.clear();
|
||||
}
|
||||
|
||||
void OliveGlobal::open_action_search() {
|
||||
ActionSearch as(Olive::MainWindow);
|
||||
ActionSearch as(olive::MainWindow);
|
||||
as.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user