void ScreenshotManager::updateHistory(const QString &fileName, const QString &url, const QString &deleteHash)
{
    if (!mSettings->value("/options/history", true).toBool() || url.isEmpty()) {
        return;
    }

    if (!mHistoryInitialized) {
        initHistory();
    }

    QSqlQuery query;
    query.prepare("SELECT fileName FROM history WHERE URL IS NOT EMPTY AND fileName = ?");
    query.addBindValue(fileName);
    query.exec();

    if (query.record().count() > 0) {
        QSqlQuery updateQuery;
        updateQuery.prepare("UPDATE history SET URL = ?, deleteURL = ?, time = ? WHERE fileName = ?");
        updateQuery.addBindValue(url);
        updateQuery.addBindValue("https://imgur.com/delete/" + deleteHash);
        updateQuery.addBindValue(QDateTime::currentMSecsSinceEpoch());
        updateQuery.addBindValue(fileName);

        updateQuery.exec();
    } else {
        saveHistory(fileName, url, deleteHash);
    }
}
示例#2
0
文件: chatform.cpp 项目: allenlv/IM
void chatform::on_sendButton_clicked()
{
    QString sendText = ui->textEdit->toPlainText();
       if(!sendText.isEmpty())
       {

           QString windowTitle = this->windowTitle().replace("].","");
           QString toId = QString(windowTitle.split("[").at(1));
           QString msgType = "MSG_CLIENT_CHAT";
           QByteArray block;
           QDataStream out(&block, QIODevice::WriteOnly);
           out.setVersion(QDataStream::Qt_4_6);
           out << (quint16)0 << msgType << usrname << toId << sendText;
           out.device()->seek(0);

           out << (quint16)(block.size() - sizeof(quint16));

           udpSocket->writeDatagram(block.data(), block.size(), QHostAddress(serverIp), (quint16)serverPort.toUInt()+1);

           QString str="I say :\n" + sendText + "\n";
           ui->listWidget->addItem(str);
           QString fileName="/home/allen/donkey_x/donkeyhead-client/"+toId+".txt";
           if(!QFile::exists(fileName))
           {
               QFile file(fileName);
               file.open(QIODevice::WriteOnly);
               file.close();
           }
           saveHistory(fileName,str);
       }
       ui->textEdit->clear();
}
示例#3
0
void KfindTabWidget::beginSearch()
{
///  dirlister->openURL(KURL(dirBox->currentText().stripWhiteSpace()));

  saveHistory();
  setEnabled( FALSE );
}
示例#4
0
void DebugTools::sendPacket()
{
    if(ui->packetLineEdit->text().length() == 0)
        return;

    QString packet = ui->packetLineEdit->text();
    packet.append("\r\n");

    emit packetSent( packet.toLatin1() );

    if(ui->historyListWidget->count() > 0)
    {
        if(ui->historyListWidget->item( ui->historyListWidget->count()-1 )->text() != ui->packetLineEdit->text())
            ui->historyListWidget->addItem( ui->packetLineEdit->text() );
    }
    else
        ui->historyListWidget->addItem( ui->packetLineEdit->text() );

    ui->historyListWidget->setCurrentRow( ui->historyListWidget->count()-1 );
    ui->historyListWidget->scrollToBottom();

    ui->packetLineEdit->clear();

    saveHistory();
}
示例#5
0
文件: chatform.cpp 项目: allenlv/IM
void chatform::displayText(QString nickname, QString usrname, QString text)
{
    QString str=nickname + "(" + usrname + ") :\n" + text + "\n";
    QListWidgetItem *displayItem = new QListWidgetItem(str);
    ui->listWidget->addItem(displayItem);
    QString file="/home/allen/donkey_x/donkeyhead-client/"+usrname+".txt";
    saveHistory(file,str);
}
示例#6
0
void Transcribe::restoreHistory(int index) {
  saveHistory(); // Save the history to remember the audio position befor we
                 // load a new file

  QModelIndex model_index = m_history.index(index, 0);
  m_restore_pos = model_index.data(HistoryModel::AudioPostionRole).toUInt();
  QString audio_file_path = model_index.data(HistoryModel::AudioFileRole).toString();
  QString text_file_path  = model_index.data(HistoryModel::TextFileRole).toString();
  openAudioFile(audio_file_path);
  openTextFile(text_file_path);

  // Same as with pickFiles():
  // saveHistory() is called when the audio file has finished loading, but we
  // need do it here as well because openTextFile() might return after the audio
  // file has finished loading. The joys of concurrency ...
  saveHistory();
}
示例#7
0
void KfindTabWidget::beginSearch()
{
///  dirlister->openUrl(KUrl(dirBox->currentText().trimmed()));

  saveHistory();

  for (uint i = 0; i < sizeof(pages) / sizeof(pages[0]); ++i) {
      pages[i]->setEnabled(false);
  }
}
示例#8
0
bool ReaderViewNative::closeBook()
{
	if ( _docview->isDocumentOpened() ) {
	    _docview->savePosition();
        _docview->getDocument()->updateMap();
	    saveHistory(lString16());
	    _docview->close();
	    return true;
	}
	return false;
}
示例#9
0
int HistoryListModel::rowCount(const QModelIndex &parent) const
{
    if (lastSeenWidget != q->widget()) {
        if (lastSeenWidget)
            const_cast<QWidget*>(lastSeenWidget)->removeEventFilter(const_cast<HistoryListModel *>(this));
        const_cast<QWidget*>(q->widget())->installEventFilter(const_cast<HistoryListModel *>(this));
        if (qobject_cast<QLineEdit *>(lastSeenWidget))
            // this will result in spamming the history with garbage in some corner cases.
            // not my idea.
            disconnect(lastSeenWidget, SIGNAL(editingFinished ()), q, SLOT(saveHistory()));
        HistoryListModel *that = const_cast<HistoryListModel *>(this);
        that->lastSeenWidget = q->widget();
        that->fetchHistory();
        if (qobject_cast<QLineEdit *>(lastSeenWidget))
            connect(lastSeenWidget, SIGNAL(editingFinished ()), q, SLOT(saveHistory()));
    }
    if (parent.isValid())
        return 0;
    return list.count();
}
示例#10
0
void Server::incomingConnection(qintptr socketDescriptor)
{
    Client *client = new Client(socketDescriptor);
    clients->push_back(client);
    QObject::connect(client,SIGNAL(sendMessageToAll(QString)),this,SLOT(sendMessageToAll(QString)));
    QObject::connect(client,SIGNAL(showDialog(QString)),this,SLOT(onShowDialog(QString)));
    QObject::connect(client,SIGNAL(signalDisconnected(QString)),this,SLOT(onClientDisconnected(QString)));
    QObject::connect(client,SIGNAL(signalConnected(QString)),this,SLOT(onClientConnected(QString)));
    QObject::connect(client,SIGNAL(saveHistory(QString)),this,SLOT(onSaveHistory(QString)));
    QObject::connect(client,SIGNAL(getHistory()),this,SLOT(onGetHistory(Client*)));
    onGetHistory(client);
}
示例#11
0
void ActionDialog::accept()
{
    QVariant itemData = createCurrentItemData();
    int i = findCommand(*ui->comboBoxCommands, itemData);
    if (i != -1)
        ui->comboBoxCommands->removeItem(i);

    const QString text = ui->commandEdit->command();
    ui->comboBoxCommands->insertItem(1, commandToLabel(text), itemData);

    saveHistory();

    QDialog::accept();
}
示例#12
0
void Transcribe::mediaDurationChanged() {
  if (m_player->getDuration() > 0) {

    if (m_restore_pos > 0) {
      // We were loaded with a position to restore
      m_player->setPosition(m_restore_pos);
      m_restore_pos = 0;
    }

    // Now that the audio file is fully loaded, we can save the state (and send
    // the current configuration to the top).
    saveHistory();
  }
}
示例#13
0
void ActionDialog::saveSettings()
{
    ConfigurationManager *cm = ConfigurationManager::instance();
    cm->saveGeometry(this);

    cm->setValue("action_has_input",
                 ui->comboBoxInputFormat->currentText() == QString("text/plain"));
    cm->setValue("action_has_output",
                 ui->comboBoxOutputFormat->currentText() == QString("text/plain"));
    cm->setValue("action_separator",  ui->separatorEdit->text());
    cm->setValue("action_output_tab", ui->comboBoxOutputTab->currentText());

    saveHistory();
}
示例#14
0
int HyperPage_goToPage (I, const wchar_t *title) {
	iam (HyperPage);
	switch (my v_goToPage (title)) {
		case -1: return 0;
		case 0: HyperPage_clear (me); return 0;
	}
	saveHistory (me, title);   /* Last chance: HyperPage_clear will destroy "title" !!! */
	Melder_free (my currentPageTitle);
	my currentPageTitle = Melder_wcsdup_f (title);
	my top = 0;
	HyperPage_clear (me);
	updateVerticalScrollBar (me);   /* Scroll to the top (my top == 0). */
	return 1;	
}
示例#15
0
void V3DocViewWin::closing()
{
    if ( !_docview->getDocument() )
        return;
    //_docview->getDocument()->swapToCacheIfNecessary();
    //_docview->getDocument()->updateMap();


	CRLog::trace("V3DocViewWin::closing(), before docview->savePosition()");
	_dict = NULL;
    _docview->savePosition();
    CRLog::trace("after docview->savePosition()");
    saveHistory( lString16() );
}
示例#16
0
文件: input.c 项目: kasoku/jpug-doc
static void
finishInput(void)
{
#ifdef USE_READLINE
	if (useHistory && psql_history)
	{
		int			hist_size;

		hist_size = GetVariableNum(pset.vars, "HISTSIZE", 500, -1, true);
		(void) saveHistory(psql_history, hist_size);
		free(psql_history);
		psql_history = NULL;
	}
#endif
}
示例#17
0
finishInput(int exitstatus, void *arg)
#endif
{
#ifdef USE_READLINE
	if (useHistory && psql_history)
	{
		int			hist_size;

		hist_size = GetVariableNum(pset.vars, "HISTSIZE", 500, -1, true);
		saveHistory(psql_history, hist_size, true, true);
		free(psql_history);
		psql_history = NULL;
	}
#endif
}
示例#18
0
  foreach (Screenshot* screenshot, mScreenshots) {
    if (screenshot->options().fileName == fileName
        || screenshot->unloadedFileName() == fileName) {
      screenshot->uploadDone(url);

      if (screenshot->options().file) {
        updateHistory(fileName, url, deleteHash);
      }
      else {
        saveHistory("", url, deleteHash);
      }

      return;
    }
  }
示例#19
0
文件: textin.cpp 项目: viranch/textin
void TextIn::sendDone()
{
    saveHistory(m_receivers[m_curr++]);
    setAutoComplete();
    if (m_receivers.size()>1)
        m_bar->setValue(m_curr);
    if (m_curr < m_receivers.size()) {
        m_talker->sendText(m_receivers[m_curr], ui->textEdit->toPlainText());
    } else {
        setEnabled(true);
        ui->buttonBox->button(QDialogButtonBox::Cancel)->hide();
        ui->buttonBox->button(QDialogButtonBox::Close)->show();
        if (m_curr == m_receivers.size())
            ui->statusBar->showMessage("Sent");
    }
}
示例#20
0
/**
 * handle the input history scrolling for the message input area
 * @param wParam: VK_ keyboard code (VK_UP or VK_DOWN)
 */
void CContactCache::inputHistoryEvent(WPARAM wParam)
{
	if (m_hwnd == 0 || m_dat == 0)
		return;

	if (m_history != NULL && m_history[0].szText != NULL) {     // at least one entry needs to be alloced, otherwise we get a nice infinite loop ;)
		HWND		hwndEdit = ::GetDlgItem(m_hwnd, IDC_MESSAGE);
		SETTEXTEX 	stx = {ST_DEFAULT, CP_UTF8};

		if (m_dat->dwFlags & MWF_NEEDHISTORYSAVE) {
			m_iHistoryCurrent = m_iHistoryTop;
			if (::GetWindowTextLengthA(hwndEdit) > 0)
				saveHistory((WPARAM)m_iHistorySize, 0);
			else
				m_history[m_iHistorySize].szText[0] = (TCHAR)'\0';
		}
		if (wParam == VK_UP) {
			if (m_iHistoryCurrent == 0)
				return;
			m_iHistoryCurrent--;
		}
		else {
			m_iHistoryCurrent++;
			if (m_iHistoryCurrent > m_iHistoryTop)
				m_iHistoryCurrent = m_iHistoryTop;
		}
		if (m_iHistoryCurrent == m_iHistoryTop) {
			if (m_history[m_iHistorySize].szText != NULL) {           // replace the temp buffer
				::SetWindowText(hwndEdit, _T(""));
				::SendMessage(hwndEdit, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)m_history[m_iHistorySize].szText);
				::SendMessage(hwndEdit, EM_SETSEL, (WPARAM)- 1, (LPARAM)- 1);
			}
		}
		else {
			if (m_history[m_iHistoryCurrent].szText != NULL) {
				::SetWindowText(hwndEdit, _T(""));
				::SendMessage(hwndEdit, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)m_history[m_iHistoryCurrent].szText);
				::SendMessage(hwndEdit, EM_SETSEL, (WPARAM)- 1, (LPARAM)- 1);
			}
			else ::SetWindowText(hwndEdit, _T(""));
		}
		::SendMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(::GetDlgCtrlID(hwndEdit), EN_CHANGE), (LPARAM)hwndEdit);
		m_dat->dwFlags &= ~MWF_NEEDHISTORYSAVE;
	}
}
示例#21
0
static void gui_drawingarea_cb_click (I, GuiDrawingAreaClickEvent event) {
	iam (HyperPage);
	if (my g == NULL) return;   // Could be the case in the very beginning.
if (gtk && event -> type != BUTTON_PRESS) return;
	if (! my links) return;
	for (long ilink = 1; ilink <= my links -> size; ilink ++) {
		HyperLink link = (HyperLink) my links -> item [ilink];
		if (event -> y > link -> y2DC && event -> y < link -> y1DC && event -> x > link -> x1DC && event -> x < link -> x2DC) {
			saveHistory (me, my currentPageTitle);
			try {
				HyperPage_goToPage (me, link -> name);
			} catch (MelderError) {
				Melder_flushError (NULL);
			}
			return;
		}
	}
}
示例#22
0
void Transcribe::close() {
  bool may_close = true;

  if (m_is_text_dirty) {
    QMessageBox box;
    box.setText(tr("The latest edits are not saved."));
    box.setInformativeText(tr("Do you want to save them now?"));
    box.setStandardButtons(QMessageBox::Save |
                           QMessageBox::Discard |
                           QMessageBox::Cancel );
    int action = box.exec();

    switch (action) {
      case QMessageBox::Save:
        may_close = saveText();
        break;
      case QMessageBox::Cancel:
        may_close = false;
        break;
    }
  }

  if (may_close) {
#ifndef Q_OS_ANDROID
    // Save window state
    QSettings settings;
    settings.beginGroup(CFG_GROUP_SCREEN);
    if (m_main_window->visibility() == QWindow::Maximized) {
      settings.setValue(CFG_SCREEN_IS_MAXIMIZED, true);
    } else {
      settings.setValue(CFG_SCREEN_IS_MAXIMIZED, false);
    }
    settings.setValue(CFG_SCREEN_SIZE, m_main_window->size());
    settings.setValue(CFG_SCREEN_POS,  m_main_window->position());
    settings.endGroup();
    settings.sync();
#endif

    saveHistory();

    QApplication::quit();
  }
}
示例#23
0
void ScreenshotManager::uploadDone(const QString &fileName, const QString &url, const QString &deleteHash)
{
    for (Screenshot *screenshot : qAsConst(mScreenshots)) {
        if (screenshot->options().fileName == fileName
                || screenshot->unloadedFileName() == fileName) {
            screenshot->uploadDone(url);

            if (screenshot->options().file) {
                updateHistory(fileName, url, deleteHash);
            } else {
                saveHistory("", url, deleteHash);
            }

            return;
        }
    }

    // If we get here, it's because the screenshot upload wasn't on the current screenshot list, which means it's a View History/Upload Later upload.
    updateHistory(fileName, url, deleteHash);
}
示例#24
0
void MainWindow::execute()
{
    emit cancelQuery();

    QString target = ui->txtTarget->text().trimmed();

    if (!target.isEmpty()) {
        for (QList<Target *>::const_iterator i = targetList_->cbegin(); i != targetList_->cend(); i++) {
            if (target.compare((*i)->getName(), Qt::CaseInsensitive) == 0) {

                //Saving history
                saveHistory(*(*i));

                QString command;

                if ((*i)->getCommand().isEmpty()) {
                    command = target;
                } else {
                    command = (*i)->getCommand();
                }

                if (command.startsWith("http://") || command.startsWith("https://")) {
                    command.append(ui->txtArgument->encodedText());
                    QDesktopServices::openUrl(QUrl(command));
                } else {
                    command.append(" ");
                    command.append(ui->txtArgument->text().trimmed());
                    QProcess *p = new QProcess(this);
                    p->startDetached(command);
                    connect(p, SIGNAL(finished(int)), p, SLOT(deleteLater())); //Clean UP!!
                }

                break;
            }
        }
    }

    PersistenceHandler::saveLast(ui->txtTarget->text(), ui->txtArgument->text(), this);
    qApp->exit(0);
}
示例#25
0
bool V3DocViewWin::saveHistory( lString16 filename )
{
    crtrace log;
    if ( filename.empty() )
        filename = _historyFileName;
    if ( filename.empty() ) {
        CRLog::info("Cannot write history file - no file name specified");
        return false;
    }
    CRLog::debug("Exporting bookmarks to %s", UnicodeToUtf8(_bookmarkDir).c_str());
    _docview->exportBookmarks(_bookmarkDir); //use default filename
    _historyFileName = filename;
    log << "V3DocViewWin::saveHistory(" << filename << ")";
    LVStreamRef stream = LVOpenFileStream( filename.c_str(), LVOM_WRITE );
    if ( !stream ) {
        lString16 path16 = LVExtractPath( filename );
        lString8 path = UnicodeToLocal( path16 );
#ifdef _WIN32
        if ( !CreateDirectoryW( path16.c_str(), NULL ) ) {
            CRLog::error("Cannot create directory %s", path.c_str() );
        } else {
            stream = LVOpenFileStream( filename.c_str(), LVOM_WRITE );
        }
#else
        path.erase( path.length()-1, 1 );
        CRLog::warn("Cannot create settings file, trying to create directory %s", path.c_str());
        if ( mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) ) {
            CRLog::error("Cannot create directory %s", path.c_str() );
        } else {
            stream = LVOpenFileStream( filename.c_str(), LVOM_WRITE );
        }
#endif
    }
    if ( stream.isNull() ) {
    	CRLog::error("Error while creating history file %s - position will be lost", UnicodeToUtf8(filename).c_str() );
    	return false;
    }
    return saveHistory( stream );
}
示例#26
0
 void bdm() {
   // % performs element-wise multiplication
   arma::vec d = d0 + dslope % (abundance.t() * interaction).t();
   for (int i = 0; i < abundance.n_elem; i++) if(abundance(i) == 0) d(i) = 0;
   //Gillespie weights for each specie, which are the sum of their rates
   arma::vec w = (abundance % (b + d)) + m; 
   //sampling which species will suffer the next action, proportionaly to their weights
   int c = Csample(w);
   // Should the selected species gain or lose an individual?
   double choice = R::runif(0,1);
   if ( choice > (b(c)*abundance(c)+m(c)) / (b(c)*abundance(c)+m(c)+d(c)*abundance(c)))
     abundance(c) --;
   else 
     abundance(c) ++;
   // advances the simulation clock
   double elapsed = R::rexp(1.0 / sum(w));
   if (elapsed > save_int) warning("Time elapsed larger than save interval!");
   // only saves trajectories if we have completed a saving period
   if (((int) (time / save_int)) !=  ((int) ((time+elapsed)/save_int)))
     saveHistory();
   time += elapsed;
   return;
 }
示例#27
0
void KeyAddDialog::on_add_clicked()
{
	if( !skView->selectionModel()->hasSelection() )
		return;

	QList<CKey> keys;
	Q_FOREACH( const QModelIndex &index, skView->selectionModel()->selectedRows() )
	{
		const CKey k = keyModel->key( index );
		keys << k;
		if( usedView->findItems( k.recipient, Qt::MatchExactly ).isEmpty() )
		{
			QTreeWidgetItem *i = new QTreeWidgetItem( usedView );
			i->setText( 0, k.recipient );
			i->setText( 1, k.cert.issuerInfo( "CN" ) );
			i->setText( 2, k.cert.expiryDate().toLocalTime().toString( "dd.MM.yyyy" ) );
			i->setData( 0, Qt::UserRole, SslCertificate( k.cert ).isTempel() );
			usedView->addTopLevelItem( i );
		}
	}
	addKeys( keys );

	saveHistory();
}
示例#28
0
文件: qlv2.cpp 项目: chagge/AI
double QL::playAnEpisode(bool toTrain) {
	double epScore = 0;
	int ftime = 1;

	while(!gameOver() && !interface->isTerminal()) {
		if(ftime == 1) {
			ftime = 0;
			epScore += initSeq();
		}
		int toAct = chooseAction(toTrain);
		double lastScore = repeatLastAction(ind2Act[toAct], numFrmStack, toTrain);
		epScore += lastScore;
		int reward = 0;
		if(lastScore != 0.0f) {
			reward = 1;
			if(lastScore < 0.0f) {
				reward = -1;
			}
		}

		if(toTrain) {
			History history = {(maxHistoryLen+lastHistInd-2)%maxHistoryLen, 
								reward, 
								toAct, 
								interface->isTerminal(), 
								(maxHistoryLen+lastHistInd-1)%maxHistoryLen};
			saveHistory(history);
			if(dExp.size() > info.memThreshold) {
				getAMiniBatch();
				learnWts();
			}
		}
	}
	interface->resetVals(1);
	return epScore;
}
示例#29
0
HistoryLineEdit::~HistoryLineEdit( )
{
	saveHistory( );

	delete m_history;
}
示例#30
0
void Transcribe::pickFiles() {
  QFileDialog dlg;

  // Unfortunately, Android doesn't really work with the concept of files,
  // they are abstracted away. Since it would require a major effort to make
  // this work in the Android way, we'll just try to make the best of it.
#ifdef Q_OS_ANDROID
    // First see if we have storage permissions. We fail here if we don't have
    // them and let the callback to the request popup call this method again.
    if (!StoragePerm::instance()->tryPermission(std::bind(&Transcribe::pickFiles, this))) return;

    // Make the QFileDialog a bit better by maximizing it.
    dlg.setWindowState(Qt::WindowMaximized);
    dlg.setViewMode(QFileDialog::List);

    // Add the root and the internal memory location to the paths to choose
    // from. There are no real standard paths for this, let's hope Qt knows
    // what to do.
    QUrl home_url = QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first());
    dlg.setDirectoryUrl(home_url);
    QList<QUrl> urls;
    urls << QUrl::fromLocalFile("/");
    urls << home_url;
    dlg.setSidebarUrls(urls);
#endif

  // Let the user pick an audio file
  dlg.setWindowTitle(tr("Open an audio file"));
  dlg.setNameFilter(tr("Audio files (*.wav *.mp3 *.aac *.amr *.aiff *.flac *.ogg *.wma, *.opus)"));
  dlg.setFileMode(QFileDialog::ExistingFile);
  dlg.setAcceptMode(QFileDialog::AcceptOpen);
  if (dlg.exec() == QDialog::Rejected || dlg.selectedFiles().count() != 1) {
    return;
  }

  m_restore_pos = 0;
  openAudioFile(dlg.selectedFiles().at(0));

#ifdef Q_OS_ANDROID
  QString audio_path = dlg.selectedFiles().at(0);
  QString text_path;

  // Check if the audio file is in our history
  if (!m_history.textFileForAudio(audio_path, text_path)) {
    // If not, create a new file in the app private folder based on the audio
    // file name. If a text file with the name already exists, append a number
    // to it.
    QString base_name = QFileInfo(audio_path).baseName();
    QDir home = QDir(QStandardPaths::writableLocation((QStandardPaths::AppDataLocation)));
    text_path = home.filePath(base_name + ".txt");
    short counter = 1;
    while (QFile::exists(text_path)) {
      text_path = home.filePath(QString("%1_%2.txt").arg(base_name).arg(counter, 2, 10, QChar('0')));
      counter++;
    }
  }

  openTextFile(text_path);
#else
  // Recycle the file dialog to let the user pick a text file for the
  // transcript. As a file suggestion, we base a txt file on the current audio
  // file.
  dlg.setWindowTitle(tr("Pick a text file for the transcript"));
  dlg.setNameFilter(tr("Text files (*.txt)"));
  dlg.setFileMode(QFileDialog::AnyFile);
  dlg.setAcceptMode(QFileDialog::AcceptSave);
  dlg.setOption(QFileDialog::DontConfirmOverwrite, true);
  dlg.setLabelText(QFileDialog::Accept, tr("Open/Create"));
  QFileInfo info(dlg.selectedFiles().at(0));
  dlg.setDirectory(info.absolutePath());
  dlg.selectFile(info.baseName() + ".txt");
  if (dlg.exec() == QDialog::Rejected || dlg.selectedFiles().count() != 1) {
    return;
  }

  openTextFile(dlg.selectedFiles().at(0));
#endif

  // saveHistory() is called when the audio file has finished loading, but we
  // need do it here as well because openTextFile() might return after the audio
  // file has finished loading. The joys of concurrency ...
  saveHistory();
}