Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
merge ../allowClientResize
Browse files Browse the repository at this point in the history
  • Loading branch information
dandrader committed Mar 16, 2017
2 parents 593d500 + 4900a5f commit 2a9c520
Show file tree
Hide file tree
Showing 32 changed files with 452 additions and 42 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ find_package(Qt5DBus 5.6 REQUIRED)
find_package(Qt5Concurrent 5.6 REQUIRED)
find_package(Qt5Sql 5.6 REQUIRED)

pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=26)
pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=27)
pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=11)
pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=12)
pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
pkg_check_modules(GD3 REQUIRED gnome-desktop-3.0)
pkg_check_modules(UAL REQUIRED ubuntu-app-launch-3)
Expand Down
10 changes: 5 additions & 5 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Build-Depends: cmake,
libubuntugestures5-private-dev (>= 1.3.2030),
libudev-dev,
libudm-common-dev,
libunity-api-dev (>= 8.2),
libunity-api-dev (>= 8.6),
libusermetricsoutput1-dev,
# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
libx11-dev[!arm64 !armhf],
Expand Down Expand Up @@ -132,7 +132,7 @@ Depends: dmz-cursor-theme,
qtdeclarative5-qtmir-plugin (>= 0.4.8),
qtdeclarative5-ubuntu-telephony0.1,
ubuntu-system-settings (>= 0.4),
unity-launcher-impl-10,
unity-launcher-impl-12,
unity8-common (= ${source:Version}),
unity8-private (= ${binary:Version}),
unity8-private | unity-launcher-impl,
Expand Down Expand Up @@ -162,7 +162,7 @@ Depends: qml-module-qtquick-layouts,
qttranslations5-l10n,
ubuntu-thumbnailer-impl-0,
ubuntu-wallpapers,
unity-application-impl-26,
unity-application-impl-27,
unity-notifications-impl-3,
unity-plugin-scopes | unity-scopes-impl,
unity-scopes-impl-12,
Expand Down Expand Up @@ -212,7 +212,7 @@ Depends: dbus-test-runner,
${misc:Depends},
${shlibs:Depends},
Provides: unity-application-impl,
unity-application-impl-26,
unity-application-impl-27,
unity8-fake-env,
Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1),
unity8-fake-env,
Expand All @@ -235,7 +235,7 @@ Depends: accountsservice-ubuntu-schemas (>= 0.0.7),
${misc:Depends},
${shlibs:Depends},
Provides: unity-launcher-impl,
unity-launcher-impl-10,
unity-launcher-impl-12,
Description: Unity 8 private libs
The Unity 8 shell is the primary user interface for Ubuntu devices.
.
Expand Down
2 changes: 2 additions & 0 deletions plugins/Greeter/Unity/Launcher/quicklistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ QVariant QuickListModel::data(const QModelIndex &index, int role) const
return m_list.at(index.row()).icon();
case RoleClickable:
return m_list.at(index.row()).clickable();
case RoleIsPrivate:
return false; // The greeter plugin would just not add any private entries
}
return QVariant();
}
2 changes: 2 additions & 0 deletions plugins/Unity/Launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ set(QMLLAUNCHERPLUGIN_SRC
${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
Expand Down
36 changes: 30 additions & 6 deletions plugins/Unity/Launcher/launcheritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
m_countVisible(false),
m_focused(false),
m_alerting(false),
m_surfaceCount(0),
m_quickList(new QuickListModel(this))
{
Q_ASSERT(parent != nullptr);
Expand All @@ -48,11 +47,13 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
QuickListEntry pinningAction;
pinningAction.setActionId(QStringLiteral("pin_item"));
pinningAction.setText(gettext("Pin shortcut"));
pinningAction.setIsPrivate(true);
m_quickList->appendAction(pinningAction);

m_quitAction.setActionId(QStringLiteral("stop_item"));
m_quitAction.setIcon(QStringLiteral("application-exit"));
m_quitAction.setText(gettext("Quit"));
m_quitAction.setIsPrivate(true);
}

QString LauncherItem::appId() const
Expand Down Expand Up @@ -120,6 +121,7 @@ void LauncherItem::setPinned(bool pinned)
QuickListEntry entry;
entry.setActionId(QStringLiteral("pin_item"));
entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
entry.setIsPrivate(true);
m_quickList->updateAction(entry);
}

Expand Down Expand Up @@ -221,14 +223,36 @@ void LauncherItem::setAlerting(bool alerting)

int LauncherItem::surfaceCount() const
{
return m_surfaceCount;
return m_surfaces.count();
}

void LauncherItem::setSurfaceCount(int surfaceCount)
void LauncherItem::setSurfaces(const QList<QPair<QString, QString> > &surfaces)
{
if (m_surfaceCount != surfaceCount) {
m_surfaceCount = surfaceCount;
Q_EMIT surfaceCountChanged(surfaceCount);
if (m_surfaces != surfaces) {
m_surfaces = surfaces;

QList<QuickListEntry> removedEntries;
for (int i = 0; i < m_quickList->rowCount(); ++i) {
QuickListEntry entry = m_quickList->get(i);
if (entry.actionId().startsWith(QStringLiteral("surface_"))) {
removedEntries.append(entry);
}
}
Q_FOREACH (const QuickListEntry &entry, removedEntries) {
m_quickList->removeAction(entry);
}
for (int i = 0; i < surfaces.count(); ++i) {
QuickListEntry entry;
entry.setActionId(QStringLiteral("surface_") + surfaces.at(i).first);
entry.setText(surfaces.at(i).second);
entry.setIsPrivate(true);
if (i == surfaces.count() - 1) {
entry.setHasSeparator(true);
}
m_quickList->insertAction(entry, i + 1);
}

Q_EMIT surfaceCountChanged(m_surfaces.count());
}
}

Expand Down
5 changes: 3 additions & 2 deletions plugins/Unity/Launcher/launcheritem.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "quicklistmodel.h"

#include <unity/shell/launcher/LauncherItemInterface.h>
#include <unity/shell/application/MirSurfaceInterface.h>

class QuickListModel;

Expand Down Expand Up @@ -62,7 +63,7 @@ class LauncherItem: public LauncherItemInterface
void setCountVisible(bool countVisible);
void setFocused(bool focused);
void setAlerting(bool alerting);
void setSurfaceCount(int surfaceCount);
void setSurfaces(const QList<QPair<QString, QString >> &surfaces);

private:
QString m_appId;
Expand All @@ -77,7 +78,7 @@ class LauncherItem: public LauncherItemInterface
bool m_countVisible;
bool m_focused;
bool m_alerting;
int m_surfaceCount;
QList<QPair<QString, QString> > m_surfaces;
QuickListModel *m_quickList;
QuickListEntry m_quitAction;

Expand Down
61 changes: 47 additions & 14 deletions plugins/Unity/Launcher/launchermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <unity/shell/application/ApplicationInfoInterface.h>
#include <unity/shell/application/MirSurfaceListInterface.h>
#include <unity/shell/application/MirSurfaceInterface.h>

#include <QDesktopServices>
#include <QDebug>
Expand Down Expand Up @@ -198,12 +199,25 @@ void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex
} else {
pin(appId);
}
} else if (actionId == QLatin1String("launch_item")) {
} else if (actionId == QStringLiteral("launch_item")) {
QDesktopServices::openUrl(getUrlForAppId(appId));
} else if (actionId == QLatin1String("stop_item")) { // Quit
} else if (actionId == QStringLiteral("stop_item")) { // Quit
if (m_appManager) {
m_appManager->stopApplication(appId);
}
} else if (actionId.startsWith(QStringLiteral("surface_"))){
ApplicationInfoInterface *appInfo = m_appManager->findApplication(appId);
if (!appInfo) {
qWarning() << "App for" << appId << "not found in launcher. Cannot invoke quicklist action";
}
for (int i = 0; i < appInfo->surfaceList()->count(); ++i) {
MirSurfaceInterface *iface = appInfo->surfaceList()->get(i);
QString id = actionId;
id.remove(QRegExp("^surface_"));
if (id == iface->persistentId()) {
iface->activate();
}
}
// Nope, we don't know this action, let the backend forward it to the application
} else {
// TODO: forward quicklist action to app, possibly via m_dbusIface
Expand Down Expand Up @@ -517,40 +531,59 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
item->setRecent(true);
Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRecent});
}
if (item->surfaceCount() != app->surfaceCount()) {
item->setSurfaceCount(app->surfaceCount());
Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleSurfaceCount});
}

item->setRunning(true);
} else {
LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
item->setRecent(true);
item->setRunning(true);
item->setFocused(app->focused());
item->setSurfaceCount(app->surfaceCount());
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
m_list.append(item);
endInsertRows();
}
connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::updateSurfaceList);
m_asAdapter->syncItems(m_list);
Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRunning});
}

void LauncherModel::applicationSurfaceCountChanged(int count)
void LauncherModel::updateSurfaceList()
{
ApplicationInfoInterface *app = static_cast<ApplicationInfoInterface*>(sender());
updateSurfaceListForApp(app);
}

void LauncherModel::updateSurfaceListForSurface()
{
MirSurfaceInterface *iface = static_cast<MirSurfaceInterface*>(sender());
ApplicationInfoInterface* app = m_appManager->findApplication(iface->appId());
if (!app) {
return;
}
updateSurfaceListForApp(app);
}

void LauncherModel::updateSurfaceListForApp(ApplicationInfoInterface* app)
{
int idx = findApplication(app->appId());
if (idx < 0) {
qWarning() << "Received a surface count changed event from an app that's not in the Launcher model";
return;
}
LauncherItem *item = m_list.at(idx);
if (item->surfaceCount() != count) {
item->setSurfaceCount(count);
Q_EMIT dataChanged(index(idx), index(idx), {RoleSurfaceCount});
QList<QPair<QString, QString> > surfaces;
for (int i = 0; i < app->surfaceList()->count(); ++i) {
MirSurfaceInterface* iface = app->surfaceList()->get(i);
// Avoid duplicate connections, so let's just disconnect first to be sure
disconnect(iface, &MirSurfaceInterface::nameChanged, this, &LauncherModel::updateSurfaceListForSurface);
connect(iface, &MirSurfaceInterface::nameChanged, this, &LauncherModel::updateSurfaceListForSurface);
QString name = iface->name();
if (name.isEmpty()) {
name = app->name();
}
surfaces.append({iface->persistentId(), name});
}
item->setSurfaces(surfaces);
Q_EMIT dataChanged(index(idx), index(idx), {RoleSurfaceCount});
}

void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
Expand All @@ -571,7 +604,7 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
return;
}

disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::updateSurfaceList);

LauncherItem * item = m_list.at(appIndex);

Expand Down
4 changes: 3 additions & 1 deletion plugins/Unity/Launcher/launchermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ private Q_SLOTS:
void applicationAdded(const QModelIndex &parent, int row);
void applicationRemoved(const QModelIndex &parent, int row);
void focusedAppIdChanged();
void applicationSurfaceCountChanged(int);
void updateSurfaceList();
void updateSurfaceListForApp(ApplicationInfoInterface *app);
void updateSurfaceListForSurface();

private:
QList<LauncherItem*> m_list;
Expand Down
11 changes: 11 additions & 0 deletions plugins/Unity/Launcher/quicklistentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

QuickListEntry::QuickListEntry()
: m_hasSeparator(false)
, m_isPrivate(false)
{
}

Expand Down Expand Up @@ -72,3 +73,13 @@ bool QuickListEntry::operator==(const QuickListEntry &other)
{
return !other.actionId().isEmpty() && other.actionId() == m_actionId;
}

bool QuickListEntry::isPrivate() const
{
return m_isPrivate;
}

void QuickListEntry::setIsPrivate(bool isPrivate)
{
m_isPrivate = isPrivate;
}
4 changes: 4 additions & 0 deletions plugins/Unity/Launcher/quicklistentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ class QuickListEntry

bool operator==(const QuickListEntry & other);

bool isPrivate() const;
void setIsPrivate(bool isPrivate);

private:
QString m_actionId;
QString m_text;
QString m_icon;
bool m_hasSeparator;
bool m_isPrivate;
};

#endif // QUICKLISTENTRY
9 changes: 9 additions & 0 deletions plugins/Unity/Launcher/quicklistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ void QuickListModel::appendAction(const QuickListEntry &entry)
endInsertRows();
}

void QuickListModel::insertAction(const QuickListEntry &entry, int index)
{
beginInsertRows(QModelIndex(), index, index);
m_list.insert(index, entry);
endInsertRows();
}

void QuickListModel::updateAction(const QuickListEntry &entry)
{
for (int i = 0; i < m_list.count(); ++i) {
Expand Down Expand Up @@ -81,6 +88,8 @@ QVariant QuickListModel::data(const QModelIndex &index, int role) const
return m_list.at(index.row()).clickable();
case RoleHasSeparator:
return m_list.at(index.row()).hasSeparator();
case RoleIsPrivate:
return m_list.at(index.row()).isPrivate();
}
return QVariant();
}
1 change: 1 addition & 0 deletions plugins/Unity/Launcher/quicklistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class QuickListModel: public QuickListModelInterface
~QuickListModel();

void appendAction(const QuickListEntry &entry);
void insertAction(const QuickListEntry &entry, int index);

/**
* @brief Update an existing action
Expand Down
1 change: 1 addition & 0 deletions plugins/Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set(QMLPLUGIN_SRC
URLDispatcher.cpp
tabfocusfence.cpp
expressionfiltermodel.cpp
quicklistproxymodel.cpp
plugin.cpp
)

Expand Down
2 changes: 2 additions & 0 deletions plugins/Utils/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "appdrawerproxymodel.h"
#include "tabfocusfence.h"
#include "expressionfiltermodel.h"
#include "quicklistproxymodel.h"

static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Expand Down Expand Up @@ -88,4 +89,5 @@ void UtilsPlugin::registerTypes(const char *uri)
qmlRegisterType<AppDrawerProxyModel>(uri, 0, 1, "AppDrawerProxyModel");
qmlRegisterType<TabFocusFenceItem>(uri, 0, 1, "TabFocusFence");
qmlRegisterType<ExpressionFilterModel>(uri, 0, 1, "ExpressionFilterModel");
qmlRegisterType<QuickListProxyModel>(uri, 0, 1, "QuickListProxyModel");
}
Loading

0 comments on commit 2a9c520

Please sign in to comment.