mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-06-30 21:36:33 -04:00
Merged in mmastriani/fractorium_michel (pull request #37)
Open Examples Feature
This commit is contained in:
@ -797,8 +797,9 @@ void Fractorium::SetFixedTableHeader(QHeaderView* header, QHeaderView::ResizeMod
|
||||
/// Setup and show the open XML dialog.
|
||||
/// This will perform lazy instantiation.
|
||||
/// </summary>
|
||||
/// <param name="openExamples">true to open files in examples folder</param>
|
||||
/// <returns>The list of filenames selected</returns>
|
||||
QStringList Fractorium::SetupOpenXmlDialog()
|
||||
QStringList Fractorium::SetupOpenXmlDialog(bool openExamples)
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
|
||||
@ -817,24 +818,47 @@ QStringList Fractorium::SetupOpenXmlDialog()
|
||||
}
|
||||
|
||||
QStringList filenames;
|
||||
m_OpenFileDialog->setDirectory(m_Settings->OpenFolder());
|
||||
m_OpenFileDialog->selectNameFilter(m_Settings->OpenXmlExt());
|
||||
|
||||
if(openExamples)
|
||||
{
|
||||
m_OpenFileDialog->selectFile("*");
|
||||
m_OpenFileDialog->setDirectory(QCoreApplication::applicationDirPath() + "/FlameExamples");
|
||||
m_OpenFileDialog->selectNameFilter("flame (*.flame)");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OpenFileDialog->setDirectory(m_Settings->OpenFolder());
|
||||
m_OpenFileDialog->selectNameFilter(m_Settings->OpenXmlExt());
|
||||
}
|
||||
|
||||
if (m_OpenFileDialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
filenames = m_OpenFileDialog->selectedFiles();
|
||||
|
||||
if (!filenames.empty())
|
||||
if (!openExamples && !filenames.empty())
|
||||
m_Settings->OpenFolder(QFileInfo(filenames[0]).canonicalPath());
|
||||
}
|
||||
else
|
||||
m_OpenFileDialog->selectFile("*");
|
||||
}
|
||||
|
||||
#else
|
||||
auto defaultFilter(m_Settings->OpenXmlExt());
|
||||
auto filenames = QFileDialog::getOpenFileNames(this, tr("Open Flame"), m_Settings->OpenFolder(), tr("flam3(*.flam3);; flame(*.flame);; xml(*.xml);; chaos (*.chaos)"), &defaultFilter);
|
||||
m_Settings->OpenXmlExt(defaultFilter);
|
||||
QString defaultFilter;
|
||||
QStringList filenames;
|
||||
|
||||
if (!filenames.empty())
|
||||
m_Settings->OpenFolder(QFileInfo(filenames[0]).canonicalPath());
|
||||
if(openExamples)
|
||||
{
|
||||
defaultFilter = "flame (*.flame)";
|
||||
filenames = QFileDialog::getOpenFileNames(this, tr("Open Flame"), QCoreApplication::applicationDirPath() + "/FlameExamples", tr("flame(*.flame)"), &defaultFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultFilter = m_Settings->OpenXmlExt();
|
||||
filenames = QFileDialog::getOpenFileNames(this, tr("Open Flame"), m_Settings->OpenFolder(), tr("flam3(*.flam3);; flame(*.flame);; xml(*.xml);; chaos (*.chaos)"), &defaultFilter);
|
||||
m_Settings->OpenXmlExt(defaultFilter);
|
||||
|
||||
if (!filenames.empty())
|
||||
m_Settings->OpenFolder(QFileInfo(filenames[0]).canonicalPath());
|
||||
}
|
||||
|
||||
#endif
|
||||
return filenames;
|
||||
|
@ -144,6 +144,7 @@ public slots:
|
||||
void OnActionCopyFlameInCurrentFile(bool checked);
|
||||
void OnActionCreateReferenceFile(bool checked);
|
||||
void OnActionOpen(bool checked);
|
||||
void OnActionOpenExamples(bool checked);
|
||||
void OnActionSaveCurrentAsXml(bool checked);
|
||||
void OnActionSaveEntireFileAsXml(bool checked);
|
||||
void OnActionSaveCurrentScreen(bool checked);
|
||||
@ -469,7 +470,7 @@ private:
|
||||
void EnableRenderControls(bool enable);
|
||||
|
||||
//Dialogs.
|
||||
QStringList SetupOpenXmlDialog();
|
||||
QStringList SetupOpenXmlDialog(bool openExamples = false);
|
||||
QString SetupSaveXmlDialog(const QString& defaultFilename);
|
||||
QString SetupSaveImageDialog(const QString& defaultFilename);
|
||||
QString SetupSaveFolderDialog();
|
||||
|
@ -7219,6 +7219,7 @@
|
||||
<addaction name="ActionCreateReferenceFile"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="ActionOpen"/>
|
||||
<addaction name="ActionOpenExamples"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="ActionSaveCurrentAsXml"/>
|
||||
<addaction name="ActionSaveEntireFileAsXml"/>
|
||||
@ -8165,6 +8166,18 @@
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="ActionOpenExamples">
|
||||
<property name="icon">
|
||||
<iconset resource="Fractorium.qrc">
|
||||
<normaloff>:/Fractorium/Icons/folder-visiting-4.png</normaloff>:/Fractorium/Icons/folder-visiting-4.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open Examples</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open Examples</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="ActionExit">
|
||||
<property name="icon">
|
||||
<iconset resource="Fractorium.qrc">
|
||||
|
@ -13,6 +13,7 @@ void Fractorium::InitMenusUI()
|
||||
connect(ui.ActionCopyFlameInCurrentFile, SIGNAL(triggered(bool)), this, SLOT(OnActionCopyFlameInCurrentFile(bool)), Qt::QueuedConnection);
|
||||
connect(ui.ActionCreateReferenceFile, SIGNAL(triggered(bool)), this, SLOT(OnActionCreateReferenceFile(bool)), Qt::QueuedConnection);
|
||||
connect(ui.ActionOpen, SIGNAL(triggered(bool)), this, SLOT(OnActionOpen(bool)), Qt::QueuedConnection);
|
||||
connect(ui.ActionOpenExamples, SIGNAL(triggered(bool)), this, SLOT(OnActionOpenExamples(bool)), Qt::QueuedConnection);
|
||||
connect(ui.ActionSaveCurrentAsXml, SIGNAL(triggered(bool)), this, SLOT(OnActionSaveCurrentAsXml(bool)), Qt::QueuedConnection);
|
||||
connect(ui.ActionSaveEntireFileAsXml, SIGNAL(triggered(bool)), this, SLOT(OnActionSaveEntireFileAsXml(bool)), Qt::QueuedConnection);
|
||||
connect(ui.ActionSaveCurrentScreen, SIGNAL(triggered(bool)), this, SLOT(OnActionSaveCurrentScreen(bool)), Qt::QueuedConnection);
|
||||
@ -370,6 +371,12 @@ void FractoriumEmberController<T>::OpenAndPrepFiles(const QStringList& filenames
|
||||
/// <param name="checked">Ignored</param>
|
||||
void Fractorium::OnActionOpen(bool checked) { m_Controller->OpenAndPrepFiles(SetupOpenXmlDialog(), false); }
|
||||
|
||||
/// <summary>
|
||||
/// Show a file open dialog to open examples Xml files.
|
||||
/// </summary>
|
||||
/// <param name="checked">Ignored</param>
|
||||
void Fractorium::OnActionOpenExamples(bool checked) { m_Controller->OpenAndPrepFiles(SetupOpenXmlDialog(true), false); }
|
||||
|
||||
/// <summary>
|
||||
/// Save current ember as Xml, using the Xml saving template values from the options.
|
||||
/// This will first save the current ember back to the opened file in memory before
|
||||
|
Reference in New Issue
Block a user