コード例 #1
0
void AddNewTorrentDialog::onSavePathChanged(int index)
{
    // Toggle default save path setting checkbox visibility
    ui->defaultSavePathCheckBox->setChecked(false);
    ui->defaultSavePathCheckBox->setVisible(
                QDir(ui->savePathComboBox->itemData(ui->savePathComboBox->currentIndex()).toString())
                != QDir(defaultSavePath()));

    // Remember index
    m_oldIndex = index;

    updateDiskSpaceLabel();
}
コード例 #2
0
void GraphEditorTabs::handleExportAs(void)
{
    auto editor = dynamic_cast<GraphEditor *>(this->currentWidget());
    assert(editor != nullptr);

    QString lastPath = editor->getCurrentFilePath();
    if (lastPath.isEmpty()) lastPath = defaultSavePath();
    if (lastPath.endsWith(".pothos")) lastPath = lastPath.left(lastPath.size()-7);
    if (lastPath.endsWith(".pth")) lastPath = lastPath.left(lastPath.size()-4);
    lastPath += ".json";

    this->setCurrentWidget(editor);
    auto filePath = QFileDialog::getSaveFileName(this,
                        tr("Export As"),
                        lastPath,
                        tr("Exported JSON Topologies (*.json)"));
    if (filePath.isEmpty()) return;
    if (not filePath.endsWith(".json")) filePath += ".json";
    filePath = QDir(filePath).absolutePath();

    editor->exportToJSONTopology(filePath);
}
コード例 #3
0
void GraphEditorTabs::handleSaveAs(void)
{
    auto editor = dynamic_cast<GraphEditor *>(this->currentWidget());
    assert(editor != nullptr);

    QString lastPath = editor->getCurrentFilePath();
    if (lastPath.isEmpty()) lastPath = defaultSavePath();

    this->setCurrentWidget(editor);
    auto filePath = QFileDialog::getSaveFileName(this,
                        tr("Save As"),
                        lastPath,
                        tr("Pothos Topologies (*.pothos *.pth)"));
    if (filePath.isEmpty()) return;
    if (not filePath.endsWith(".pothos")) filePath += ".pothos";
    filePath = QDir(filePath).absolutePath();
    auto settings = MainSettings::global();
    settings->setValue("GraphEditorTabs/lastFile", filePath);
    editor->setCurrentFilePath(filePath);
    editor->save();
    this->saveState();
}