1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Do not track clipboard on mobile systems to avoid permissions prompt

This commit is contained in:
Ivan Savenko
2025-03-26 16:00:31 +00:00
parent 8a0fed7b3a
commit 7d3e59d7d3
3 changed files with 38 additions and 13 deletions

View File

@@ -85,7 +85,7 @@ SDL_Surface * CSDL_Ext::newSurface(const Point & dimensions, SDL_Surface * mod)
std::string messagePattern = "Failed to create SDL Surface of size %d x %d, %d bpp. Reason: %s";
std::string message = boost::str(boost::format(messagePattern) % dimensions.x % dimensions.y % mod->format->BitsPerPixel % error);
handleFatalError(message, true);
throw std::runtime_error(message);
}
if (mod->format->palette)

View File

@@ -649,14 +649,15 @@
"additionalProperties" : false,
"required" : [
"setupCompleted",
"defaultRepositoryEnabled",
"defaultRepositoryURL",
"extraRepositoryURL",
"extraRepositoryEnabled",
"autoCheckRepositories",
"defaultRepositoryEnabled",
"defaultRepositoryURL",
"extraRepositoryURL",
"extraRepositoryEnabled",
"autoCheckRepositories",
"ignoreSslErrors",
"updateOnStartup",
"updateConfigUrl"
"updateOnStartup",
"updateConfigUrl",
"trackClipboardState"
],
"properties" : {
"defaultRepositoryEnabled" : {
@@ -694,7 +695,15 @@
"updateConfigUrl" : {
"type" : "string",
"default" : "https://raw.githubusercontent.com/vcmi/vcmi-updates/master/vcmi-updates.json"
}
},
"trackClipboardState" : {
"type" : "boolean",
"default" : true,
"defaultIOS": false,
"defaultAndroid": false,
"defaultDesktop" : true
},
}
},
"lobby" : {

View File

@@ -50,9 +50,11 @@ StartGameTab::StartGameTab(QWidget * parent)
ui->buttonGameEditor->hide();
#endif
auto clipboard = QGuiApplication::clipboard();
connect(clipboard, SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
if (settings["launcher"]["trackClipboardState"].Bool())
{
auto clipboard = QGuiApplication::clipboard();
connect(clipboard, SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
}
}
void StartGameTab::clipboardDataChanged()
@@ -103,7 +105,8 @@ void StartGameTab::refreshState()
refreshPresets();
refreshMods();
clipboardDataChanged();
if (settings["launcher"]["trackClipboardState"].Bool())
clipboardDataChanged();
}
void StartGameTab::refreshPresets()
@@ -405,9 +408,22 @@ void StartGameTab::on_buttonPresetExport_clicked()
void StartGameTab::on_buttonPresetImport_clicked()
{
QString presetString = QGuiApplication::clipboard()->text();
if (!presetString.startsWith("{"))
{
MessageBoxCustom::information(this, tr("Preset import failed"), tr("Failed to import preset - data in clipboard does not looks like mod preset!"));
return;
}
QByteArray presetBytes(presetString.toUtf8());
JsonNode presetJson(reinterpret_cast<const std::byte*>(presetBytes.data()), presetBytes.size(), "imported preset");
if (presetJson["name"].String().empty() || presetJson["mods"].Vector().empty())
{
MessageBoxCustom::information(this, tr("Preset import failed"), tr("Failed to import preset - data in clipboard does not looks like mod preset!"));
return;
}
getMainWindow()->getModView()->importPreset(presetJson);
getMainWindow()->switchToModsTab();
refreshPresets();