Fix implicit conversions from QByteArray

This commit is contained in:
Ilya Fedin 2021-02-19 14:09:01 +04:00 committed by John Preston
parent 22cbf32a14
commit bbf49b024a
11 changed files with 60 additions and 56 deletions

View file

@ -642,7 +642,10 @@ std::pair<QString, QSize> WriteImageThumb(
? largePath.mid(0, firstDot) + postfix + largePath.mid(firstDot) ? largePath.mid(0, firstDot) + postfix + largePath.mid(firstDot)
: largePath + postfix; : largePath + postfix;
const auto result = Output::File::PrepareRelativePath(basePath, thumb); const auto result = Output::File::PrepareRelativePath(basePath, thumb);
if (!image.save(basePath + result, finalFormat, finalQuality)) { if (!image.save(
basePath + result,
finalFormat.constData(),
finalQuality)) {
return {}; return {};
} }
return { result, finalSize }; return { result, finalSize };

View file

@ -55,7 +55,7 @@ std::variant<ReadScanError, QByteArray> ProcessImage(QByteArray &&bytes) {
auto result = QByteArray(); auto result = QByteArray();
{ {
QBuffer buffer(&result); QBuffer buffer(&result);
if (!image.save(&buffer, QByteArray("JPG"), kJpegQuality)) { if (!image.save(&buffer, "JPG", kJpegQuality)) {
return ReadScanError::Unknown; return ReadScanError::Unknown;
} }
base::take(image); base::take(image);

View file

@ -29,7 +29,7 @@ namespace File {
void UnsafeOpenUrl(const QString &url) { void UnsafeOpenUrl(const QString &url) {
if (!g_app_info_launch_default_for_uri( if (!g_app_info_launch_default_for_uri(
url.toUtf8(), url.toUtf8().constData(),
nullptr, nullptr,
nullptr)) { nullptr)) {
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
@ -57,7 +57,10 @@ void UnsafeLaunch(const QString &filepath) {
const auto absolutePath = QFileInfo(filepath).absoluteFilePath(); const auto absolutePath = QFileInfo(filepath).absoluteFilePath();
if (!g_app_info_launch_default_for_uri( if (!g_app_info_launch_default_for_uri(
g_filename_to_uri(absolutePath.toUtf8(), nullptr, nullptr), g_filename_to_uri(
absolutePath.toUtf8().constData(),
nullptr,
nullptr),
nullptr, nullptr,
nullptr)) { nullptr)) {
if (!UnsafeShowOpenWith(filepath)) { if (!UnsafeShowOpenWith(filepath)) {

View file

@ -103,9 +103,9 @@ GSDMediaKeys::GSDMediaKeys() {
auto reply = g_dbus_connection_call_sync( auto reply = g_dbus_connection_call_sync(
_dbusConnection, _dbusConnection,
_service.toUtf8(), _service.toUtf8().constData(),
_objectPath.toUtf8(), _objectPath.toUtf8().constData(),
_interface.toUtf8(), _interface.toUtf8().constData(),
"GrabMediaPlayerKeys", "GrabMediaPlayerKeys",
g_variant_new( g_variant_new(
"(su)", "(su)",
@ -127,10 +127,10 @@ GSDMediaKeys::GSDMediaKeys() {
_signalId = g_dbus_connection_signal_subscribe( _signalId = g_dbus_connection_signal_subscribe(
_dbusConnection, _dbusConnection,
_service.toUtf8(), _service.toUtf8().constData(),
_interface.toUtf8(), _interface.toUtf8().constData(),
"MediaPlayerKeyPressed", "MediaPlayerKeyPressed",
_objectPath.toUtf8(), _objectPath.toUtf8().constData(),
nullptr, nullptr,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
KeyPressed, KeyPressed,
@ -150,9 +150,9 @@ GSDMediaKeys::~GSDMediaKeys() {
if (_grabbed) { if (_grabbed) {
auto reply = g_dbus_connection_call_sync( auto reply = g_dbus_connection_call_sync(
_dbusConnection, _dbusConnection,
_service.toUtf8(), _service.toUtf8().constData(),
_objectPath.toUtf8(), _objectPath.toUtf8().constData(),
_interface.toUtf8(), _interface.toUtf8().constData(),
"ReleaseMediaPlayerKeys", "ReleaseMediaPlayerKeys",
g_variant_new( g_variant_new(
"(s)", "(s)",

View file

@ -310,9 +310,7 @@ GtkFileDialog::GtkFileDialog(QWidget *parent, const QString &caption, const QStr
d.reset(new QGtkDialog(gtk_file_chooser_dialog_new("", nullptr, d.reset(new QGtkDialog(gtk_file_chooser_dialog_new("", nullptr,
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
// https://developer.gnome.org/gtk3/stable/GtkFileChooserDialog.html#gtk-file-chooser-dialog-new tr::lng_cancel(tr::now).toUtf8().constData(), GTK_RESPONSE_CANCEL,
// first_button_text doesn't need explicit conversion to char*, while all others are vardict
tr::lng_cancel(tr::now).toUtf8(), GTK_RESPONSE_CANCEL,
tr::lng_box_ok(tr::now).toUtf8().constData(), GTK_RESPONSE_OK, nullptr))); tr::lng_box_ok(tr::now).toUtf8().constData(), GTK_RESPONSE_OK, nullptr)));
d.data()->accept( d.data()->accept(
@ -400,7 +398,7 @@ bool GtkFileDialog::defaultNameFilterDisables() const {
void GtkFileDialog::setDirectory(const QString &directory) { void GtkFileDialog::setDirectory(const QString &directory) {
GtkDialog *gtkDialog = d->gtkDialog(); GtkDialog *gtkDialog = d->gtkDialog();
gtk_file_chooser_set_current_folder(gtk_file_chooser_cast(gtkDialog), directory.toUtf8()); gtk_file_chooser_set_current_folder(gtk_file_chooser_cast(gtkDialog), directory.toUtf8().constData());
} }
QDir GtkFileDialog::directory() const { QDir GtkFileDialog::directory() const {
@ -511,7 +509,7 @@ GtkFileChooserAction gtkFileChooserAction(QFileDialog::FileMode fileMode, QFileD
void GtkFileDialog::applyOptions() { void GtkFileDialog::applyOptions() {
GtkDialog *gtkDialog = d->gtkDialog(); GtkDialog *gtkDialog = d->gtkDialog();
gtk_window_set_title(gtk_window_cast(gtkDialog), _windowTitle.toUtf8()); gtk_window_set_title(gtk_window_cast(gtkDialog), _windowTitle.toUtf8().constData());
gtk_file_chooser_set_local_only(gtk_file_chooser_cast(gtkDialog), true); gtk_file_chooser_set_local_only(gtk_file_chooser_cast(gtkDialog), true);
const GtkFileChooserAction action = gtkFileChooserAction(_fileMode, _acceptMode); const GtkFileChooserAction action = gtkFileChooserAction(_fileMode, _acceptMode);
@ -532,12 +530,12 @@ void GtkFileDialog::applyOptions() {
for_const (const auto &filename, _initialFiles) { for_const (const auto &filename, _initialFiles) {
if (_acceptMode == QFileDialog::AcceptSave) { if (_acceptMode == QFileDialog::AcceptSave) {
QFileInfo fi(filename); QFileInfo fi(filename);
gtk_file_chooser_set_current_folder(gtk_file_chooser_cast(gtkDialog), fi.path().toUtf8()); gtk_file_chooser_set_current_folder(gtk_file_chooser_cast(gtkDialog), fi.path().toUtf8().constData());
gtk_file_chooser_set_current_name(gtk_file_chooser_cast(gtkDialog), fi.fileName().toUtf8()); gtk_file_chooser_set_current_name(gtk_file_chooser_cast(gtkDialog), fi.fileName().toUtf8().constData());
} else if (filename.endsWith('/')) { } else if (filename.endsWith('/')) {
gtk_file_chooser_set_current_folder(gtk_file_chooser_cast(gtkDialog), filename.toUtf8()); gtk_file_chooser_set_current_folder(gtk_file_chooser_cast(gtkDialog), filename.toUtf8().constData());
} else { } else {
gtk_file_chooser_select_filename(gtk_file_chooser_cast(gtkDialog), filename.toUtf8()); gtk_file_chooser_select_filename(gtk_file_chooser_cast(gtkDialog), filename.toUtf8().constData());
} }
} }
@ -549,19 +547,19 @@ void GtkFileDialog::applyOptions() {
GtkWidget *acceptButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_OK); GtkWidget *acceptButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_OK);
if (acceptButton) { if (acceptButton) {
/*if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept)) /*if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
gtk_button_set_label(gtk_button_cast(acceptButton), opts->labelText(QFileDialogOptions::Accept).toUtf8()); gtk_button_set_label(gtk_button_cast(acceptButton), opts->labelText(QFileDialogOptions::Accept).toUtf8().constData());
else*/ if (_acceptMode == QFileDialog::AcceptOpen) else*/ if (_acceptMode == QFileDialog::AcceptOpen)
gtk_button_set_label(gtk_button_cast(acceptButton), tr::lng_open_link(tr::now).toUtf8()); gtk_button_set_label(gtk_button_cast(acceptButton), tr::lng_open_link(tr::now).toUtf8().constData());
else else
gtk_button_set_label(gtk_button_cast(acceptButton), tr::lng_settings_save(tr::now).toUtf8()); gtk_button_set_label(gtk_button_cast(acceptButton), tr::lng_settings_save(tr::now).toUtf8().constData());
} }
GtkWidget *rejectButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_CANCEL); GtkWidget *rejectButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_CANCEL);
if (rejectButton) { if (rejectButton) {
/*if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject)) /*if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject))
gtk_button_set_label(gtk_button_cast(rejectButton), opts->labelText(QFileDialogOptions::Reject).toUtf8()); gtk_button_set_label(gtk_button_cast(rejectButton), opts->labelText(QFileDialogOptions::Reject).toUtf8().constData());
else*/ else*/
gtk_button_set_label(gtk_button_cast(rejectButton), tr::lng_cancel(tr::now).toUtf8()); gtk_button_set_label(gtk_button_cast(rejectButton), tr::lng_cancel(tr::now).toUtf8().constData());
} }
} }
} }
@ -579,7 +577,7 @@ void GtkFileDialog::setNameFilters(const QStringList &filters) {
auto name = filter;//.left(filter.indexOf(QLatin1Char('('))); auto name = filter;//.left(filter.indexOf(QLatin1Char('(')));
auto extensions = cleanFilterList(filter); auto extensions = cleanFilterList(filter);
gtk_file_filter_set_name(gtkFilter, name.isEmpty() ? extensions.join(QStringLiteral(", ")).toUtf8() : name.toUtf8()); gtk_file_filter_set_name(gtkFilter, name.isEmpty() ? extensions.join(QStringLiteral(", ")).toUtf8().constData() : name.toUtf8().constData());
for_const (auto &ext, extensions) { for_const (auto &ext, extensions) {
auto caseInsensitiveExt = QString(); auto caseInsensitiveExt = QString();
caseInsensitiveExt.reserve(4 * ext.size()); caseInsensitiveExt.reserve(4 * ext.size());
@ -593,7 +591,7 @@ void GtkFileDialog::setNameFilters(const QStringList &filters) {
} }
} }
gtk_file_filter_add_pattern(gtkFilter, caseInsensitiveExt.toUtf8()); gtk_file_filter_add_pattern(gtkFilter, caseInsensitiveExt.toUtf8().constData());
} }
gtk_file_chooser_add_filter(gtk_file_chooser_cast(gtkDialog), gtkFilter); gtk_file_chooser_add_filter(gtk_file_chooser_cast(gtkDialog), gtkFilter);

View file

@ -49,7 +49,7 @@ private:
}; };
OpenWithDialog::OpenWithDialog(const QString &filepath) OpenWithDialog::OpenWithDialog(const QString &filepath)
: _gfileInstance(g_file_new_for_path(filepath.toUtf8())) : _gfileInstance(g_file_new_for_path(filepath.toUtf8().constData()))
, _gtkWidget(gtk_app_chooser_dialog_new( , _gtkWidget(gtk_app_chooser_dialog_new(
nullptr, nullptr,
GTK_DIALOG_MODAL, GTK_DIALOG_MODAL,

View file

@ -537,9 +537,9 @@ void MainWindow::initHook() {
G_BUS_TYPE_SESSION, G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE, G_DBUS_PROXY_FLAGS_NONE,
nullptr, nullptr,
kSNIWatcherService.utf8(), kSNIWatcherService.utf8().constData(),
kSNIWatcherObjectPath.utf8(), kSNIWatcherObjectPath.utf8().constData(),
kSNIWatcherInterface.utf8(), kSNIWatcherInterface.utf8().constData(),
nullptr, nullptr,
nullptr); nullptr);

View file

@ -363,10 +363,10 @@ NotificationData::NotificationData(
_notificationRepliedSignalId = g_dbus_connection_signal_subscribe( _notificationRepliedSignalId = g_dbus_connection_signal_subscribe(
_dbusConnection, _dbusConnection,
kService.utf8(), kService.utf8().constData(),
kInterface.utf8(), kInterface.utf8().constData(),
"NotificationReplied", "NotificationReplied",
kObjectPath.utf8(), kObjectPath.utf8().constData(),
nullptr, nullptr,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
signalEmitted, signalEmitted,
@ -380,10 +380,10 @@ NotificationData::NotificationData(
_actionInvokedSignalId = g_dbus_connection_signal_subscribe( _actionInvokedSignalId = g_dbus_connection_signal_subscribe(
_dbusConnection, _dbusConnection,
kService.utf8(), kService.utf8().constData(),
kInterface.utf8(), kInterface.utf8().constData(),
"ActionInvoked", "ActionInvoked",
kObjectPath.utf8(), kObjectPath.utf8().constData(),
nullptr, nullptr,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
signalEmitted, signalEmitted,
@ -420,14 +420,14 @@ NotificationData::NotificationData(
_hints.emplace( _hints.emplace(
qsl("desktop-entry"), qsl("desktop-entry"),
g_variant_new_string(GetLauncherBasename().toUtf8())); g_variant_new_string(GetLauncherBasename().toUtf8().constData()));
_notificationClosedSignalId = g_dbus_connection_signal_subscribe( _notificationClosedSignalId = g_dbus_connection_signal_subscribe(
_dbusConnection, _dbusConnection,
kService.utf8(), kService.utf8().constData(),
kInterface.utf8(), kInterface.utf8().constData(),
"NotificationClosed", "NotificationClosed",
kObjectPath.utf8(), kObjectPath.utf8().constData(),
nullptr, nullptr,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
signalEmitted, signalEmitted,
@ -497,9 +497,9 @@ void NotificationData::show() {
g_dbus_connection_call( g_dbus_connection_call(
_dbusConnection, _dbusConnection,
kService.utf8(), kService.utf8().constData(),
kObjectPath.utf8(), kObjectPath.utf8().constData(),
kInterface.utf8(), kInterface.utf8().constData(),
"Notify", "Notify",
g_variant_new( g_variant_new(
"(susssasa{sv}i)", "(susssasa{sv}i)",
@ -559,9 +559,9 @@ void NotificationData::notificationShown(
void NotificationData::close() { void NotificationData::close() {
g_dbus_connection_call( g_dbus_connection_call(
_dbusConnection, _dbusConnection,
kService.utf8(), kService.utf8().constData(),
kObjectPath.utf8(), kObjectPath.utf8().constData(),
kInterface.utf8(), kInterface.utf8().constData(),
"CloseNotification", "CloseNotification",
g_variant_new("(u)", _notificationId), g_variant_new("(u)", _notificationId),
nullptr, nullptr,

View file

@ -743,7 +743,7 @@ void RegisterCustomScheme(bool force) {
.arg(neededCommandlineBuilder); .arg(neededCommandlineBuilder);
auto currentAppInfo = g_app_info_get_default_for_type( auto currentAppInfo = g_app_info_get_default_for_type(
kHandlerTypeName.utf8(), kHandlerTypeName.utf8().constData(),
true); true);
if (currentAppInfo) { if (currentAppInfo) {
@ -758,7 +758,7 @@ void RegisterCustomScheme(bool force) {
} }
auto registeredAppInfoList = g_app_info_get_recommended_for_type( auto registeredAppInfoList = g_app_info_get_recommended_for_type(
kHandlerTypeName.utf8()); kHandlerTypeName.utf8().constData());
for (auto l = registeredAppInfoList; l != nullptr; l = l->next) { for (auto l = registeredAppInfoList; l != nullptr; l = l->next) {
const auto currentRegisteredAppInfo = reinterpret_cast<GAppInfo*>( const auto currentRegisteredAppInfo = reinterpret_cast<GAppInfo*>(
@ -781,15 +781,15 @@ void RegisterCustomScheme(bool force) {
} }
auto newAppInfo = g_app_info_create_from_commandline( auto newAppInfo = g_app_info_create_from_commandline(
neededCommandlineBuilder.toUtf8(), neededCommandlineBuilder.toUtf8().constData(),
AppName.utf8(), AppName.utf8().constData(),
G_APP_INFO_CREATE_SUPPORTS_URIS, G_APP_INFO_CREATE_SUPPORTS_URIS,
&error); &error);
if (newAppInfo) { if (newAppInfo) {
g_app_info_set_as_default_for_type( g_app_info_set_as_default_for_type(
newAppInfo, newAppInfo,
kHandlerTypeName.utf8(), kHandlerTypeName.utf8().constData(),
&error); &error);
g_object_unref(newAppInfo); g_object_unref(newAppInfo);

View file

@ -107,7 +107,7 @@ PreparedFileThumbnail FinalizeFileThumbnail(
bool isSticker) { bool isSticker) {
prepared.name = isSticker ? qsl("thumb.webp") : qsl("thumb.jpg"); prepared.name = isSticker ? qsl("thumb.webp") : qsl("thumb.jpg");
if (FileThumbnailUploadRequired(filemime, filesize)) { if (FileThumbnailUploadRequired(filemime, filesize)) {
const auto format = QByteArray(isSticker ? "WEBP" : "JPG"); const auto format = isSticker ? "WEBP" : "JPG";
auto buffer = QBuffer(&prepared.bytes); auto buffer = QBuffer(&prepared.bytes);
prepared.image.save(&buffer, format, kThumbnailQuality); prepared.image.save(&buffer, format, kThumbnailQuality);
} }

@ -1 +1 @@
Subproject commit 1b540b38ed78e9a3cba93e9ba4ce4525ab692277 Subproject commit a92ba8f1ee41e8c56b3cfced8498b33ec270228e