Implement the shortcut caption suffix for Wayland windows

Summary:
The generation of the shortcut caption part is moved from Client to
AbstractClient. The ShellClient also has a captionSuffix and implements
the full part in caption.

Overall this needs more refactoring to support more sharing between the
two implementations. But one step at a time.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7093
icc-effect-5.14.5
Martin Flöser 2017-08-03 07:11:40 +02:00
parent bbad15f661
commit bbca8c6677
8 changed files with 29 additions and 5 deletions

View File

@ -1750,4 +1750,12 @@ void AbstractClient::setUnresponsive(bool unresponsive)
}
}
QString AbstractClient::shortcutCaptionSuffix() const
{
if (shortcut().isEmpty()) {
return QString();
}
return QLatin1String(" {") + shortcut().toString() + QLatin1Char('}');
}
}

View File

@ -983,6 +983,8 @@ protected:
void setUnresponsive(bool unresponsive);
virtual void setShortcutInternal();
QString shortcutCaptionSuffix() const;
virtual void updateCaption() = 0;
private:
void handlePaletteChange();

View File

@ -292,7 +292,6 @@ void GlobalShortcutsTest::testWaylandClientShortcut()
client->setShortcut(seq.toString());
QCOMPARE(client->shortcut(), seq);
QVERIFY(!workspace()->shortcutAvailable(seq));
QEXPECT_FAIL("", "Caption adjustment not yet implemented", Continue);
QCOMPARE(client->caption(), QStringLiteral(" {Meta+Shift+Y}"));
workspace()->activateClient(nullptr);

View File

@ -1442,7 +1442,7 @@ void Client::setCaption(const QString& _s, bool force)
if (clientMachine()->hostName() != ClientMachine::localhost() && !clientMachine()->isLocal())
machine_suffix = QLatin1String(" <@") + QString::fromUtf8(clientMachine()->hostName()) + QLatin1Char('>') + LRM;
}
QString shortcut_suffix = !shortcut().isEmpty() ? (QLatin1String(" {") + shortcut().toString() + QLatin1Char('}')) : QString();
QString shortcut_suffix = shortcutCaptionSuffix();
cap_suffix = machine_suffix + shortcut_suffix;
auto fetchNameInternalPredicate = [this](const Client *cl) {
return (!cl->isSpecialWindow() || cl->isToolbar()) &&

View File

@ -339,7 +339,7 @@ public:
public Q_SLOTS:
void closeWindow() override;
void updateCaption();
void updateCaption() override;
void evaluateWindowRules();
private Q_SLOTS:

View File

@ -556,8 +556,20 @@ void ShellClient::blockActivityUpdates(bool b)
QString ShellClient::caption(bool full) const
{
Q_UNUSED(full)
return m_caption;
QString caption = m_caption;
if (full) {
caption += m_captionSuffix;
}
return caption;
}
void ShellClient::updateCaption()
{
const QString oldSuffix = m_captionSuffix;
m_captionSuffix = shortcutCaptionSuffix();
if (m_captionSuffix != oldSuffix) {
emit captionChanged();
}
}
void ShellClient::closeWindow()

View File

@ -163,6 +163,7 @@ protected:
bool acceptsFocus() const override;
void doMinimize() override;
void doMove(int x, int y) override;
void updateCaption() override;
private Q_SLOTS:
void clientFullScreenChanged(bool fullScreen);
@ -236,6 +237,7 @@ private:
int m_requestGeometryBlockCounter = 0;
QRect m_blockedRequestGeometry;
QString m_caption;
QString m_captionSuffix;
bool m_compositingSetup = false;
};

View File

@ -1826,6 +1826,7 @@ void AbstractClient::setShortcut(const QString& _cut)
void AbstractClient::setShortcutInternal()
{
updateCaption();
workspace()->clientShortcutUpdated(this);
}