Skip to content

Commit f08c0d4

Browse files
committed
Fix QChar construction for Qt 6.9
1 parent f355f41 commit f08c0d4

File tree

13 files changed

+48
-31
lines changed

13 files changed

+48
-31
lines changed

plugins/itemencrypted/itemencrypted.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "common/textdata.h"
1414
#include "gui/icons.h"
1515
#include "gui/iconwidget.h"
16+
#include "gui/fromiconid.h"
1617
#include "item/serialize.h"
1718

1819
#ifdef HAS_TESTS
@@ -859,7 +860,7 @@ QVector<Command> ItemEncryptedLoader::commands() const
859860
Command c;
860861
c.internalId = QStringLiteral("copyq_encrypted_encrypt");
861862
c.name = ItemEncryptedLoader::tr("Encrypt (needs GnuPG)");
862-
c.icon = QString(QChar(IconLock));
863+
c.icon = fromIconId(IconLock);
863864
c.input = "!OUTPUT";
864865
c.output = mimeEncryptedData;
865866
c.inMenu = true;
@@ -870,7 +871,7 @@ QVector<Command> ItemEncryptedLoader::commands() const
870871
c = Command();
871872
c.internalId = QStringLiteral("copyq_encrypted_decrypt");
872873
c.name = ItemEncryptedLoader::tr("Decrypt");
873-
c.icon = QString(QChar(IconUnlock));
874+
c.icon = fromIconId(IconUnlock);
874875
c.input = mimeEncryptedData;
875876
c.output = mimeItems;
876877
c.inMenu = true;
@@ -881,7 +882,7 @@ QVector<Command> ItemEncryptedLoader::commands() const
881882
c = Command();
882883
c.internalId = QStringLiteral("copyq_encrypted_decrypt_and_copy");
883884
c.name = ItemEncryptedLoader::tr("Decrypt and Copy");
884-
c.icon = QString(QChar(IconUnlockKeyhole));
885+
c.icon = fromIconId(IconUnlockKeyhole);
885886
c.input = mimeEncryptedData;
886887
c.inMenu = true;
887888
c.cmd = "copyq: plugins.itemencrypted.copyEncryptedItems()";
@@ -891,7 +892,7 @@ QVector<Command> ItemEncryptedLoader::commands() const
891892
c = Command();
892893
c.internalId = QStringLiteral("copyq_encrypted_decrypt_and_paste");
893894
c.name = ItemEncryptedLoader::tr("Decrypt and Paste");
894-
c.icon = QString(QChar(IconUnlockKeyhole));
895+
c.icon = fromIconId(IconUnlockKeyhole);
895896
c.input = mimeEncryptedData;
896897
c.inMenu = true;
897898
c.cmd = "copyq: plugins.itemencrypted.pasteEncryptedItems()";

plugins/itemfakevim/fakevim/fakevimhandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ QString quoteUnprintable(const QString &ba)
10331033
else if (cc == '\n')
10341034
res += "<CR>";
10351035
else
1036-
res += QString("\\x%1").arg(c.unicode(), 2, 16, QLatin1Char('0'));
1036+
res += QString("\\x%1").arg(cc, 2, 16, QLatin1Char('0'));
10371037
}
10381038
return res;
10391039
}

plugins/itempinned/itempinned.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "common/command.h"
66
#include "common/contenttype.h"
77
#include "common/display.h"
8+
#include "gui/fromiconid.h"
89

910
#ifdef HAS_TESTS
1011
# include "tests/itempinnedtests.h"
@@ -32,7 +33,7 @@ bool isPinned(const QModelIndex &index)
3233
Command dummyPinCommand()
3334
{
3435
Command c;
35-
c.icon = QString(QChar(IconThumbtack));
36+
c.icon = fromIconId(IconThumbtack);
3637
c.inMenu = true;
3738
return c;
3839
}

plugins/itemsync/itemsync.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "gui/icons.h"
1616
#include "gui/iconfont.h"
1717
#include "gui/iconwidget.h"
18+
#include "gui/fromiconid.h"
1819
#include "item/itemfilter.h"
1920

2021
#ifdef HAS_TESTS
@@ -100,7 +101,7 @@ void writeConfiguration(QIODevice *file, const QStringList &savedFiles)
100101

101102
QString iconFromId(int id)
102103
{
103-
return id != -1 ? QString(QChar(id)) : QString();
104+
return id != -1 ? fromIconId(id) : QString();
104105
}
105106

106107
QPushButton *createBrowseButton()

plugins/itemtags/itemtags.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "common/textdata.h"
1111
#include "gui/iconfont.h"
1212
#include "gui/iconselectbutton.h"
13+
#include "gui/fromiconid.h"
1314
#include "gui/pixelratio.h"
1415
#include "item/itemfilter.h"
1516

@@ -153,7 +154,7 @@ QString removeTagText()
153154
Command dummyTagCommand()
154155
{
155156
Command c;
156-
c.icon = QString(QChar(IconTag));
157+
c.icon = fromIconId(IconTag);
157158
c.inMenu = true;
158159
return c;
159160
}

src/common/globalshortcutcommands.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "globalshortcutcommands.h"
44

55
#include "common/command.h"
6+
#include "gui/fromiconid.h"
67

78
#include <QCoreApplication>
89
#include <QLocale>
@@ -50,7 +51,7 @@ Command createGlobalShortcut(const QString &name, const QString &script, IconId
5051
c.internalId = internalId;
5152
c.name = name;
5253
c.cmd = "copyq: " + script;
53-
c.icon = QString(QChar(icon));
54+
c.icon = fromIconId(icon);
5455
c.isGlobalShortcut = true;
5556
return c;
5657
}

src/common/predefinedcommands.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "common/shortcuts.h"
99
#include "common/textdata.h"
1010
#include "gui/icons.h"
11+
#include "gui/fromiconid.h"
1112
#include "platform/platformnativeinterface.h"
1213

1314
#include <QCoreApplication>
@@ -38,14 +39,14 @@ QVector<Command> predefinedCommands()
3839
commands.prepend(Command());
3940
c = &commands.first();
4041
c->name = AddCommandDialog::tr("New command");
41-
c->icon = QString(QChar(IconFile));
42+
c->icon = fromIconId(IconFile);
4243
c->input = c->output = QString();
4344
c->wait = c->automatic = c->remove = false;
4445
c->sep = QLatin1String("\\n");
4546

4647
c = newCommand(&commands);
4748
c->name = AddCommandDialog::tr("Ignore items with no or single character");
48-
c->icon = QString(QChar(IconCircleExclamation));
49+
c->icon = fromIconId(IconCircleExclamation);
4950
c->cmd = R"(function hasEmptyOrSingleCharText() {
5051
if (dataFormats().includes(mimeText)) {
5152
const text = str(data(mimeText));
@@ -75,23 +76,23 @@ overrideFunction('provideSelection');
7576
c = newCommand(&commands);
7677
c->name = AddCommandDialog::tr("Open in &Browser");
7778
c->re = reURL;
78-
c->icon = QString(QChar(IconGlobe));
79+
c->icon = fromIconId(IconGlobe);
7980
c->cmd = QStringLiteral("copyq open %1");
8081
c->hideWindow = true;
8182
c->inMenu = true;
8283

8384
c = newCommand(&commands);
8485
c->name = AddCommandDialog::tr("Paste as Plain Text");
8586
c->input = mimeText;
86-
c->icon = QString(QChar(IconPaste));
87+
c->icon = fromIconId(IconPaste);
8788
c->cmd = QStringLiteral("copyq:") + pasteAsPlainTextScript("input()");
8889
c->hideWindow = true;
8990
c->inMenu = true;
9091

9192
c = newCommand(&commands);
9293
c->name = AddCommandDialog::tr("Autoplay videos");
9394
c->re = QRegularExpression("^http://.*\\.(mp4|avi|mkv|wmv|flv|ogv)$");
94-
c->icon = QString(QChar(IconCirclePlay));
95+
c->icon = fromIconId(IconCirclePlay);
9596
c->cmd = QStringLiteral("copyq open %1");
9697
c->automatic = true;
9798
c->hideWindow = true;
@@ -100,13 +101,13 @@ overrideFunction('provideSelection');
100101
c = newCommand(&commands);
101102
c->name = AddCommandDialog::tr("Copy URL (web address) to other tab");
102103
c->re = reURL;
103-
c->icon = QString(QChar(IconCopy));
104+
c->icon = fromIconId(IconCopy);
104105
c->tab = QStringLiteral("&web");
105106
c->automatic = true;
106107

107108
c = newCommand(&commands);
108109
c->name = AddCommandDialog::tr("Create thumbnail (needs ImageMagick)");
109-
c->icon = QString(QChar(IconImage));
110+
c->icon = fromIconId(IconImage);
110111
c->cmd = QStringLiteral("convert - -resize 92x92 png:-");
111112
c->input = QStringLiteral("image/png");
112113
c->output = QStringLiteral("image/png");
@@ -115,7 +116,7 @@ overrideFunction('provideSelection');
115116
c = newCommand(&commands);
116117
c->name = AddCommandDialog::tr("Create QR Code from URL (needs qrencode)");
117118
c->re = reURL;
118-
c->icon = QString(QChar(IconQrcode));
119+
c->icon = fromIconId(IconQrcode);
119120
c->cmd = QStringLiteral("qrencode -o - -t PNG -s 6");
120121
c->input = mimeText;
121122
c->output = QStringLiteral("image/png");
@@ -126,23 +127,23 @@ overrideFunction('provideSelection');
126127
c = newCommand(&commands);
127128
c->name = AddCommandDialog::tr("Add to %1 tab", "%1 is quoted Tasks tab name")
128129
.arg(todoTabQuoted);
129-
c->icon = QString(QChar(IconShare));
130+
c->icon = fromIconId(IconShare);
130131
c->tab = todoTab;
131132
c->input = mimeText;
132133
c->inMenu = true;
133134

134135
c = newCommand(&commands);
135136
c->name = AddCommandDialog::tr("Move to %1 tab", "%1 is quoted Tasks tab name")
136137
.arg(todoTabQuoted);
137-
c->icon = QString(QChar(IconShare));
138+
c->icon = fromIconId(IconShare);
138139
c->tab = todoTab;
139140
c->remove = true;
140141
c->inMenu = true;
141142

142143
c = newCommand(&commands);
143144
c->name = AddCommandDialog::tr("Ignore copied files");
144145
c->re = reNotURL;
145-
c->icon = QString(QChar(IconCircleExclamation));
146+
c->icon = fromIconId(IconCircleExclamation);
146147
c->input = mimeUriList;
147148
c->remove = true;
148149
c->automatic = true;
@@ -151,22 +152,22 @@ overrideFunction('provideSelection');
151152
c = newCommand(&commands);
152153
c->name = AddCommandDialog::tr("Ignore *\"Password\"* window");
153154
c->wndre = QRegularExpression(AddCommandDialog::tr("Password"));
154-
c->icon = QString(QChar(IconAsterisk));
155+
c->icon = fromIconId(IconAsterisk);
155156
c->remove = true;
156157
c->automatic = true;
157158
c->cmd = QStringLiteral("copyq ignore");
158159
}
159160

160161
c = newCommand(&commands);
161162
c->name = AddCommandDialog::tr("Move to Trash");
162-
c->icon = QString(QChar(IconTrash));
163+
c->icon = fromIconId(IconTrash);
163164
c->inMenu = true;
164165
c->tab = AddCommandDialog::tr("(trash)");
165166
c->remove = true;
166167

167168
c = newCommand(&commands);
168169
c->name = AddCommandDialog::tr("Clear Current Tab");
169-
c->icon = QString(QChar(IconBroom));
170+
c->icon = fromIconId(IconBroom);
170171
c->inMenu = true;
171172
c->cmd = QStringLiteral("copyq: ItemSelection(selectedTab()).selectRemovable().removeAll()");
172173
c->matchCmd = QStringLiteral("copyq: tab(selectedTab()); if (size() == 0) fail()");

src/gui/commanddialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "gui/commandwidget.h"
1414
#include "gui/iconfactory.h"
1515
#include "gui/icons.h"
16+
#include "gui/fromiconid.h"
1617
#include "platform/platformclipboard.h"
1718
#include "platform/platformnativeinterface.h"
1819

@@ -48,7 +49,7 @@ QIcon getCommandIcon(const QString &iconString, int commandType)
4849
: commandType & CommandType::Menu ? QColor(100,220,255)
4950
: QColor(255,100,100);
5051

51-
return iconFromFile(iconString, QString(QChar(icon)), color);
52+
return iconFromFile(iconString, fromIconId(icon), color);
5253
}
5354

5455
bool hasCommandsToPaste(const QString &text)

src/gui/fromiconid.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
#pragma once
3+
4+
#include <QChar>
5+
#include <QString>
6+
7+
inline QString fromIconId(int id) {
8+
return QString(QChar(id));
9+
}

src/gui/iconfactory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "iconfactory.h"
44

55
#include "gui/fix_icon_id.h"
6-
#include "gui/icons.h"
76
#include "gui/iconfont.h"
7+
#include "gui/fromiconid.h"
88
#include "gui/pixelratio.h"
99

1010
#include <QBitmap>
@@ -265,7 +265,7 @@ QPixmap drawFontIcon(ushort id, int w, int h, const QColor &color)
265265

266266
// Center the icon to whole pixels so it stays sharp.
267267
const auto flags = Qt::AlignTop | Qt::AlignLeft;
268-
const auto iconText = QString(QChar(id));
268+
const auto iconText = fromIconId(id);
269269
auto boundingRect = painter.boundingRect(0, 0, w, h, flags, iconText);
270270
const auto x = w - boundingRect.width();
271271
// If icon is wider, assume that a tag will be rendered and align image to the right.

0 commit comments

Comments
 (0)