mirror of
https://github.com/KDE/konsole.git
synced 2026-06-11 07:26:10 -04:00
Use QStringLiteral and QLatin1String
This commit is contained in:
@@ -72,7 +72,7 @@ MainWindow::MainWindow()
|
||||
// If we are not using the global Konsole save geometry on exit,
|
||||
// remove all Height and Width from [MainWindow] from konsolerc
|
||||
// Each screen resolution will have entries (Width 1280=619)
|
||||
KSharedConfigPtr konsoleConfig = KSharedConfig::openConfig("konsolerc");
|
||||
KSharedConfigPtr konsoleConfig = KSharedConfig::openConfig(QStringLiteral("konsolerc"));
|
||||
KConfigGroup group = konsoleConfig->group("MainWindow");
|
||||
QMap<QString, QString> configEntries = group.entryMap();
|
||||
QMapIterator<QString, QString> i(configEntries);
|
||||
@@ -175,7 +175,7 @@ void MainWindow::restoreMenuAccelerators()
|
||||
void MainWindow::correctStandardShortcuts()
|
||||
{
|
||||
// replace F1 shortcut for help contents
|
||||
QAction* helpAction = actionCollection()->action("help_contents");
|
||||
QAction* helpAction = actionCollection()->action(QStringLiteral("help_contents"));
|
||||
if (helpAction) {
|
||||
actionCollection()->setDefaultShortcut(helpAction, QKeySequence());
|
||||
}
|
||||
@@ -183,7 +183,7 @@ void MainWindow::correctStandardShortcuts()
|
||||
// replace Ctrl+B shortcut for bookmarks only if user hasn't already
|
||||
// changed the shortcut; however, if the user changed it to Ctrl+B
|
||||
// this will still get changed to Ctrl+Shift+B
|
||||
QAction* bookmarkAction = actionCollection()->action("add_bookmark");
|
||||
QAction* bookmarkAction = actionCollection()->action(QStringLiteral("add_bookmark"));
|
||||
if (bookmarkAction && bookmarkAction->shortcut() == QKeySequence(Qt::CTRL + Qt::Key_B)) {
|
||||
actionCollection()->setDefaultShortcut(bookmarkAction, Qt::CTRL + Qt::SHIFT + Qt::Key_B);
|
||||
}
|
||||
@@ -295,24 +295,24 @@ void MainWindow::setupActions()
|
||||
collection->setShortcutsConfigurable(_newTabMenuAction, true);
|
||||
_newTabMenuAction->setAutoRepeat(false);
|
||||
connect(_newTabMenuAction, &KActionMenu::triggered, this, &Konsole::MainWindow::newTab);
|
||||
collection->addAction("new-tab", _newTabMenuAction);
|
||||
collection->addAction(QStringLiteral("new-tab"), _newTabMenuAction);
|
||||
collection->setShortcutsConfigurable(_newTabMenuAction, true);
|
||||
|
||||
menuAction = collection->addAction("clone-tab");
|
||||
menuAction = collection->addAction(QStringLiteral("clone-tab"));
|
||||
menuAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-duplicate")));
|
||||
menuAction->setText(i18nc("@action:inmenu", "&Clone Tab"));
|
||||
collection->setDefaultShortcut(menuAction, QKeySequence());
|
||||
menuAction->setAutoRepeat(false);
|
||||
connect(menuAction, &QAction::triggered, this, &Konsole::MainWindow::cloneTab);
|
||||
|
||||
menuAction = collection->addAction("new-window");
|
||||
menuAction = collection->addAction(QStringLiteral("new-window"));
|
||||
menuAction->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
|
||||
menuAction->setText(i18nc("@action:inmenu", "New &Window"));
|
||||
collection->setDefaultShortcut(menuAction, Qt::CTRL + Qt::SHIFT + Qt::Key_N);
|
||||
menuAction->setAutoRepeat(false);
|
||||
connect(menuAction, &QAction::triggered, this, &Konsole::MainWindow::newWindow);
|
||||
|
||||
menuAction = collection->addAction("close-window");
|
||||
menuAction = collection->addAction(QStringLiteral("close-window"));
|
||||
menuAction->setIcon(QIcon::fromTheme(QStringLiteral("window-close")));
|
||||
menuAction->setText(i18nc("@action:inmenu", "Close Window"));
|
||||
collection->setDefaultShortcut(menuAction, Qt::CTRL + Qt::SHIFT + Qt::Key_Q);
|
||||
@@ -321,7 +321,7 @@ void MainWindow::setupActions()
|
||||
// Bookmark Menu
|
||||
KActionMenu* bookmarkMenu = new KActionMenu(i18nc("@title:menu", "&Bookmarks"), collection);
|
||||
_bookmarkHandler = new BookmarkHandler(collection, bookmarkMenu->menu(), true, this);
|
||||
collection->addAction("bookmark", bookmarkMenu);
|
||||
collection->addAction(QStringLiteral("bookmark"), bookmarkMenu);
|
||||
connect(_bookmarkHandler, &Konsole::BookmarkHandler::openUrls, this, &Konsole::MainWindow::openUrls);
|
||||
|
||||
// Settings Menu
|
||||
@@ -336,13 +336,13 @@ void MainWindow::setupActions()
|
||||
KStandardAction::keyBindings(this, SLOT(showShortcutsDialog()), collection);
|
||||
KStandardAction::preferences(this, SLOT(showSettingsDialog()), collection);
|
||||
|
||||
menuAction = collection->addAction("manage-profiles");
|
||||
menuAction = collection->addAction(QStringLiteral("manage-profiles"));
|
||||
menuAction->setText(i18nc("@action:inmenu", "Manage Profiles..."));
|
||||
menuAction->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
|
||||
connect(menuAction, &QAction::triggered, this, &Konsole::MainWindow::showManageProfilesDialog);
|
||||
|
||||
// Set up an shortcut-only action for activating menu bar.
|
||||
menuAction = collection->addAction("activate-menu");
|
||||
menuAction = collection->addAction(QStringLiteral("activate-menu"));
|
||||
menuAction->setText(i18nc("@item", "Activate Menu"));
|
||||
collection->setDefaultShortcut(menuAction, Qt::CTRL + Qt::SHIFT + Qt::Key_F10);
|
||||
connect(menuAction, &QAction::triggered, this, &Konsole::MainWindow::activateMenuBar);
|
||||
@@ -387,7 +387,7 @@ void MainWindow::profileListChanged(const QList<QAction*>& sessionActions)
|
||||
// NOTE: defaultProfile seems to not work here, sigh.
|
||||
Profile::Ptr profile = ProfileManager::instance()->defaultProfile();
|
||||
if (profile && profile->name() == sessionAction->text().remove('&')) {
|
||||
QIcon icon(KIconLoader::global()->loadIcon(profile->icon(), KIconLoader::Small, 0, KIconLoader::DefaultState, QStringList("emblem-favorite")));
|
||||
QIcon icon(KIconLoader::global()->loadIcon(profile->icon(), KIconLoader::Small, 0, KIconLoader::DefaultState, QStringList(QStringLiteral("emblem-favorite"))));
|
||||
sessionAction->setIcon(icon);
|
||||
_newTabMenuAction->menu()->setDefaultAction(sessionAction);
|
||||
QFont actionFont = sessionAction->font();
|
||||
@@ -434,7 +434,7 @@ void MainWindow::openUrls(const QList<QUrl>& urls)
|
||||
if (url.isLocalFile())
|
||||
createSession(defaultProfile, url.path());
|
||||
|
||||
else if (url.scheme() == "ssh")
|
||||
else if (url.scheme() == QLatin1String("ssh"))
|
||||
createSSHSession(defaultProfile, url);
|
||||
}
|
||||
}
|
||||
@@ -470,7 +470,7 @@ Session* MainWindow::createSession(Profile::Ptr profile, const QString& director
|
||||
if (!directory.isEmpty() && profile->startInCurrentSessionDir())
|
||||
session->setInitialWorkingDirectory(directory);
|
||||
|
||||
session->addEnvironmentEntry(QString("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(_viewManager->managerId()));
|
||||
session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(_viewManager->managerId()));
|
||||
|
||||
// create view before starting the session process so that the session
|
||||
// doesn't suffer a change in terminal size right after the session
|
||||
@@ -488,9 +488,9 @@ Session* MainWindow::createSSHSession(Profile::Ptr profile, const QUrl& url)
|
||||
|
||||
Session* session = SessionManager::instance()->createSession(profile);
|
||||
|
||||
QString sshCommand = "ssh ";
|
||||
QString sshCommand = QStringLiteral("ssh ");
|
||||
if (url.port() > -1) {
|
||||
sshCommand += QString("-p %1 ").arg(url.port());
|
||||
sshCommand += QLatin1String("-p %1 ").arg(url.port());
|
||||
}
|
||||
if (!url.userName().isEmpty()) {
|
||||
sshCommand += (url.userName() + '@');
|
||||
@@ -574,10 +574,10 @@ bool MainWindow::queryClose()
|
||||
processesRunning.count()),
|
||||
processesRunning,
|
||||
i18nc("@title", "Confirm Close"),
|
||||
KGuiItem(i18nc("@action:button", "Close &Window"), "window-close"),
|
||||
KGuiItem(i18nc("@action:button", "Close Current &Tab"), "tab-close"),
|
||||
KGuiItem(i18nc("@action:button", "Close &Window"), QStringLiteral("window-close")),
|
||||
KGuiItem(i18nc("@action:button", "Close Current &Tab"), QStringLiteral("tab-close")),
|
||||
KStandardGuiItem::cancel(),
|
||||
"CloseAllTabs");
|
||||
QStringLiteral("CloseAllTabs"));
|
||||
|
||||
switch (result) {
|
||||
case KMessageBox::Yes:
|
||||
@@ -663,31 +663,31 @@ void MainWindow::showManageProfilesDialog()
|
||||
|
||||
void MainWindow::showSettingsDialog(const bool showProfilePage)
|
||||
{
|
||||
if (KConfigDialog::showDialog("settings"))
|
||||
if (KConfigDialog::showDialog(QStringLiteral("settings")))
|
||||
return;
|
||||
|
||||
KConfigDialog* settingsDialog = new KConfigDialog(this, "settings", KonsoleSettings::self());
|
||||
KConfigDialog* settingsDialog = new KConfigDialog(this, QStringLiteral("settings"), KonsoleSettings::self());
|
||||
settingsDialog->setFaceType(KPageDialog::Tabbed);
|
||||
|
||||
GeneralSettings* generalSettings = new GeneralSettings(settingsDialog);
|
||||
settingsDialog->addPage(generalSettings,
|
||||
i18nc("@title Preferences page name", "General"),
|
||||
"utilities-terminal");
|
||||
QStringLiteral("utilities-terminal"));
|
||||
|
||||
ProfileSettings* profileSettings = new ProfileSettings(settingsDialog);
|
||||
KPageWidgetItem* profilePage = settingsDialog->addPage(profileSettings,
|
||||
i18nc("@title Preferences page name", "Profiles"),
|
||||
"configure");
|
||||
QStringLiteral("configure"));
|
||||
|
||||
TabBarSettings* tabBarSettings = new TabBarSettings(settingsDialog);
|
||||
settingsDialog->addPage(tabBarSettings,
|
||||
i18nc("@title Preferences page name", "TabBar"),
|
||||
"system-run");
|
||||
QStringLiteral("system-run"));
|
||||
|
||||
FileLocationSettings* fileLocationSettings = new FileLocationSettings(settingsDialog);
|
||||
settingsDialog->addPage(fileLocationSettings,
|
||||
i18nc("@title Preferences page name", "File Location"),
|
||||
"configure");
|
||||
QStringLiteral("configure"));
|
||||
|
||||
if (showProfilePage)
|
||||
settingsDialog->setCurrentPage(profilePage);
|
||||
@@ -717,7 +717,7 @@ void MainWindow::applyKonsoleSettings()
|
||||
setNavigationStyleSheet(KonsoleSettings::tabBarStyleSheet());
|
||||
}
|
||||
|
||||
setAutoSaveSettings("MainWindow", KonsoleSettings::saveGeometryOnExit());
|
||||
setAutoSaveSettings(QStringLiteral("MainWindow"), KonsoleSettings::saveGeometryOnExit());
|
||||
|
||||
updateWindowCaption();
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ QString Part::foregroundProcessName()
|
||||
if (activeSession()->isForegroundProcessActive()) {
|
||||
return activeSession()->foregroundProcessName();
|
||||
} else {
|
||||
return "";
|
||||
return QLatin1String("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ void Part::changeSessionSettings(const QString& text)
|
||||
// send a profile change command, the escape code format
|
||||
// is the same as the normal X-Term commands used to change the window title or icon,
|
||||
// but with a magic value of '50' for the parameter which specifies what to change
|
||||
QString command = QString("\033]50;%1\a").arg(text);
|
||||
QString command = QStringLiteral("\033]50;%1\a").arg(text);
|
||||
|
||||
sendInput(command);
|
||||
}
|
||||
|
||||
@@ -123,12 +123,12 @@ QString ProcessInfo::format(const QString& input) const
|
||||
QString output(input);
|
||||
|
||||
// search for and replace known marker
|
||||
output.replace("%u", userName());
|
||||
output.replace("%h", localHost());
|
||||
output.replace("%n", name(&ok));
|
||||
output.replace(QLatin1String("%u"), userName());
|
||||
output.replace(QLatin1String("%h"), localHost());
|
||||
output.replace(QLatin1String("%n"), name(&ok));
|
||||
|
||||
QString dir = validCurrentDir();
|
||||
if (output.contains("%D")) {
|
||||
if (output.contains(QLatin1String("%D"))) {
|
||||
QString homeDir = userHomeDir();
|
||||
QString tempDir = dir;
|
||||
// Change User's Home Dir w/ ~ only at the beginning
|
||||
@@ -136,9 +136,9 @@ QString ProcessInfo::format(const QString& input) const
|
||||
tempDir.remove(0, homeDir.length());
|
||||
tempDir.prepend('~');
|
||||
}
|
||||
output.replace("%D", tempDir);
|
||||
output.replace(QLatin1String("%D"), tempDir);
|
||||
}
|
||||
output.replace("%d", formatShortDir(dir));
|
||||
output.replace(QLatin1String("%d"), formatShortDir(dir));
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -440,7 +440,7 @@ private:
|
||||
|
||||
// For user id read process status file ( /proc/<pid>/status )
|
||||
// Can not use getuid() due to it does not work for 'su'
|
||||
QFile statusInfo(QString("/proc/%1/status").arg(aPid));
|
||||
QFile statusInfo(QStringLiteral("/proc/%1/status").arg(aPid));
|
||||
if (statusInfo.open(QIODevice::ReadOnly)) {
|
||||
QTextStream stream(&statusInfo);
|
||||
QString statusLine;
|
||||
@@ -476,7 +476,7 @@ private:
|
||||
//
|
||||
// FIELD FIELD (FIELD WITH SPACES) FIELD FIELD
|
||||
//
|
||||
QFile processInfo(QString("/proc/%1/stat").arg(aPid));
|
||||
QFile processInfo(QStringLiteral("/proc/%1/stat").arg(aPid));
|
||||
if (processInfo.open(QIODevice::ReadOnly)) {
|
||||
QTextStream stream(&processInfo);
|
||||
const QString& data = stream.readAll();
|
||||
@@ -539,7 +539,7 @@ private:
|
||||
// the expected format is a list of strings delimited by null characters,
|
||||
// and ending in a double null character pair.
|
||||
|
||||
QFile argumentsFile(QString("/proc/%1/cmdline").arg(aPid));
|
||||
QFile argumentsFile(QStringLiteral("/proc/%1/cmdline").arg(aPid));
|
||||
if (argumentsFile.open(QIODevice::ReadOnly)) {
|
||||
QTextStream stream(&argumentsFile);
|
||||
const QString& data = stream.readAll();
|
||||
@@ -560,7 +560,7 @@ private:
|
||||
virtual bool readCurrentDir(int aPid) {
|
||||
char path_buffer[MAXPATHLEN + 1];
|
||||
path_buffer[MAXPATHLEN] = 0;
|
||||
QByteArray procCwd = QFile::encodeName(QString("/proc/%1/cwd").arg(aPid));
|
||||
QByteArray procCwd = QFile::encodeName(QStringLiteral("/proc/%1/cwd").arg(aPid));
|
||||
const int length = readlink(procCwd.constData(), path_buffer, MAXPATHLEN);
|
||||
if (length == -1) {
|
||||
setError(UnknownError);
|
||||
@@ -579,7 +579,7 @@ private:
|
||||
// the expected format is a list of KEY=VALUE strings delimited by null
|
||||
// characters and ending in a double null character pair.
|
||||
|
||||
QFile environmentFile(QString("/proc/%1/environ").arg(aPid));
|
||||
QFile environmentFile(QStringLiteral("/proc/%1/environ").arg(aPid));
|
||||
if (environmentFile.open(QIODevice::ReadOnly)) {
|
||||
QTextStream stream(&environmentFile);
|
||||
const QString& data = stream.readAll();
|
||||
@@ -1024,7 +1024,7 @@ SSHProcessInfo::SSHProcessInfo(const ProcessInfo& process)
|
||||
// check that this is a SSH process
|
||||
const QString& name = _process.name(&ok);
|
||||
|
||||
if (!ok || name != "ssh") {
|
||||
if (!ok || name != QLatin1String("ssh")) {
|
||||
if (!ok)
|
||||
qWarning() << "Could not read process info";
|
||||
else
|
||||
@@ -1040,9 +1040,9 @@ SSHProcessInfo::SSHProcessInfo(const ProcessInfo& process)
|
||||
// these are taken from the SSH manual ( accessed via 'man ssh' )
|
||||
|
||||
// options which take no arguments
|
||||
static const QString noArgumentOptions("1246AaCfgKkMNnqsTtVvXxYy");
|
||||
static const QString noArgumentOptions(QStringLiteral("1246AaCfgKkMNnqsTtVvXxYy"));
|
||||
// options which take one argument
|
||||
static const QString singleArgumentOptions("bcDeFIiLlmOopRSWw");
|
||||
static const QString singleArgumentOptions(QStringLiteral("bcDeFIiLlmOopRSWw"));
|
||||
|
||||
if (ok) {
|
||||
// find the username, host and command arguments
|
||||
@@ -1151,15 +1151,15 @@ QString SSHProcessInfo::format(const QString& input) const
|
||||
isIpAddress = false;
|
||||
|
||||
// search for and replace known markers
|
||||
output.replace("%u", _user);
|
||||
output.replace(QLatin1String("%u"), _user);
|
||||
|
||||
if (isIpAddress)
|
||||
output.replace("%h", _host);
|
||||
output.replace(QLatin1String("%h"), _host);
|
||||
else
|
||||
output.replace("%h", _host.left(_host.indexOf('.')));
|
||||
output.replace(QLatin1String("%h"), _host.left(_host.indexOf('.')));
|
||||
|
||||
output.replace("%H", _host);
|
||||
output.replace("%c", _command);
|
||||
output.replace(QLatin1String("%H"), _host);
|
||||
output.replace(QLatin1String("%c"), _command);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user