Port to KF5/Qt5

TerminalDisplayAccessible is disabled for Qt5 currently since I don't
have any experience with accessible stuff and it is more complicated
than just changing a few includes

REVIEW: 111937
This commit is contained in:
Alex Richardson
2013-08-20 23:34:35 +02:00
parent 205a51839c
commit a83db71590
33 changed files with 184 additions and 120 deletions

View File

@@ -50,8 +50,10 @@
#include <KDebug>
#include <KUriFilter>
#include <KStringHandler>
#include <KSharedConfig>
#include <KConfigGroup>
#include <KGlobal>
#include <KShortcut>
#include <kdeversion.h>
#if KDE_IS_VERSION(4, 9, 1)
@@ -90,9 +92,10 @@ using namespace Konsole;
// TODO - Replace the icon choices below when suitable icons for silence and
// activity are available
const KIcon SessionController::_activityIcon("dialog-information");
const KIcon SessionController::_silenceIcon("dialog-information");
const KIcon SessionController::_broadcastIcon("emblem-important");
//having global static KIcons no longer works with Qt5/KF5, use K_GLOBAL_STATIC
K_GLOBAL_STATIC_WITH_ARGS(KIcon, _activityIcon, ("dialog-information"));
K_GLOBAL_STATIC_WITH_ARGS(KIcon, _silenceIcon, ("dialog-information"));
K_GLOBAL_STATIC_WITH_ARGS(KIcon, _broadcastIcon, ("emblem-important"));
QSet<SessionController*> SessionController::_allControllers;
int SessionController::_lastControllerId;
@@ -548,7 +551,8 @@ void SessionController::setShowMenuAction(QAction* action)
void SessionController::setupCommonActions()
{
KAction* action = 0;
QAction* action = 0;
KActionCollection* collection = actionCollection();
// Close Session
@@ -573,10 +577,10 @@ void SessionController::setupCommonActions()
action->setEnabled(false);
action = KStandardAction::paste(this, SLOT(paste()), collection);
KShortcut pasteShortcut = action->shortcut();
pasteShortcut.setPrimary(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
pasteShortcut.setAlternate(QKeySequence(Qt::SHIFT + Qt::Key_Insert));
action->setShortcut(pasteShortcut);
QList<QKeySequence> pasteShortcut;
pasteShortcut.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
pasteShortcut.append(QKeySequence(Qt::SHIFT + Qt::Key_Insert));
action->setShortcuts(pasteShortcut);
action = collection->addAction("paste-selection", this, SLOT(pasteFromX11Selection()));
action->setText(i18n("Paste Selection"));
@@ -643,7 +647,7 @@ void SessionController::setupCommonActions()
void SessionController::setupExtraActions()
{
KAction* action = 0;
QAction* action = 0;
KToggleAction* toggleAction = 0;
KActionCollection* collection = actionCollection();
@@ -702,15 +706,16 @@ void SessionController::setupExtraActions()
action = collection->addAction("enlarge-font", this, SLOT(increaseFontSize()));
action->setText(i18n("Enlarge Font"));
action->setIcon(KIcon("format-font-size-more"));
KShortcut enlargeFontShortcut = action->shortcut();
enlargeFontShortcut.setPrimary(QKeySequence(Qt::CTRL + Qt::Key_Plus));
enlargeFontShortcut.setAlternate(QKeySequence(Qt::CTRL + Qt::Key_Equal));
action->setShortcut(enlargeFontShortcut);
QList<QKeySequence> enlargeFontShortcut;
enlargeFontShortcut.append(QKeySequence(Qt::CTRL + Qt::Key_Plus));
enlargeFontShortcut.append(QKeySequence(Qt::CTRL + Qt::Key_Equal));
action->setShortcuts(enlargeFontShortcut);
action = collection->addAction("shrink-font", this, SLOT(decreaseFontSize()));
action->setText(i18n("Shrink Font"));
action->setIcon(KIcon("format-font-size-less"));
action->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Minus));
action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus));
// Send signal
KSelectAction* sendSignalActions = collection->add<KSelectAction>("send-signal");
@@ -918,10 +923,11 @@ void SessionController::openBrowser()
{
KUrl currentUrl = url();
if (currentUrl.isLocalFile())
new KRun(currentUrl, QApplication::activeWindow(), 0, true, true);
else
new KRun(KUrl(QDir::homePath()), QApplication::activeWindow(), 0, true, true);
if (currentUrl.isLocalFile()) {
new KRun(currentUrl, QApplication::activeWindow(), true);
} else {
new KRun(QUrl::fromLocalFile(QDir::homePath()), QApplication::activeWindow(), true);
}
}
void SessionController::copy()
@@ -1381,7 +1387,7 @@ void SessionController::updateSessionIcon()
// Visualize that the session is broadcasting to others
if (_copyToGroup && _copyToGroup->sessions().count() > 1) {
// Master Mode: set different icon, to warn the user to be careful
setIcon(_broadcastIcon);
setIcon(*_broadcastIcon);
} else {
if (!_keepIconUntilInteraction) {
// Not in Master Mode: use normal icon
@@ -1393,7 +1399,7 @@ void SessionController::sessionTitleChanged()
{
if (_sessionIconName != _session->iconName()) {
_sessionIconName = _session->iconName();
_sessionIcon = KIcon(_sessionIconName);
_sessionIcon = QIcon::fromTheme(_sessionIconName);
updateSessionIcon();
}
@@ -1484,10 +1490,10 @@ void SessionController::sessionStateChanged(int state)
return;
if (state == NOTIFYACTIVITY) {
setIcon(_activityIcon);
setIcon(*_activityIcon);
_keepIconUntilInteraction = true;
} else if (state == NOTIFYSILENCE) {
setIcon(_silenceIcon);
setIcon(*_silenceIcon);
_keepIconUntilInteraction = true;
} else if (state == NOTIFYNORMAL) {
if (_sessionIconName != _session->iconName()) {
@@ -1509,7 +1515,7 @@ void SessionController::zmodemDownload()
}
if (!zmodem.isEmpty()) {
const QString path = KFileDialog::getExistingDirectory(
QString(), _view,
KUrl(), _view,
i18n("Save ZModem Download to..."));
if (!path.isEmpty()) {
@@ -1598,7 +1604,7 @@ void SaveHistoryTask::execute()
// TODO - show a warning ( preferably passive ) if saving the history output fails
//
KFileDialog* dialog = new KFileDialog(QString(":konsole") /* check this */,
KFileDialog* dialog = new KFileDialog(KUrl(QString(":konsole")) /* check this */,
QString(), QApplication::activeWindow());
dialog->setOperationMode(KFileDialog::Saving);
dialog->setConfirmOverwrite(true);
@@ -1612,7 +1618,7 @@ void SaveHistoryTask::execute()
// to save that session's history.
// then start a KIO job to transfer the data from the history to the chosen URL
foreach(const SessionPtr& session, sessions()) {
dialog->setCaption(i18n("Save Output From %1", session->title(Session::NameRole)));
dialog->setWindowTitle(i18n("Save Output From %1", session->title(Session::NameRole)));
int result = dialog->exec();