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 + postfix;
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 { result, finalSize };

View File

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

View File

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

View File

@ -103,9 +103,9 @@ GSDMediaKeys::GSDMediaKeys() {
auto reply = g_dbus_connection_call_sync(
_dbusConnection,
_service.toUtf8(),
_objectPath.toUtf8(),
_interface.toUtf8(),
_service.toUtf8().constData(),
_objectPath.toUtf8().constData(),
_interface.toUtf8().constData(),
"GrabMediaPlayerKeys",
g_variant_new(
"(su)",
@ -127,10 +127,10 @@ GSDMediaKeys::GSDMediaKeys() {
_signalId = g_dbus_connection_signal_subscribe(
_dbusConnection,
_service.toUtf8(),
_interface.toUtf8(),
_service.toUtf8().constData(),
_interface.toUtf8().constData(),
"MediaPlayerKeyPressed",
_objectPath.toUtf8(),
_objectPath.toUtf8().constData(),
nullptr,
G_DBUS_SIGNAL_FLAGS_NONE,
KeyPressed,
@ -150,9 +150,9 @@ GSDMediaKeys::~GSDMediaKeys() {
if (_grabbed) {
auto reply = g_dbus_connection_call_sync(
_dbusConnection,
_service.toUtf8(),
_objectPath.toUtf8(),
_interface.toUtf8(),
_service.toUtf8().constData(),
_objectPath.toUtf8().constData(),
_interface.toUtf8().constData(),
"ReleaseMediaPlayerKeys",
g_variant_new(
"(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,
GTK_FILE_CHOOSER_ACTION_OPEN,
// https://developer.gnome.org/gtk3/stable/GtkFileChooserDialog.html#gtk-file-chooser-dialog-new
// 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_cancel(tr::now).toUtf8().constData(), GTK_RESPONSE_CANCEL,
tr::lng_box_ok(tr::now).toUtf8().constData(), GTK_RESPONSE_OK, nullptr)));
d.data()->accept(
@ -400,7 +398,7 @@ bool GtkFileDialog::defaultNameFilterDisables() const {
void GtkFileDialog::setDirectory(const QString &directory) {
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 {
@ -511,7 +509,7 @@ GtkFileChooserAction gtkFileChooserAction(QFileDialog::FileMode fileMode, QFileD
void GtkFileDialog::applyOptions() {
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);
const GtkFileChooserAction action = gtkFileChooserAction(_fileMode, _acceptMode);
@ -532,12 +530,12 @@ void GtkFileDialog::applyOptions() {
for_const (const auto &filename, _initialFiles) {
if (_acceptMode == QFileDialog::AcceptSave) {
QFileInfo fi(filename);
gtk_file_chooser_set_current_folder(gtk_file_chooser_cast(gtkDialog), fi.path().toUtf8());
gtk_file_chooser_set_current_name(gtk_file_chooser_cast(gtkDialog), fi.fileName().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().constData());
} 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 {
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);
if (acceptButton) {
/*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)
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
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);
if (rejectButton) {
/*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*/
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 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) {
auto caseInsensitiveExt = QString();
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);

View File

@ -49,7 +49,7 @@ private:
};
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(
nullptr,
GTK_DIALOG_MODAL,

View File

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

View File

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

View File

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

View File

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

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