Improved location coords precision when converting them to string.

Also disabled some options for a packaged build.
This commit is contained in:
John Preston 2017-02-03 13:17:40 +03:00
parent 5f0741a0a5
commit 60f45ab9b3
17 changed files with 113 additions and 47 deletions

View File

@ -44,7 +44,7 @@ using GifItems = QHash<Media::Clip::Reader*, HistoryItem*>;
using PhotosData = QHash<PhotoId, PhotoData*>; using PhotosData = QHash<PhotoId, PhotoData*>;
using DocumentsData = QHash<DocumentId, DocumentData*>; using DocumentsData = QHash<DocumentId, DocumentData*>;
struct LocationCoords; class LocationCoords;
struct LocationData; struct LocationData;
namespace App { namespace App {

View File

@ -699,7 +699,7 @@ AppClass::AppClass() : QObject() {
if (cLaunchMode() == LaunchModeAutoStart && !cAutoStart()) { if (cLaunchMode() == LaunchModeAutoStart && !cAutoStart()) {
psAutoStart(false, true); psAutoStart(false, true);
application()->quit(); App::quit();
return; return;
} }

View File

@ -116,11 +116,13 @@ void DownloadPathBox::onEditPath() {
} }
void DownloadPathBox::save() { void DownloadPathBox::save() {
#ifndef OS_WIN_STORE
Global::SetDownloadPath(_default->checked() ? QString() : (_temp->checked() ? qsl("tmp") : _path)); Global::SetDownloadPath(_default->checked() ? QString() : (_temp->checked() ? qsl("tmp") : _path));
Global::SetDownloadPathBookmark((_default->checked() || _temp->checked()) ? QByteArray() : _pathBookmark); Global::SetDownloadPathBookmark((_default->checked() || _temp->checked()) ? QByteArray() : _pathBookmark);
Local::writeUserSettings(); Local::writeUserSettings();
Global::RefDownloadPathChanged().notify(); Global::RefDownloadPathChanged().notify();
closeBox(); closeBox();
#endif // OS_WIN_STORE
} }
void DownloadPathBox::setPathText(const QString &text) { void DownloadPathBox::setPathText(const QString &text) {

View File

@ -25,6 +25,12 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "lang.h" #include "lang.h"
#include "pspecific.h" #include "pspecific.h"
namespace {
constexpr auto kCoordPrecision = 8;
} // namespace
QString LocationClickHandler::copyToClipboardContextItemText() const { QString LocationClickHandler::copyToClipboardContextItemText() const {
return lang(lng_context_copy_link); return lang(lng_context_copy_link);
} }
@ -36,7 +42,7 @@ void LocationClickHandler::onClick(Qt::MouseButton button) const {
} }
void LocationClickHandler::setup() { void LocationClickHandler::setup() {
QString latlon(qsl("%1,%2").arg(_coords.lat).arg(_coords.lon)); auto latlon = _coords.latAsString() + ',' + _coords.lonAsString();
_text = qsl("https://maps.google.com/maps?q=") + latlon + qsl("&ll=") + latlon + qsl("&z=16"); _text = qsl("https://maps.google.com/maps?q=") + latlon + qsl("&ll=") + latlon + qsl("&z=16");
} }
@ -118,7 +124,7 @@ void LocationManager::getData(LocationData *data) {
w = convertScale(w); w = convertScale(w);
h = convertScale(h); h = convertScale(h);
} }
QString coords = qsl("%1,%2").arg(data->coords.lat).arg(data->coords.lon); auto coords = data->coords.latAsString() + ',' + data->coords.lonAsString();
QString url = qsl("https://maps.googleapis.com/maps/api/staticmap?center=") + coords + qsl("&zoom=%1&size=%2x%3&maptype=roadmap&scale=%4&markers=color:red|size:big|").arg(zoom).arg(w).arg(h).arg(scale) + coords + qsl("&sensor=false"); QString url = qsl("https://maps.googleapis.com/maps/api/staticmap?center=") + coords + qsl("&zoom=%1&size=%2x%3&maptype=roadmap&scale=%4&markers=color:red|size:big|").arg(zoom).arg(w).arg(h).arg(scale) + coords + qsl("&sensor=false");
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url))); QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url)));
imageLoadings[reply] = data; imageLoadings[reply] = data;
@ -224,7 +230,7 @@ void LocationManager::onFailed(QNetworkReply *reply) {
imageLoadings.erase(i); imageLoadings.erase(i);
} }
} }
DEBUG_LOG(("Network Error: failed to get data for image link %1,%2 error %3").arg(d ? d->coords.lat : 0).arg(d ? d->coords.lon : 0).arg(reply->errorString())); DEBUG_LOG(("Network Error: failed to get data for image link %1,%2 error %3").arg(d ? d->coords.latAsString() : QString()).arg(d ? d->coords.lonAsString() : QString()).arg(reply->errorString()));
if (d) { if (d) {
failed(d); failed(d);
} }

View File

@ -24,30 +24,52 @@ void initLocationManager();
void reinitLocationManager(); void reinitLocationManager();
void deinitLocationManager(); void deinitLocationManager();
struct LocationCoords { class LocationCoords {
LocationCoords() : lat(0), lon(0) { public:
LocationCoords() = default;
LocationCoords(float64 lat, float64 lon) : _lat(lat), _lon(lon) {
} }
LocationCoords(float64 lat, float64 lon) : lat(lat), lon(lon) { LocationCoords(const MTPDgeoPoint &point) : _lat(point.vlat.v), _lon(point.vlong.v) {
} }
LocationCoords(const MTPDgeoPoint &point) : lat(point.vlat.v), lon(point.vlong.v) {
QString latAsString() const {
return asString(_lat);
} }
float64 lat, lon; QString lonAsString() const {
}; return asString(_lon);
inline bool operator==(const LocationCoords &a, const LocationCoords &b) { }
return (a.lat == b.lat) && (a.lon == b.lon); MTPGeoPoint toMTP() const {
} return MTP_geoPoint(MTP_double(_lon), MTP_double(_lat));
inline bool operator<(const LocationCoords &a, const LocationCoords &b) { }
return (a.lat < b.lat) || ((a.lat == b.lat) && (a.lon < b.lon));
} private:
inline uint qHash(const LocationCoords &t, uint seed = 0) { static QString asString(float64 value) {
static constexpr auto kPrecision = 6;
return QString::number(value, 'f', kPrecision);
}
friend inline bool operator==(const LocationCoords &a, const LocationCoords &b) {
return (a._lat == b._lat) && (a._lon == b._lon);
}
friend inline bool operator<(const LocationCoords &a, const LocationCoords &b) {
return (a._lat < b._lat) || ((a._lat == b._lat) && (a._lon < b._lon));
}
friend inline uint qHash(const LocationCoords &t, uint seed = 0) {
#ifndef OS_MAC_OLD #ifndef OS_MAC_OLD
return qHash(QtPrivate::QHashCombine().operator()(qHash(t.lat), t.lon), seed); return qHash(QtPrivate::QHashCombine().operator()(qHash(t._lat), t._lon), seed);
#else // OS_MAC_OLD #else // OS_MAC_OLD
uint h1 = qHash(t.lat, seed); uint h1 = qHash(t._lat, seed);
uint h2 = qHash(t.lon, seed); uint h2 = qHash(t._lon, seed);
return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed; return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed;
#endif // OS_MAC_OLD #endif // OS_MAC_OLD
} }
float64 _lat = 0;
float64 _lon = 0;
};
struct LocationData { struct LocationData {
LocationData(const LocationCoords &coords) : coords(coords), loading(false) { LocationData(const LocationCoords &coords) : coords(coords), loading(false) {

View File

@ -844,7 +844,7 @@ private:
}; };
struct LocationCoords; class LocationCoords;
struct LocationData; struct LocationData;
class HistoryLocation : public HistoryMedia { class HistoryLocation : public HistoryMedia {

View File

@ -202,7 +202,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
w /= 2; w /= 2;
h /= 2; h /= 2;
} }
QString coords = qsl("%1,%2").arg(location.lat).arg(location.lon); auto coords = location.latAsString() + ',' + location.lonAsString();
QString url = qsl("https://maps.googleapis.com/maps/api/staticmap?center=") + coords + qsl("&zoom=%1&size=%2x%3&maptype=roadmap&scale=%4&markers=color:red|size:big|").arg(zoom).arg(w).arg(h).arg(scale) + coords + qsl("&sensor=false"); QString url = qsl("https://maps.googleapis.com/maps/api/staticmap?center=") + coords + qsl("&zoom=%1&size=%2x%3&maptype=roadmap&scale=%4&markers=color:red|size:big|").arg(zoom).arg(w).arg(h).arg(scale) + coords + qsl("&sensor=false");
result->_locationThumb = ImagePtr(url); result->_locationThumb = ImagePtr(url);
} }

View File

@ -54,13 +54,13 @@ SendDataCommon::SentMTPMessageFields SendText::getSentMessageFields() const {
SendDataCommon::SentMTPMessageFields SendGeo::getSentMessageFields() const { SendDataCommon::SentMTPMessageFields SendGeo::getSentMessageFields() const {
SentMTPMessageFields result; SentMTPMessageFields result;
result.media = MTP_messageMediaGeo(MTP_geoPoint(MTP_double(_location.lon), MTP_double(_location.lat))); result.media = MTP_messageMediaGeo(_location.toMTP());
return result; return result;
} }
SendDataCommon::SentMTPMessageFields SendVenue::getSentMessageFields() const { SendDataCommon::SentMTPMessageFields SendVenue::getSentMessageFields() const {
SentMTPMessageFields result; SentMTPMessageFields result;
result.media = MTP_messageMediaVenue(MTP_geoPoint(MTP_double(_location.lon), MTP_double(_location.lat)), MTP_string(_title), MTP_string(_address), MTP_string(_provider), MTP_string(_venueId)); result.media = MTP_messageMediaVenue(_location.toMTP(), MTP_string(_title), MTP_string(_address), MTP_string(_provider), MTP_string(_venueId));
return result; return result;
} }

View File

@ -1269,11 +1269,12 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version) {
QString v; QString v;
stream >> v; stream >> v;
if (!_checkStreamStatus(stream)) return false; if (!_checkStreamStatus(stream)) return false;
#ifndef OS_WIN_STORE
if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/'; if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/';
Global::SetDownloadPath(v); Global::SetDownloadPath(v);
Global::SetDownloadPathBookmark(QByteArray()); Global::SetDownloadPathBookmark(QByteArray());
Global::RefDownloadPathChanged().notify(); Global::RefDownloadPathChanged().notify();
#endif // OS_WIN_STORE
} break; } break;
case dbiDownloadPath: { case dbiDownloadPath: {
@ -1281,12 +1282,13 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version) {
QByteArray bookmark; QByteArray bookmark;
stream >> v >> bookmark; stream >> v >> bookmark;
if (!_checkStreamStatus(stream)) return false; if (!_checkStreamStatus(stream)) return false;
#ifndef OS_WIN_STORE
if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/'; if (!v.isEmpty() && v != qstr("tmp") && !v.endsWith('/')) v += '/';
Global::SetDownloadPath(v); Global::SetDownloadPath(v);
Global::SetDownloadPathBookmark(bookmark); Global::SetDownloadPathBookmark(bookmark);
psDownloadPathEnableAccess(); psDownloadPathEnableAccess();
Global::RefDownloadPathChanged().notify(); Global::RefDownloadPathChanged().notify();
#endif // OS_WIN_STORE
} break; } break;
case dbiCompressPastedImage: { case dbiCompressPastedImage: {

View File

@ -460,7 +460,7 @@ QByteArray psPathBookmark(const QString &path) {
} }
bool psLaunchMaps(const LocationCoords &coords) { bool psLaunchMaps(const LocationCoords &coords) {
return QDesktopServices::openUrl(qsl("https://maps.apple.com/?q=Point&z=16&ll=%1,%2").arg(coords.lat).arg(coords.lon)); return QDesktopServices::openUrl(qsl("https://maps.apple.com/?q=Point&z=16&ll=%1,%2").arg(coords.latAsString()).arg(coords.lonAsString()));
} }
QString strNotificationAboutThemeChange() { QString strNotificationAboutThemeChange() {

View File

@ -1552,5 +1552,5 @@ void psWriteStackTrace() {
} }
bool psLaunchMaps(const LocationCoords &coords) { bool psLaunchMaps(const LocationCoords &coords) {
return QDesktopServices::openUrl(qsl("bingmaps:?lvl=16&collection=point.%1_%2_Point").arg(coords.lat).arg(coords.lon)); return QDesktopServices::openUrl(qsl("bingmaps:?lvl=16&collection=point.%1_%2_Point").arg(coords.latAsString()).arg(coords.lonAsString()));
} }

View File

@ -144,7 +144,11 @@ void settingsParseArgs(int argc, char *argv[]) {
switch (cPlatform()) { switch (cPlatform()) {
case dbipWindows: case dbipWindows:
gUpdateURL = QUrl(qsl("http://tdesktop.com/win/tupdates/current")); gUpdateURL = QUrl(qsl("http://tdesktop.com/win/tupdates/current"));
#ifndef OS_WIN_STORE
gPlatformString = qsl("Windows"); gPlatformString = qsl("Windows");
#else // OS_WIN_STORE
gPlatformString = qsl("WinStore");
#endif // OS_WIN_STORE
break; break;
case dbipMac: case dbipMac:
gUpdateURL = QUrl(qsl("http://tdesktop.com/mac/tupdates/current")); gUpdateURL = QUrl(qsl("http://tdesktop.com/mac/tupdates/current"));

View File

@ -63,6 +63,7 @@ int LabeledLink::resizeGetHeight(int newWidth) {
return _label->height(); return _label->height();
} }
#ifndef OS_WIN_STORE
DownloadPathState::DownloadPathState(QWidget *parent) : TWidget(parent) DownloadPathState::DownloadPathState(QWidget *parent) : TWidget(parent)
, _path(this, lang(lng_download_path_label), downloadPathText(), LabeledLink::Type::Secondary, SLOT(onDownloadPath())) , _path(this, lang(lng_download_path_label), downloadPathText(), LabeledLink::Type::Secondary, SLOT(onDownloadPath()))
, _clear(this, lang(lng_download_path_clear)) { , _clear(this, lang(lng_download_path_clear)) {
@ -146,6 +147,7 @@ void DownloadPathState::onTempDirClearFailed(int task) {
} }
updateControls(); updateControls();
} }
#endif // OS_WIN_STORE
ChatSettingsWidget::ChatSettingsWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_chat_settings)) { ChatSettingsWidget::ChatSettingsWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_chat_settings)) {
createControls(); createControls();
@ -164,12 +166,20 @@ void ChatSettingsWidget::createControls() {
_viewList->hideFast(); _viewList->hideFast();
} }
addChildRow(_dontAskDownloadPath, marginSub, lang(lng_download_path_dont_ask), SLOT(onDontAskDownloadPath()), !Global::AskDownloadPath()); #ifndef OS_WIN_STORE
auto pathMargin = marginSub;
#else // OS_WIN_STORE
auto pathMargin = marginSkip;
#endif // OS_WIN_STORE
addChildRow(_dontAskDownloadPath, pathMargin, lang(lng_download_path_dont_ask), SLOT(onDontAskDownloadPath()), !Global::AskDownloadPath());
#ifndef OS_WIN_STORE
style::margins marginPath(st::defaultBoxCheckbox.textPosition.x(), 0, 0, st::settingsSkip); style::margins marginPath(st::defaultBoxCheckbox.textPosition.x(), 0, 0, st::settingsSkip);
addChildRow(_downloadPath, marginPath, slidedPadding); addChildRow(_downloadPath, marginPath, slidedPadding);
if (Global::AskDownloadPath()) { if (Global::AskDownloadPath()) {
_downloadPath->hideFast(); _downloadPath->hideFast();
} }
#endif // OS_WIN_STORE
addChildRow(_sendByEnter, marginSmall, qsl("send_key"), 0, lang(lng_settings_send_enter), SLOT(onSendByEnter()), !cCtrlEnter()); addChildRow(_sendByEnter, marginSmall, qsl("send_key"), 0, lang(lng_settings_send_enter), SLOT(onSendByEnter()), !cCtrlEnter());
addChildRow(_sendByCtrlEnter, marginSkip, qsl("send_key"), 1, lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_settings_send_cmdenter : lng_settings_send_ctrlenter), SLOT(onSendByCtrlEnter()), cCtrlEnter()); addChildRow(_sendByCtrlEnter, marginSkip, qsl("send_key"), 1, lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_settings_send_cmdenter : lng_settings_send_ctrlenter), SLOT(onSendByCtrlEnter()), cCtrlEnter());
@ -195,11 +205,13 @@ void ChatSettingsWidget::onViewList() {
void ChatSettingsWidget::onDontAskDownloadPath() { void ChatSettingsWidget::onDontAskDownloadPath() {
Global::SetAskDownloadPath(!_dontAskDownloadPath->checked()); Global::SetAskDownloadPath(!_dontAskDownloadPath->checked());
Local::writeUserSettings(); Local::writeUserSettings();
#ifndef OS_WIN_STORE
if (_dontAskDownloadPath->checked()) { if (_dontAskDownloadPath->checked()) {
_downloadPath->slideDown(); _downloadPath->slideDown();
} else { } else {
_downloadPath->slideUp(); _downloadPath->slideUp();
} }
#endif // OS_WIN_STORE
} }
void ChatSettingsWidget::onSendByEnter() { void ChatSettingsWidget::onSendByEnter() {

View File

@ -51,6 +51,7 @@ private:
}; };
#ifndef OS_WIN_STORE
class DownloadPathState : public TWidget, private base::Subscriber { class DownloadPathState : public TWidget, private base::Subscriber {
Q_OBJECT Q_OBJECT
@ -85,6 +86,7 @@ private:
object_ptr<Ui::LinkButton> _clear; object_ptr<Ui::LinkButton> _clear;
}; };
#endif // OS_WIN_STORE
class ChatSettingsWidget : public BlockWidget { class ChatSettingsWidget : public BlockWidget {
Q_OBJECT Q_OBJECT
@ -107,7 +109,11 @@ private:
object_ptr<Ui::Checkbox> _replaceEmoji = { nullptr }; object_ptr<Ui::Checkbox> _replaceEmoji = { nullptr };
object_ptr<Ui::WidgetSlideWrap<Ui::LinkButton>> _viewList = { nullptr }; object_ptr<Ui::WidgetSlideWrap<Ui::LinkButton>> _viewList = { nullptr };
object_ptr<Ui::Checkbox> _dontAskDownloadPath = { nullptr }; object_ptr<Ui::Checkbox> _dontAskDownloadPath = { nullptr };
#ifndef OS_WIN_STORE
object_ptr<Ui::WidgetSlideWrap<DownloadPathState>> _downloadPath = { nullptr }; object_ptr<Ui::WidgetSlideWrap<DownloadPathState>> _downloadPath = { nullptr };
#endif // OS_WIN_STORE
object_ptr<Ui::Radiobutton> _sendByEnter = { nullptr }; object_ptr<Ui::Radiobutton> _sendByEnter = { nullptr };
object_ptr<Ui::Radiobutton> _sendByCtrlEnter = { nullptr }; object_ptr<Ui::Radiobutton> _sendByCtrlEnter = { nullptr };
object_ptr<Ui::LinkButton> _automaticMediaDownloadSettings = { nullptr }; object_ptr<Ui::LinkButton> _automaticMediaDownloadSettings = { nullptr };

View File

@ -189,19 +189,21 @@ void GeneralWidget::refreshControls() {
if (cPlatform() == dbipWindows || cSupportTray()) { if (cPlatform() == dbipWindows || cSupportTray()) {
addChildRow(_enableTrayIcon, marginSmall, lang(lng_settings_workmode_tray), SLOT(onEnableTrayIcon()), (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray)); addChildRow(_enableTrayIcon, marginSmall, lang(lng_settings_workmode_tray), SLOT(onEnableTrayIcon()), (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray));
if (cPlatform() == dbipWindows) { #ifdef Q_OS_WIN
addChildRow(_enableTaskbarIcon, marginLarge, lang(lng_settings_workmode_window), SLOT(onEnableTaskbarIcon()), (cWorkMode() == dbiwmWindowOnly || cWorkMode() == dbiwmWindowAndTray)); addChildRow(_enableTaskbarIcon, marginLarge, lang(lng_settings_workmode_window), SLOT(onEnableTaskbarIcon()), (cWorkMode() == dbiwmWindowOnly || cWorkMode() == dbiwmWindowAndTray));
addChildRow(_autoStart, marginSmall, lang(lng_settings_auto_start), SLOT(onAutoStart()), cAutoStart()); #ifndef OS_WIN_STORE
addChildRow(_startMinimized, marginLarge, slidedPadding, lang(lng_settings_start_min), SLOT(onStartMinimized()), (cStartMinimized() && !Global::LocalPasscode())); addChildRow(_autoStart, marginSmall, lang(lng_settings_auto_start), SLOT(onAutoStart()), cAutoStart());
subscribe(Global::RefLocalPasscodeChanged(), [this] { addChildRow(_startMinimized, marginLarge, slidedPadding, lang(lng_settings_start_min), SLOT(onStartMinimized()), (cStartMinimized() && !Global::LocalPasscode()));
_startMinimized->entity()->setChecked(cStartMinimized() && !Global::LocalPasscode()); subscribe(Global::RefLocalPasscodeChanged(), [this] {
}); _startMinimized->entity()->setChecked(cStartMinimized() && !Global::LocalPasscode());
if (!cAutoStart()) { });
_startMinimized->hideFast(); if (!cAutoStart()) {
} _startMinimized->hideFast();
addChildRow(_addInSendTo, marginSmall, lang(lng_settings_add_sendto), SLOT(onAddInSendTo()), cSendToMenu());
} }
addChildRow(_addInSendTo, marginSmall, lang(lng_settings_add_sendto), SLOT(onAddInSendTo()), cSendToMenu());
#endif // OS_WIN_STORE
#endif // Q_OS_WIN
} }
} }
@ -295,6 +297,7 @@ void GeneralWidget::updateWorkmode() {
Local::writeSettings(); Local::writeSettings();
} }
#if defined Q_OS_WIN && !defined OS_WIN_STORE
void GeneralWidget::onAutoStart() { void GeneralWidget::onAutoStart() {
cSetAutoStart(_autoStart->checked()); cSetAutoStart(_autoStart->checked());
if (cAutoStart()) { if (cAutoStart()) {
@ -332,5 +335,6 @@ void GeneralWidget::onAddInSendTo() {
psSendToMenu(_addInSendTo->checked()); psSendToMenu(_addInSendTo->checked());
Local::writeSettings(); Local::writeSettings();
} }
#endif // Q_OS_WIN && !OS_WIN_STORE
} // namespace Settings } // namespace Settings

View File

@ -94,9 +94,11 @@ private slots:
void onEnableTrayIcon(); void onEnableTrayIcon();
void onEnableTaskbarIcon(); void onEnableTaskbarIcon();
#if defined Q_OS_WIN && !defined OS_WIN_STORE
void onAutoStart(); void onAutoStart();
void onStartMinimized(); void onStartMinimized();
void onAddInSendTo(); void onAddInSendTo();
#endif // Q_OS_WIN && !OS_WIN_STORE
void onRestart(); void onRestart();

View File

@ -64,9 +64,9 @@ void filedialogInit() {
cSetDialogHelperPath(temppath.absolutePath()); cSetDialogHelperPath(temppath.absolutePath());
} }
} }
#else #else // Q_OS_WIN
cSetDialogLastPath(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)); cSetDialogLastPath(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
#endif #endif // Q_OS_WIN
} }
} }
@ -116,7 +116,8 @@ bool getFiles(QStringList &files, QByteArray &remoteContent, const QString &capt
#endif #endif
// hack for fast non-native dialog create // hack for fast non-native dialog create
QFileDialog dialog(App::wnd() ? App::wnd()->filedialogParent() : 0, caption, cDialogHelperPathFinal(), filter); auto helperPath = cDialogHelperPathFinal();
QFileDialog dialog(App::wnd() ? App::wnd()->filedialogParent() : 0, caption, helperPath, filter);
dialog.setModal(true); dialog.setModal(true);
if (type == Type::ReadFile || type == Type::ReadFiles) { if (type == Type::ReadFile || type == Type::ReadFiles) {
@ -132,7 +133,12 @@ bool getFiles(QStringList &files, QByteArray &remoteContent, const QString &capt
} }
dialog.show(); dialog.show();
if (!cDialogLastPath().isEmpty()) dialog.setDirectory(cDialogLastPath()); auto realLastPath = cDialogLastPath();
if (realLastPath.isEmpty() || realLastPath.endsWith(qstr("/tdummy"))) {
realLastPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
}
dialog.setDirectory(realLastPath);
if (type == Type::WriteFile) { if (type == Type::WriteFile) {
QString toSelect(startFile); QString toSelect(startFile);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN