mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Wrapped text recognition on macOS with experimental toggle.
This commit is contained in:
@@ -21,6 +21,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/platform/mac/base_confirm_quit.h"
|
||||
#include "base/platform/mac/base_utilities_mac.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "main/main_session.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "base/options.h"
|
||||
|
||||
#include <QtGui/QDesktopServices>
|
||||
#include <QtWidgets/QApplication>
|
||||
@@ -242,6 +245,15 @@ bool AutostartSkip() {
|
||||
}
|
||||
|
||||
void NewVersionLaunched(int oldVersion) {
|
||||
if (const auto window = Core::App().activeWindow()) {
|
||||
if (const auto controller = window->sessionController()) {
|
||||
const auto userId = controller->session().userId().bare;
|
||||
const auto hash = std::hash<uint64>{}(userId);
|
||||
if ((hash % 100) < 15 || (userId % 100) == 91) {
|
||||
base::options::lookup<bool>("text-recognition-mac").set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QImage DefaultApplicationIcon() {
|
||||
|
||||
@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "platform/platform_text_recognition.h"
|
||||
|
||||
#include "base/platform/mac/base_utilities_mac.h"
|
||||
#include "base/options.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Vision/Vision.h>
|
||||
@@ -16,9 +17,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
namespace Platform {
|
||||
namespace TextRecognition {
|
||||
|
||||
namespace {
|
||||
|
||||
base::options::toggle TextRecognitionOption({
|
||||
.id = "text-recognition-mac",
|
||||
.name = "Text Recognition",
|
||||
.description = "Enable text recognition from images on macOS 10.15+.",
|
||||
.defaultValue = false,
|
||||
.scope = base::options::macos,
|
||||
});
|
||||
|
||||
} // namespace
|
||||
|
||||
bool IsAvailable() {
|
||||
if (@available(macOS 10.15, *)) {
|
||||
return true;
|
||||
return TextRecognitionOption.value();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ void SetupExperimental(
|
||||
addToggle(Window::kOptionDisableTouchbar);
|
||||
addToggle(Info::kAlternativeScrollProcessing);
|
||||
addToggle("webauthn-mac");
|
||||
addToggle("text-recognition-mac");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user