2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
RadRussianRus
2019-10-07 21:44:39 +03:00
5 changed files with 33 additions and 15 deletions

View File

@@ -746,6 +746,12 @@ QWidget *Application::getFileDialogParent() {
: nullptr;
}
void Application::notifyFileDialogShown(bool shown) {
if (_mediaView) {
_mediaView->notifyFileDialogShown(shown);
}
}
void Application::checkMediaViewActivation() {
if (_mediaView && !_mediaView->isHidden()) {
_mediaView->activateWindow();

View File

@@ -99,6 +99,7 @@ public:
bool closeActiveWindow();
bool minimizeActiveWindow();
QWidget *getFileDialogParent();
void notifyFileDialogShown(bool shown);
// Media view interface.
void checkMediaViewActivation();

View File

@@ -360,11 +360,13 @@ bool GetDefault(
Platform::FileDialog::InitLastPath();
}
remoteContent = QByteArray();
remoteContent = QByteArray();
if (startFile.isEmpty() || startFile.at(0) != '/') {
startFile = cDialogLastPath() + '/' + startFile;
}
QString file;
Core::App().notifyFileDialogShown(true);
if (type == Type::ReadFiles) {
files = QFileDialog::getOpenFileNames(Core::App().getFileDialogParent(), caption, startFile, filter);
QString path = files.isEmpty() ? QString() : QFileInfo(files.back()).absoluteDir().absolutePath();
@@ -373,17 +375,19 @@ bool GetDefault(
Local::writeUserSettings();
}
return !files.isEmpty();
} else if (type == Type::ReadFolder) {
} else if (type == Type::ReadFolder) {
file = QFileDialog::getExistingDirectory(Core::App().getFileDialogParent(), caption, startFile);
} else if (type == Type::WriteFile) {
} else if (type == Type::WriteFile) {
file = QFileDialog::getSaveFileName(Core::App().getFileDialogParent(), caption, startFile, filter);
} else {
} else {
file = QFileDialog::getOpenFileName(Core::App().getFileDialogParent(), caption, startFile, filter);
}
if (file.isEmpty()) {
files = QStringList();
return false;
}
}
Core::App().notifyFileDialogShown(false);
if (file.isEmpty()) {
files = QStringList();
return false;
}
if (type != Type::ReadFolder) {
// Save last used directory for all queries except directory choosing.
auto path = QFileInfo(file).absoluteDir().absolutePath();

View File

@@ -1095,6 +1095,17 @@ void OverlayWidget::onToMessage() {
}
}
void OverlayWidget::notifyFileDialogShown(bool shown) {
if (shown && isHidden()) {
return;
}
if (shown) {
Ui::Platform::BringToBack(this);
} else {
Ui::Platform::ShowOverAll(this);
}
}
void OverlayWidget::onSaveAs() {
QString file;
if (_doc) {
@@ -1116,9 +1127,7 @@ void OverlayWidget::onSaveAs() {
filter = mimeType.filterString() + qsl(";;") + FileDialog::AllFilesFilter();
}
Ui::Platform::BringToBack(this);
file = FileNameForSave(tr::lng_save_file(tr::now), filter, qsl("doc"), name, true, alreadyDir);
Ui::Platform::ShowOverAll(this);
if (!file.isEmpty() && file != location.name()) {
if (_doc->data().isEmpty()) {
QFile(file).remove();
@@ -1142,7 +1151,6 @@ void OverlayWidget::onSaveAs() {
} else {
if (!_photo || !_photo->loaded()) return;
Ui::Platform::BringToBack(this);
auto filter = qsl("JPEG Image (*.jpg);;") + FileDialog::AllFilesFilter();
FileDialog::GetWritePath(
this,
@@ -1158,9 +1166,6 @@ void OverlayWidget::onSaveAs() {
if (!result.isEmpty() && _photo == photo && photo->loaded()) {
photo->large()->original().save(result, "JPG");
}
Ui::Platform::ShowOverAll(this);
}), crl::guard(this, [=] {
Ui::Platform::ShowOverAll(this);
}));
}
activateWindow();

View File

@@ -92,6 +92,8 @@ public:
PeerData *ui_getPeerForMouseAction();
void notifyFileDialogShown(bool shown);
void clearData();
~OverlayWidget();