+void FileOperator::showInputFilenamePrompt(FileManipulatorThread* manipulator,
+ const QFileInfo &file,
+ const bool dir)
+{
+ bool ok;
+ QString prompt, error;
+
+ if (dir) {
+ prompt = tr("Enter the new directory name.");
+ } else {
+ prompt = tr("Enter the new file name.");
+ }
+
+ manipulator->mutex.lock();
+
+ manipulator->newNameFromDialog = "";
+ QString text = file.fileName();
+
+
+ while (true) {
+ text = QInputDialog::getText(this, QString(), prompt + error, QLineEdit::Normal, text, &ok);
+
+ if (!ok) break;
+
+ error = "";
+ if (text.contains(QRegExp("[\"*/:<>?\\\\|]"))) {
+ error = "<small><br/><font color = 'red'>" + tr("The name cannot contain any of the following characters: ") +
+ "\"*/:<>?\\|</font></small>";
+ } else if (ok && !text.isEmpty()) {
+ QFileInfo info(file.path() + "/" + text);
+ manipulator->newNameFromDialog = info.absoluteFilePath();
+ break;
+ }
+ }
+
+ manipulator->mutex.unlock();
+ manipulator->waitCond.wakeAll();
+}
+
+