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

Replace str_const with base::const_string.

This commit is contained in:
John Preston
2020-01-29 12:44:37 +03:00
parent c03df169b3
commit 74d848311b
18 changed files with 89 additions and 114 deletions

View File

@@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Platform {
namespace {
constexpr auto kLauncherBasename = str_const(MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME) ".desktop");
constexpr auto kLauncherBasename = MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME) ".desktop"_cs;
bool noQtTrayIcon = false, tryAppIndicator = false;
bool useGtkBase = false, useAppIndicator = false, useStatusIcon = false, trayIconChecked = false, useUnityCount = false;
@@ -557,9 +557,9 @@ void MainWindow::psFirstShow() {
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
if (QDBusInterface("com.canonical.Unity", "/").isValid()) {
auto snapName = QString::fromLatin1(qgetenv("SNAP_NAME"));
if(snapName.isEmpty()) {
if (snapName.isEmpty()) {
std::vector<QString> possibleDesktopFiles = {
str_const_toString(kLauncherBasename),
kLauncherBasename.utf16(),
"Telegram.desktop"
};
@@ -577,10 +577,10 @@ void MainWindow::psFirstShow() {
} else {
LOG(("SNAP Environment detected, setting Launcher entry to %1_%2.desktop!")
.arg(snapName)
.arg(str_const_toString(kLauncherBasename)));
.arg(kLauncherBasename.utf16()));
_desktopFile = snapName
+ '_'
+ str_const_toString(kLauncherBasename);
+ kLauncherBasename.utf16();
useUnityCount=true;
}
_dbusPath = "/com/canonical/unity/launcherentry/" + QString::number(djbStringHash("application://" + _desktopFile));

View File

@@ -23,8 +23,8 @@ namespace Notifications {
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
namespace {
constexpr auto kService = str_const("org.freedesktop.Notifications");
constexpr auto kObjectPath = str_const("/org/freedesktop/Notifications");
constexpr auto kService = "org.freedesktop.Notifications"_cs;
constexpr auto kObjectPath = "/org/freedesktop/Notifications"_cs;
constexpr auto kInterface = kService;
std::vector<QString> GetServerInformation(
@@ -112,9 +112,9 @@ NotificationData::NotificationData(
_actions << qsl("default") << QString();
_notificationInterface->connection().connect(
str_const_toString(kService),
str_const_toString(kObjectPath),
str_const_toString(kInterface),
kService.utf16(),
kObjectPath.utf16(),
kInterface.utf16(),
qsl("ActionInvoked"),
this,
SLOT(notificationClicked(uint)));
@@ -124,9 +124,9 @@ NotificationData::NotificationData(
<< tr::lng_notification_reply(tr::now);
_notificationInterface->connection().connect(
str_const_toString(kService),
str_const_toString(kObjectPath),
str_const_toString(kInterface),
kService.utf16(),
kObjectPath.utf16(),
kInterface.utf16(),
qsl("NotificationReplied"),
this,
SLOT(notificationReplied(uint,QString)));
@@ -161,9 +161,9 @@ NotificationData::NotificationData(
qsl(MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME));
_notificationInterface->connection().connect(
str_const_toString(kService),
str_const_toString(kObjectPath),
str_const_toString(kInterface),
kService.utf16(),
kObjectPath.utf16(),
kInterface.utf16(),
qsl("NotificationClosed"),
this,
SLOT(notificationClosed(uint)));
@@ -172,7 +172,7 @@ NotificationData::NotificationData(
bool NotificationData::show() {
const QDBusReply<uint> notifyReply = _notificationInterface->call(
qsl("Notify"),
str_const_toString(AppName),
AppName.utf16(),
uint(0),
QString(),
_title,
@@ -311,9 +311,10 @@ const QDBusArgument &operator>>(const QDBusArgument &argument,
bool Supported() {
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
static const auto Available = QDBusInterface(
str_const_toString(kService),
str_const_toString(kObjectPath),
str_const_toString(kInterface)).isValid();
kService.utf16(),
kObjectPath.utf16(),
kInterface.utf16()
).isValid();
return Available;
#else
@@ -335,10 +336,11 @@ std::unique_ptr<Window::Notifications::Manager> Create(
Manager::Private::Private(Manager *manager, Type type)
: _cachedUserpics(type)
, _manager(manager)
, _notificationInterface(std::make_shared<QDBusInterface>(
str_const_toString(kService),
str_const_toString(kObjectPath),
str_const_toString(kInterface))) {
, _notificationInterface(
std::make_shared<QDBusInterface>(
kService.utf16(),
kObjectPath.utf16(),
kInterface.utf16())) {
qDBusRegisterMetaType<NotificationData::ImageData>();
const auto specificationVersion = ParseSpecificationVersion(

View File

@@ -42,7 +42,7 @@ using Platform::File::internal::EscapeShell;
namespace {
constexpr auto kDesktopFile = str_const(":/misc/telegramdesktop.desktop");
constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs;
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
void SandboxAutostart(bool autostart) {
@@ -121,14 +121,14 @@ bool GenerateDesktopFile(const QString &targetPath, const QString &args) {
QString fileText;
QFile source(str_const_toString(kDesktopFile));
QFile source(kDesktopFile.utf16());
if (source.open(QIODevice::ReadOnly)) {
QTextStream s(&source);
fileText = s.readAll();
source.close();
} else {
LOG(("App Error: Could not open '%1' for read")
.arg(str_const_toString(kDesktopFile)));
.arg(kDesktopFile.utf16()));
return false;
}