telegram.me links support added for os x

This commit is contained in:
John Preston 2014-12-03 18:07:24 +03:00
parent 27de201bda
commit 0f414c1d5a
5 changed files with 28 additions and 4 deletions

View File

@ -1843,7 +1843,7 @@ void MainWidget::start(const MTPUser &user) {
}
void MainWidget::openLocalUrl(const QString &url) {
QRegularExpressionMatch m = QRegularExpression(qsl("^tg://resolve/\\?domain=([a-zA-Z0-9\\.\\_]+)$"), QRegularExpression::CaseInsensitiveOption).match(url.trimmed());
QRegularExpressionMatch m = QRegularExpression(qsl("^tg://resolve/?\\?domain=([a-zA-Z0-9\\.\\_]+)$"), QRegularExpression::CaseInsensitiveOption).match(url.trimmed());
if (m.hasMatch()) {
openUserByName(m.captured(1));
}

View File

@ -36,6 +36,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
@end
ApplicationDelegate *_sharedDelegate = nil;
@implementation ApplicationDelegate {
}
@ -54,8 +56,6 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
@end
ApplicationDelegate *_sharedDelegate = nil;
class QNSString {
public:
QNSString(const QString &str) : _str([NSString stringWithUTF8String:str.toUtf8().constData()]) {

View File

@ -734,6 +734,15 @@ QRect Window::iconRect() const {
bool Window::eventFilter(QObject *obj, QEvent *evt) {
if (obj == App::app() && (evt->type() == QEvent::ApplicationActivate)) {
QTimer::singleShot(1, this, SLOT(checkHistoryActivation()));
} else if (obj == App::app() && (evt->type() == QEvent::FileOpen)) {
QString url = static_cast<QFileOpenEvent*>(evt)->url().toEncoded();
if (!url.trimmed().midRef(0, 5).compare(qsl("tg://"), Qt::CaseInsensitive)) {
cSetStartUrl(url);
if (!cStartUrl().isEmpty() && App::main() && App::self()) {
App::main()->openLocalUrl(cStartUrl());
cSetStartUrl(QString());
}
}
} else if (obj == this && evt->type() == QEvent::WindowStateChange) {
Qt::WindowState state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized : ((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized : ((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
psStateChanged(state);

View File

@ -14,6 +14,21 @@
<string>0.6.15</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLIconFile</key>
<string>AppIcon.icns</string>
<key>CFBundleURLName</key>
<string>com.tdesktop.TelegramUrl</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tg</string>
</array>
</dict>
</array>
<key>NOTE</key>
<string></string>
<key>NSPrincipalClass</key>

View File

@ -411,7 +411,7 @@ static void cleanupCocoaApplicationDelegate()
{
Q_UNUSED(replyEvent);
NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
QWindowSystemInterface::handleFileOpenEvent(QCFString::toQString(urlString));
QWindowSystemInterface::handleFileOpenEvent(QUrl::fromNSURL([NSURL URLWithString:urlString]));
}
- (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent