22 #include <QApplication>
23 #include <QFileDialog>
24 #include <QMessageBox>
25 #include <QPushButton>
49 QString title = tr(
"Import profile",
"import dialog title");
50 QString filter = tr(
"Tox save file (*.tox)",
"import dialog filter");
51 QString dir = QDir::homePath();
56 QString path = QFileDialog::getOpenFileName(Q_NULLPTR, title, dir, filter);
69 QMessageBox::Icon icon = QMessageBox::Warning;
70 QMessageBox box(icon, title,
message, QMessageBox::NoButton,
this);
71 QPushButton* pushButton1 = box.addButton(QApplication::tr(
"Yes"), QMessageBox::AcceptRole);
72 QPushButton* pushButton2 = box.addButton(QApplication::tr(
"No"), QMessageBox::RejectRole);
73 box.setDefaultButton(pushButton2);
74 box.setEscapeButton(pushButton2);
77 return box.clickedButton() == pushButton1;
92 QMessageBox::warning(
this, tr(
"File doesn't exist"), tr(
"Profile doesn't exist"),
97 QString profile = info.completeBaseName();
99 if (info.suffix() !=
"tox") {
100 QMessageBox::warning(
this, tr(
"Ignoring non-Tox file",
"popup title"),
101 tr(
"Warning: You have chosen a file that is not a "
102 "Tox save file; ignoring.",
109 QString profilePath = QDir(settingsPath).filePath(profile +
Core::TOX_EXT);
111 if (QFileInfo(profilePath).exists()) {
112 QString title = tr(
"Profile already exists",
"import confirm title");
113 QString
message = tr(
"A profile named \"%1\" already exists. "
114 "Do you want to erase it?",
115 "import confirm text")
122 QFile(profilePath).remove();
125 QFile::copy(path, profilePath);
128 QMessageBox::information(
this, tr(
"Profile imported"),
129 tr(
"%1.tox was successfully imported").arg(profile), QMessageBox::Ok);