Esempio n. 1
0
void About::aboutInit()
{
  setModal(true);
  resize(400, 400);
  setWindowTitle("About");
  setWindowIcon(QIcon("icons/backupsoft.png"));

  QWidget *icon = new QWidget(this);
  icon->setStyleSheet("background-image: url(icons/backupsoft.png)");
  icon->setGeometry(250 , 10, 100, 100);

  QLabel *title = new QLabel("BackupSoft", this);
  title->setFont(QFont("Helvetica", 25, 10, false));
  title->setGeometry(10, 10, 200, 30);

  QLabel *version = new QLabel("Copyright 2010 by\nMichael Kohler and Fabian Gammenthaler\n\nVersion: 1.0", this);
  version->setFont(QFont("Helvetica", 8, 2, false));
  version->setGeometry(10, 70, 200, 55);

  QTextEdit *licence = new QTextEdit(this);
  licence->setGeometry(10, 160, 380, 230);
  licence->setReadOnly(true);

  QFile *file = new QFile("licence.txt");
  if (file->open(QIODevice::ReadOnly)) {
    QTextStream *stream = new QTextStream(file);
    licence->setText(stream->readAll());
  }
  else {
    QString errorMsg = "Could not open licence.txt.. Please make sure it is existent and readable.";
    AlertWindow *alertWin = new AlertWindow("ERROR", "", errorMsg);
    alertWin->show();
  }
}
Esempio n. 2
0
QStringList* Helper::readFile(QString aFileName)
{
  // read the data line by line
  QFile *file = new QFile(aFileName);
  QStringList *data = new QStringList();
  if (file->open(QIODevice::ReadOnly) ) {
    // file opened successfully
    QTextStream *tstream = new QTextStream(file);
    while (!tstream->atEnd()) {
      data->append(tstream->readLine());
    }
    file->close();

    // ignore whitespaces
    for (int i = 0; i < data->length(); i++) {
      if (data->value(i) == "") {
        data->removeAt(i);
      }
    }
  }
  else {
    QString msg = tr("Could not open %1.. Please make sure it is existent and readable.").arg(aFileName);
    AlertWindow *alertWin = new AlertWindow("ERROR", msg);
    alertWin->show();
  }

  return data;
}
Esempio n. 3
0
void Gsp1101::run()
{
    double prog = 0.0;
    AlertWindow* alertWindow;

    {
        const MessageManagerLock mml ;//(Thread::getCurrentThread());
        alertWindow = LookAndFeel::getDefaultLookAndFeel()
                      .createAlertWindow ("title", String::empty, String::empty,
                                          String::empty, String::empty,
                                          AlertWindow::NoIcon, 0, 0);
        alertWindow->addProgressBarComponent (prog);
        alertWindow->setMessage ("foo");
        alertWindow->setVisible (true);
    }
    while (!threadShouldExit() && lastMidiInput_M.getSize() < 1)
    {
        wait(200);
        const MessageManagerLock mml (Thread::getCurrentThread());
        if (! mml.lockWasGained())  // if something is trying to kill this job, the lock
            return;                 // will fail, in which case we'd better return..

        prog = (prog > 1.0) ? 0.0 : prog + 0.1;

        yield();
        //Thread::sleep(200);
    }
    const MessageManagerLock mml (Thread::getCurrentThread());
    alertWindow->setVisible (false);
}
void ProfileManager::saveProfiles()
{
  QString name = nameField->text();
  QString src = sourceField->text();
  QString dest = destinationField->text();
  QString state = tr("Deactivated");
  if (stateBox->checkState()) {
    state = tr("Activated");
  }
  // Check wether directory even exists
  QDir *srcDir = new QDir(src);
  QDir *destDir = new QDir(dest);
  if (srcDir->exists() && destDir->exists()) {
    QString dataString = "\n" + name + "|" + src + "|" + dest + "|" + state;
    if(origin == 1) {
      QByteArray dataBA = dataString.toLatin1();
      helper->writeFile("profile.bs", true, dataBA);
    }
    if(origin == 2) {
      QString oldProfile;
      for(int i = 0; i < 4; i++) {
        oldProfile.append(extractedInfo.value(i));
        if(i != 3)
          oldProfile.append('|');
      }
      helper->overwriteFile("profile.bs", oldProfile, true, dataString);
    }
    this->close();
  }
  else {
    QString msg = tr("Either the source or the destination path doesn't exist. Please file it accordingly or create the needed directories.");
    AlertWindow *alertDoesntExist = new AlertWindow("ERROR", msg);
    alertDoesntExist->show();
  }
}
Esempio n. 5
0
void Helper::overwriteFile(QString aFileName, QString aProfile, bool aAppend, QString aData)
{
  QStringList *fileData;
  QString data, temp;
  QFile file(aFileName);
  int index;
  bool success;
  fileData = readFile(aFileName);
  for(int i = 0; i < fileData->length(); i++) {
    temp = fileData->value(i);
    if(temp == aProfile) {
      index = i;
      break;
    }
  }
  file.open(QIODevice::WriteOnly);
  success = file.remove();
  if(success) {
    fileData->replace(index, aData);
    for(int i = 0; i < fileData->length(); i++) {
      data = fileData->value(i) + "\n";
      writeFile(aFileName, aAppend, data.toLatin1());
    }
    file.close();
  }
  else {
    QString msg = tr("An error occured while overwriting the configuration file. We are sorry for the inconvenience.");
    AlertWindow *alertWin = new AlertWindow("ERROR", msg);
    alertWin->show();
  }
}
    void createNewFile (Project::Item parent)
    {
        for (;;)
        {
            AlertWindow aw (TRANS ("Create new Component class"),
                            TRANS ("Please enter the name for the new class"),
                            AlertWindow::NoIcon, nullptr);

            aw.addTextEditor (getClassNameFieldName(), String::empty, String::empty, false);
            aw.addButton (TRANS ("Create Files"),  1, KeyPress (KeyPress::returnKey));
            aw.addButton (TRANS ("Cancel"),        0, KeyPress (KeyPress::escapeKey));

            if (aw.runModalLoop() == 0)
                break;

            const String className (aw.getTextEditorContents (getClassNameFieldName()).trim());

            if (className == CodeHelpers::makeValidIdentifier (className, false, true, false))
            {
                const File newFile (askUserToChooseNewFile (className + ".h", "*.h;*.cpp", parent));

                if (newFile != File::nonexistent)
                    createFiles (parent, className, newFile);

                break;
            }
        }
    }
void CabbageIDELookAndFeel::drawAlertBox (Graphics& g,
                                          AlertWindow& alert,
                                          const Rectangle<int>& textArea,
                                          TextLayout& textLayout)
{
    g.fillAll (CabbageSettings::getColourFromValueTree (colourTree, CabbageColourIds::alertWindowBackground, Colour (Colour::fromString("2ff52636a"))));

    int iconSpaceUsed = 160;

    if (alert.getAlertType() != AlertWindow::NoIcon)
    {
        Path icon;

        if (alert.getAlertType() == AlertWindow::WarningIcon)
        {
            Rectangle<float> rect (alert.getLocalBounds().removeFromLeft (iconSpaceUsed).toFloat());

            const Image warningImage = ImageCache::getFromMemory (CabbageBinaryData::WarningIcon_png, CabbageBinaryData::WarningIcon_pngSize);
            //g.drawImage(warningImage, rect.reduced(20));
        }

        if (alert.getAlertType() == AlertWindow::QuestionIcon)
        {
            Rectangle<float> rect (alert.getLocalBounds().removeFromLeft (iconSpaceUsed - 20).toFloat());
            const Image warningImage = ImageCache::getFromMemory (CabbageBinaryData::WarningIcon_png, CabbageBinaryData::WarningIcon_pngSize);
            //g.drawImage(warningImage, rect.reduced(25));
        }

        MemoryInputStream svgStream (CabbageBinaryData::processstop_svg, CabbageBinaryData::processstop_svgSize, false);
        ScopedPointer<XmlElement> svg (XmlDocument::parse (svgStream.readString()));

        if (svg == nullptr)
            jassert (false);

        ScopedPointer<Drawable> drawable;

        if (svg != nullptr)
        {
            drawable = Drawable::createFromSVG (*svg);
            Rectangle<float> rect (20, 20, 80, 80);//alert.getLocalBounds().removeFromLeft (iconSpaceUsed - 20).withHeight(130).toFloat());
            drawable->setTransformToFit (rect, RectanglePlacement::stretchToFit);
            drawable->draw (g, 1.f, AffineTransform());
        }
    }


    g.setColour (alert.findColour (AlertWindow::textColourId));
    textLayout.draw (g, Rectangle<int> (textArea.getX() + iconSpaceUsed - 50,
                                        textArea.getY(),
                                        textArea.getWidth() - iconSpaceUsed - 40,
                                        textArea.getHeight()).toFloat());

    g.setColour (alert.findColour (AlertWindow::outlineColourId));
    g.drawRect (0, 0, alert.getWidth(), alert.getHeight());
}
Esempio n. 8
0
void Helper::writeFile(QString aFileName, bool aAppend, QByteArray aData)
{
  QFile file(aFileName);
  bool success;
  if (aAppend)
    success = file.open(QIODevice::WriteOnly | QIODevice::Append);
  else
    success = file.open(QIODevice::WriteOnly);

  if (success) {
    file.write(aData);
    file.close();
  }
  else {
    QString msg = tr("Could not open %1.. Please make sure it is existent and readable.").arg(aFileName);
    AlertWindow *alertWin = new AlertWindow("ERROR", msg);
    alertWin->show();
  }
}
void FileChooserDialogBox::createNewFolder()
{
    File parent (content->chooserComponent.getRoot());

    if (parent.isDirectory())
    {
        AlertWindow* aw = new AlertWindow (TRANS("New Folder"),
                                           TRANS("Please enter the name for the folder"),
                                           AlertWindow::NoIcon, this);

        aw->addTextEditor ("name", String::empty, String::empty, false);
        aw->addButton (TRANS("ok"), 1, KeyPress::returnKey);
        aw->addButton (TRANS("cancel"), KeyPress::escapeKey);

        aw->enterModalState (true,
                             ModalCallbackFunction::forComponent (createNewFolderCallback, this,
                                                                  Component::SafePointer<AlertWindow> (aw)),
                             true);
    }
}
Esempio n. 10
0
    AlertTextComp (AlertWindow& owner, const String& message, const Font& font)
    {
        setReadOnly (true);
        setMultiLine (true, true);
        setCaretVisible (false);
        setScrollbarsShown (true);
        lookAndFeelChanged();
        setWantsKeyboardFocus (false);

        setFont (font);
        setText (message, false);

        bestWidth = 2 * (int) std::sqrt (font.getHeight() * font.getStringWidth (message));

        if (owner.isColourSpecified (AlertWindow::textColourId))
            setColour (TextEditor::textColourId, owner.findColour (AlertWindow::textColourId));

        setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
        setColour (TextEditor::outlineColourId, Colours::transparentBlack);
        setColour (TextEditor::shadowColourId, Colours::transparentBlack);
    }
Esempio n. 11
0
void PluginListComponent::scanFor (AudioPluginFormat* format)
{
    if (format != nullptr)
    {
        FileSearchPath path (format->getDefaultLocationsToSearch());

        if (path.getNumPaths() > 0) // if the path is empty, then paths aren't used for this format.
        {
           #if JUCE_MODAL_LOOPS_PERMITTED
            if (propertiesToUse != nullptr)
                path = propertiesToUse->getValue ("lastPluginScanPath_" + format->getName(), path.toString());

            AlertWindow aw (TRANS("Select folders to scan..."), String::empty, AlertWindow::NoIcon);
            FileSearchPathListComponent pathList;
            pathList.setSize (500, 300);
            pathList.setPath (path);

            aw.addCustomComponent (&pathList);
            aw.addButton (TRANS("Scan"), 1, KeyPress (KeyPress::returnKey));
            aw.addButton (TRANS("Cancel"), 0, KeyPress (KeyPress::escapeKey));

            if (aw.runModalLoop() == 0)
                return;

            path = pathList.getPath();
           #else
            jassertfalse; // XXX this method needs refactoring to work without modal loops..
           #endif
        }

        if (propertiesToUse != nullptr)
        {
            propertiesToUse->setValue ("lastPluginScanPath_" + format->getName(), path.toString());
            propertiesToUse->saveIfNeeded();
        }

        currentScanner = new Scanner (*this, *format, path);
    }
}
Esempio n. 12
0
void Helper::deleteProfile(QString aFileName, QString aProfile)
{
  QStringList *fileData;
  QString data, temp;
  QFile file(aFileName);
  int index;
  bool success;
  bool aAppend = true;
  fileData = readFile(aFileName);
  for(int i = 0; i < fileData->length(); i++) {
    temp = fileData->value(i);
    if(temp == aProfile) {
      index = i;
      break;
    }
  }
  file.open(QIODevice::WriteOnly);
  success = file.remove();
  if(success) {
    fileData->removeAt(index);
    if (fileData->length() == 0) {
      writeFile(aFileName, aAppend, data.toLatin1());
    }
    else {
      for(int i = 0; i < fileData->length(); i++) {
        data = fileData->value(i);
        data.append("\n");
        writeFile(aFileName, aAppend, data.toLatin1());
      }
    }
    file.close();
  }
  else {
    QString msg = tr("Error while overwriting the file. Please try again.");
    AlertWindow *alertWin = new AlertWindow("ERROR", msg);
    alertWin->show();
  }
}
Esempio n. 13
0
void CtrlrLuaMethodEditor::renameGroup(ValueTree parentGroup)
{
	AlertWindow w ("Rename group", "", AlertWindow::QuestionIcon, this);
	w.addTextEditor("name", parentGroup.getProperty (Ids::name).toString());
	w.addButton ("OK", 1, KeyPress(KeyPress::returnKey));
	w.addButton ("Cancel", 0, KeyPress(KeyPress::escapeKey));

	if (w.runModalLoop())
	{
		parentGroup.setProperty (Ids::name, w.getTextEditorContents("name"), nullptr);
		updateRootItem();
	}

	saveSettings(); // save settings
}
Esempio n. 14
0
void EdoTabs::popupMenuClickOnTab (const int tabIndex, const String &tabName)
{
	PopupMenu menu;
	menu.addItem (1, T("Rename tab"));
	menu.addItem (2, T("Close tab"));

	const int ret = menu.show();

	if (ret == 1)
	{
		AlertWindow alert (T("New tab name"), T("Set the new tab name"), AlertWindow::InfoIcon);
		alert.addTextEditor (T("edoTabName"), tabName, T("New tab name"), false);
		alert.addButton (T("OK"), 1, KeyPress (KeyPress::returnKey));
		alert.addButton (T("Cancel"), 2);
		const int ret = alert.runModalLoop();
		if (ret == 2)
		{
			return;
		}
		else
		{
			const String newName = alert.getTextEditorContents(EDO_COMPONENT_NAME);
			Component *edoComponent = dynamic_cast<Component*>(getTabContentComponent (tabIndex));
			if (edoComponent!=0)
			{
				edoComponent->setName (newName);
			}

			setTabName (tabIndex, newName);
		}
	}
	if (ret == 2)
	{
		removeTab (tabIndex);
	}
}
Esempio n. 15
0
    void showWindow (Component& button, DialogType type)
    {
        if (type >= plainAlertWindow && type <= questionAlertWindow)
        {
            AlertWindow::AlertIconType icon = AlertWindow::NoIcon;

            switch (type)
            {
                case warningAlertWindow:    icon = AlertWindow::WarningIcon;    break;
                case infoAlertWindow:       icon = AlertWindow::InfoIcon;       break;
                case questionAlertWindow:   icon = AlertWindow::QuestionIcon;   break;
                default: break;
            }

            AlertWindow::showMessageBoxAsync (icon,
                                              "This is an AlertWindow",
                                              "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
                                              "ok");
        }
        else if (type == okCancelAlertWindow)
        {
            AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon,
                                          "This is an ok/cancel AlertWindow",
                                          "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
                                          String::empty,
                                          String::empty,
                                          0,
                                          ModalCallbackFunction::forComponent (alertBoxResultChosen, this));
        }
        else if (type == calloutBoxWindow)
        {
            ColourSelector* colourSelector = new ColourSelector();
            colourSelector->setName ("background");
            colourSelector->setCurrentColour (findColour (TextButton::buttonColourId));
            colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
            colourSelector->setSize (300, 400);

            CallOutBox::launchAsynchronously (colourSelector, button.getScreenBounds(), nullptr);
        }
        else if (type == extraComponentsAlertWindow)
        {
           #if JUCE_MODAL_LOOPS_PERMITTED
            AlertWindow w ("AlertWindow demo..",
                           "This AlertWindow has a couple of extra components added to show how to add drop-down lists and text entry boxes.",
                           AlertWindow::QuestionIcon);

            w.addTextEditor ("text", "enter some text here", "text field:");

            const char* options[] = { "option 1", "option 2", "option 3", "option 4", nullptr };
            w.addComboBox ("option", StringArray (options), "some options");

            w.addButton ("ok",     1, KeyPress (KeyPress::returnKey, 0, 0));
            w.addButton ("cancel", 0, KeyPress (KeyPress::escapeKey, 0, 0));

            if (w.runModalLoop() != 0) // is they picked 'ok'
            {
                // this is the item they chose in the drop-down list..
                const int optionIndexChosen = w.getComboBoxComponent ("option")->getSelectedItemIndex();
                (void) optionIndexChosen; // (just avoids a compiler warning about unused variables)


                // this is the text they entered..
                String text = w.getTextEditorContents ("text");
            }
           #endif
        }
        else if (type == progressWindow)
        {
            // This will launch our ThreadWithProgressWindow in a modal state. (Our subclass
            // will take care of deleting the object when the task has finished)
            (new DemoBackgroundThread())->launchThread();
        }
        else if (type >= loadChooser && type <= saveChooser)
        {
           #if JUCE_MODAL_LOOPS_PERMITTED
            const bool useNativeVersion = nativeButton.getToggleState();

            if (type == loadChooser)
            {
                FileChooser fc ("Choose a file to open...",
                                File::getCurrentWorkingDirectory(),
                                "*",
                                useNativeVersion);

                if (fc.browseForMultipleFilesToOpen())
                {
                    String chosen;
                    for (int i = 0; i < fc.getResults().size(); ++i)
                        chosen << fc.getResults().getReference(i).getFullPathName() << "\n";

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosen);
                }
            }
            else if (type == loadWithPreviewChooser)
            {
                ImagePreviewComponent imagePreview;
                imagePreview.setSize (200, 200);

                FileChooser fc ("Choose an image to open...",
                                File::getSpecialLocation (File::userPicturesDirectory),
                                "*.jpg;*.jpeg;*.png;*.gif",
                                useNativeVersion);

                if (fc.browseForMultipleFilesToOpen (&imagePreview))
                {
                    String chosen;
                    for (int i = 0; i < fc.getResults().size(); ++i)
                        chosen << fc.getResults().getReference (i).getFullPathName() << "\n";

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosen);
                }
            }
            else if (type == saveChooser)
            {
                FileChooser fc ("Choose a file to save...",
                                File::getCurrentWorkingDirectory(),
                                "*",
                                useNativeVersion);

                if (fc.browseForFileToSave (true))
                {
                    File chosenFile = fc.getResult();

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosenFile.getFullPathName());
                }
            }
            else if (type == directoryChooser)
            {
                FileChooser fc ("Choose a directory...",
                                File::getCurrentWorkingDirectory(),
                                "*",
                                useNativeVersion);

                if (fc.browseForDirectory())
                {
                    File chosenDirectory = fc.getResult();

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosenDirectory.getFullPathName());
                }
            }
           #endif
        }
    }
void PluginListComponent::scanFor (AudioPluginFormat* format)
{
#if JUCE_MODAL_LOOPS_PERMITTED
    if (format == nullptr)
        return;

    FileSearchPath path (format->getDefaultLocationsToSearch());

    if (propertiesToUse != nullptr)
        path = propertiesToUse->getValue ("lastPluginScanPath_" + format->getName(), path.toString());

    {
        AlertWindow aw (TRANS("Select folders to scan..."), String::empty, AlertWindow::NoIcon);
        FileSearchPathListComponent pathList;
        pathList.setSize (500, 300);
        pathList.setPath (path);

        aw.addCustomComponent (&pathList);
        aw.addButton (TRANS("Scan"), 1, KeyPress::returnKey);
        aw.addButton (TRANS("Cancel"), 0, KeyPress::escapeKey);

        if (aw.runModalLoop() == 0)
            return;

        path = pathList.getPath();
    }

    if (propertiesToUse != nullptr)
    {
        propertiesToUse->setValue ("lastPluginScanPath_" + format->getName(), path.toString());
        propertiesToUse->saveIfNeeded();
    }

    double progress = 0.0;

    AlertWindow aw (TRANS("Scanning for plugins..."),
                    TRANS("Searching for all possible plugin files..."), AlertWindow::NoIcon);

    aw.addButton (TRANS("Cancel"), 0, KeyPress::escapeKey);
    aw.addProgressBarComponent (progress);
    aw.enterModalState();

    MessageManager::getInstance()->runDispatchLoopUntil (300);

    PluginDirectoryScanner scanner (list, *format, path, true, deadMansPedalFile);

    for (;;)
    {
        aw.setMessage (TRANS("Testing:\n\n") + scanner.getNextPluginFileThatWillBeScanned());

        MessageManager::getInstance()->runDispatchLoopUntil (100);

        if (! scanner.scanNextFile (true))
            break;

        if (! aw.isCurrentlyModal())
            break;

        progress = scanner.getProgress();
    }

    if (scanner.getFailedFiles().size() > 0)
    {
        StringArray shortNames;

        for (int i = 0; i < scanner.getFailedFiles().size(); ++i)
            shortNames.add (File (scanner.getFailedFiles()[i]).getFileName());

        AlertWindow::showMessageBox (AlertWindow::InfoIcon,
                                     TRANS("Scan complete"),
                                     TRANS("Note that the following files appeared to be plugin files, but failed to load correctly:\n\n")
                                        + shortNames.joinIntoString (", "));
    }
#else
    jassertfalse; // this method needs refactoring to work without modal loops..
#endif
}
Esempio n. 17
0
//===============================================================================
void CabbageFileButton::buttonClicked (Button* button)
{
    if (mode == "file")
    {
        const String lastKnownDirectory = owner->getLastOpenedDirectory();
        FileChooser fc ("Choose File", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getParentDirectory() : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser());

        if (fc.browseForFileToOpen())
        {
            owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult()));
            CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult()));
            //owner->refreshComboBoxContents();
        }

        owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName());
    }

    else if (mode == "save")
    {
        const String lastKnownDirectory = owner->getLastOpenedDirectory();
        FileChooser fc ("Choose File", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getParentDirectory() : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser());

        if (fc.browseForFileToSave(true))
        {
            owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult()));
            CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult()));
            //owner->refreshComboBoxContents();
        }

        owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName());
		owner->refreshComboListBoxContents();
        startTimer(500);
    }

    else if (mode == "directory")
    {
        const String lastKnownDirectory = owner->getLastOpenedDirectory();
        FileChooser fc ("Open Directory", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getChildFile (getFilename()) : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser());

        if (fc.browseForDirectory())
        {
            owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult()));
            CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult()));
        }

        owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName());
        
    }

    else if (mode == "snapshot")
    {
        String newFileName;
        if (owner->isAudioUnit())
            newFileName = File(getCsdFile()).withFileExtension(".snaps").getFullPathName();
        else
            newFileName = owner->createNewGenericNameForPresetFile();
        
        owner->sendChannelStringDataToCsound (getChannel(), newFileName);
        owner->savePluginStateToFile (File (newFileName));
        owner->refreshComboListBoxContents();
    }
    
    else if (mode == "named snapshot")
    {
        String newFileName;
        if (owner->isAudioUnit())
            newFileName = File(getCsdFile()).withFileExtension(".snaps").getFullPathName();
        else
            newFileName = owner->createNewGenericNameForPresetFile();
        
        
#if JUCE_MODAL_LOOPS_PERMITTED
        String presetname;
        AlertWindow w ("Preset",
                       "Set preset name (warning, will overwrite previous preset of same name)",
                       AlertWindow::NoIcon);
        w.setLookAndFeel(&getLookAndFeel());
        w.setSize(100, 100);
        w.addTextEditor ("text", "enter name here", "");
        w.addButton ("OK",     1, KeyPress (KeyPress::returnKey, 0, 0));
        w.addButton ("Cancel", 0, KeyPress (KeyPress::escapeKey, 0, 0));
        
        if (w.runModalLoop() != 0) // is they picked 'ok'
        {
            presetname = w.getTextEditorContents ("text");
        }
#endif
        
        owner->sendChannelStringDataToCsound (getChannel(), newFileName);
        owner->savePluginStateToFile (File (newFileName), presetname);
        owner->refreshComboListBoxContents();
    }

    owner->getProcessor().updateHostDisplay();
}