Commit 3b58e4a9 authored by Ahmad Samir's avatar Ahmad Samir Committed by Tomaz Canabrava
Browse files

More Qt6 build fixes

- Port QStringRef to QStringView (using Q5StringRef::toInt() because
  Q5StringView::toInt() uses toString() internally to get a QString
  which defeats the point of using a view)
- Fix creating a QKeySequence from OR'ing Qt::Key and Qt::Modifiers by
  explicitly constructing a QKeySequence; IIUC, this is due to the two
  values coming from two different enums:
  "cannot convert ‘QIncompatibleFlag’ to ‘const QKeySequence&’"
- Implicit cast from int to QChar is gone in Qt6
- Implicit cast of QString to QFileInfo is gone in Qt6
- Create a QByteArray to make QStringBuilder work
- QHash::const_iterator can't be used in place of a
  QMultiHash::const_iterator
parent 38d5fa52
......@@ -190,7 +190,7 @@ void ViewManager::setupActions()
// keyboard shortcut only actions
action = new QAction(i18nc("@action Shortcut entry", "Next Tab"), this);
const QList<QKeySequence> nextViewActionKeys{Qt::SHIFT | Qt::Key_Right, Qt::CTRL | Qt::Key_PageDown};
const QList<QKeySequence> nextViewActionKeys{QKeySequence{Qt::SHIFT | Qt::Key_Right, Qt::CTRL | Qt::Key_PageDown}};
collection->setDefaultShortcuts(action, nextViewActionKeys);
collection->addAction(QStringLiteral("next-tab"), action);
connect(action, &QAction::triggered, this, &ViewManager::nextView);
......@@ -198,7 +198,7 @@ void ViewManager::setupActions()
// _viewSplitter->addAction(nextViewAction);
action = new QAction(i18nc("@action Shortcut entry", "Previous Tab"), this);
const QList<QKeySequence> previousViewActionKeys{Qt::SHIFT | Qt::Key_Left, Qt::CTRL | Qt::Key_PageUp};
const QList<QKeySequence> previousViewActionKeys{QKeySequence{Qt::SHIFT | Qt::Key_Left, Qt::CTRL | Qt::Key_PageUp}};
collection->setDefaultShortcuts(action, previousViewActionKeys);
collection->addAction(QStringLiteral("previous-tab"), action);
connect(action, &QAction::triggered, this, &ViewManager::previousView);
......@@ -238,7 +238,7 @@ void ViewManager::setupActions()
action = new QAction(i18nc("@action Shortcut entry", "Last Used Tabs"), this);
connect(action, &QAction::triggered, this, &ViewManager::lastUsedView);
collection->setDefaultShortcut(action, Qt::CTRL | Qt::Key_Tab);
collection->setDefaultShortcut(action, QKeySequence(Qt::CTRL | Qt::Key_Tab));
collection->addAction(QStringLiteral("last-used-tab"), action);
action = new QAction(i18nc("@action Shortcut entry", "Toggle Between Two Tabs"), this);
......@@ -297,7 +297,7 @@ void ViewManager::setupActions()
collection->setDefaultShortcut(action, QStringLiteral("Alt+%1").arg(i + 1));
} else if (i == 9) {
// add shortcut for 10th tab
collection->setDefaultShortcut(action, Qt::ALT | Qt::Key_0);
collection->setDefaultShortcut(action, QKeySequence(Qt::ALT | Qt::Key_0));
}
}
......
......@@ -834,7 +834,11 @@ void Vt102Emulation::processSessionAttributeRequest(int tokenSize)
}
if (var == QLatin1String("width")) {
int unitPos = val.toStdString().find_first_not_of("0123456789");
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
scaledWidth = QStringView(val).mid(0, unitPos).toInt();
#else
scaledWidth = val.midRef(0, unitPos).toInt();
#endif
if (unitPos == -1) {
scaledWidth *= _currentScreen->currentTerminalDisplay()->terminalFont()->fontWidth();
} else {
......@@ -845,7 +849,11 @@ void Vt102Emulation::processSessionAttributeRequest(int tokenSize)
}
if (var == QLatin1String("height")) {
int unitPos = val.toStdString().find_first_not_of("0123456789");
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
scaledHeight = QStringView(val).mid(0, unitPos).toInt();
#else
scaledHeight = val.midRef(0, unitPos).toInt();
#endif
if (unitPos == -1) {
scaledHeight *= _currentScreen->currentTerminalDisplay()->terminalFont()->fontHeight();
} else {
......@@ -1391,7 +1399,11 @@ void Vt102Emulation::processGraphicsToken(int tokenSize)
return;
}
if (list.at(i).at(2).isNumber() || list.at(i).at(2).toLatin1() == '-') {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
keys[list.at(i).at(0).toLatin1()] = QStringView(list.at(i)).mid(2).toInt();
#else
keys[list.at(i).at(0).toLatin1()] = list.at(i).midRef(2).toInt();
#endif
} else {
keys[list.at(i).at(0).toLatin1()] = list.at(i).at(2).toLatin1();
}
......@@ -1755,8 +1767,8 @@ void Vt102Emulation::sendMouseEvent(int cb, int cx, int cy, int eventType)
// coordinate+32, no matter what the locale is. We could easily
// convert manually, but QString can also do it for us.
QChar coords[2];
coords[0] = cx + 0x20;
coords[1] = cy + 0x20;
coords[0] = QChar(cx + 0x20);
coords[1] = QChar(cy + 0x20);
QString coordsStr = QString(coords, 2);
QByteArray utf8 = coordsStr.toUtf8();
snprintf(command, sizeof(command), "\033[M%c%s", cb + 0x20, utf8.constData());
......
......@@ -200,10 +200,8 @@ bool ColorSchemeManager::pathIsColorScheme(const QString &path)
bool ColorSchemeManager::isColorSchemeDeletable(const QString &name)
{
const QString path = findColorSchemePath(name);
QFileInfo fileInfo(path);
QFileInfo dirInfo = fileInfo.path();
QFileInfo fileInfo(findColorSchemePath(name));
QFileInfo dirInfo(fileInfo.path());
return dirInfo.isWritable();
}
......
......@@ -148,7 +148,7 @@ void HTMLDecoder::decodeLine(const Character *const characters, int count, LineP
}
} else {
// escape HTML tag characters and just display others as they are
const QChar ch = characters[i].character;
const QChar ch(characters[i].character);
if (ch == QLatin1Char('<')) {
text.append(QLatin1String("&lt;"));
} else if (ch == QLatin1Char('>')) {
......
......@@ -118,7 +118,7 @@ QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards, Qt::Keyb
}
if (replacement == 'x') {
result.replace(i, 1, "\\x" + QByteArray(1, ch).toHex());
result.replace(i, 1, QByteArray{"\\x" + QByteArray(1, ch).toHex()});
} else if (replacement != 0) {
result.remove(i, 1);
result.insert(i, '\\');
......@@ -134,7 +134,7 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray &text) const
QByteArray result(text);
for (int i = 0; i < result.count() - 1; i++) {
QByteRef ch = result[i];
auto ch = result[i];
if (ch == '\\') {
char replacement[2] = {0, 0};
int charsToRemove = 2;
......@@ -341,12 +341,12 @@ void KeyboardTranslator::removeEntry(const Entry &entry)
KeyboardTranslator::Entry KeyboardTranslator::findEntry(int keyCode, Qt::KeyboardModifiers modifiers, States state) const
{
QHash<int, KeyboardTranslator::Entry>::const_iterator i = _entries.find(keyCode);
while (i != _entries.constEnd() && i.key() == keyCode) {
if (i.value().matches(keyCode, modifiers, state)) {
return i.value();
auto it = _entries.find(keyCode);
while (it != _entries.constEnd() && it.key() == keyCode) {
if (it.value().matches(keyCode, modifiers, state)) {
return it.value();
}
++i;
++it;
}
return Entry(); // No matching entry
......
......@@ -241,9 +241,13 @@ bool KeyboardTranslatorReader::parseAsStateFlag(const QString &item, KeyboardTra
bool KeyboardTranslatorReader::parseAsKeyCode(const QString &item, int &keyCode)
{
QKeySequence sequence = QKeySequence::fromString(item);
const QKeySequence sequence = QKeySequence::fromString(item);
if (!sequence.isEmpty()) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
keyCode = sequence[0].toCombined();
#else
keyCode = sequence[0];
#endif
if (sequence.count() > 1) {
qCDebug(KonsoleDebug) << "Unhandled key codes in sequence: " << item;
......
......@@ -24,6 +24,7 @@
#include "konsolesession_export.h"
class QColor;
class QTextCodec;
class KConfigGroup;
class KProcess;
......
......@@ -729,7 +729,7 @@ void SessionController::setupCommonActions()
#else
collection->setDefaultShortcut(_findAction, Konsole::ACCEL | Qt::SHIFT | Qt::Key_F);
collection->setDefaultShortcut(_findNextAction, Qt::Key_F3);
collection->setDefaultShortcut(_findPreviousAction, Qt::SHIFT | Qt::Key_F3);
collection->setDefaultShortcut(_findPreviousAction, QKeySequence{Qt::SHIFT | Qt::Key_F3});
#endif
// Character Encoding
......
......@@ -2067,7 +2067,7 @@ QChar TerminalDisplay::charClass(const Character &ch) const
}
return letterOrNumber ? QLatin1Char('a') : s.at(0);
}
return 0;
return QChar{0};
} else {
const QChar qch(ch.character);
if (qch.isSpace()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment