Merge branch 'Plasma/5.2'

This commit is contained in:
Martin Gräßlin 2015-01-21 09:25:00 +01:00
commit de573edd1d
4 changed files with 46 additions and 22 deletions

View file

@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KSharedConfig> #include <KSharedConfig>
// Qt // Qt
#include <QDBusConnection> #include <QDBusConnection>
#include <QScreen>
#include <QTimer> #include <QTimer>
// Xlib // Xlib
#include <X11/Xcursor/Xcursor.h> #include <X11/Xcursor/Xcursor.h>
@ -78,7 +79,17 @@ void Cursor::loadThemeSettings()
{ {
QString themeName = QString::fromUtf8(qgetenv("XCURSOR_THEME")); QString themeName = QString::fromUtf8(qgetenv("XCURSOR_THEME"));
bool ok = false; bool ok = false;
uint themeSize = qgetenv("XCURSOR_SIZE").toUInt(&ok); // XCURSOR_SIZE might not be set (e.g. by startkde)
uint themeSize = 0;
if (qEnvironmentVariableIsSet("XCURSOR_SIZE")) {
themeSize = qgetenv("XCURSOR_SIZE").toUInt(&ok);
}
if (!ok) {
if (QScreen *s = QGuiApplication::primaryScreen()) {
themeSize = s->logicalDotsPerInchY() * 16 / 72;
ok = true;
}
}
if (!themeName.isEmpty() && ok) { if (!themeName.isEmpty() && ok) {
updateTheme(themeName, themeSize); updateTheme(themeName, themeSize);
return; return;

View file

@ -29,7 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KConfigGroup> #include <KConfigGroup>
#include <KDesktopFile> #include <KDesktopFile>
#include <KLocalizedString> #include <KLocalizedString>
#include <KService> #include <KMimeTypeTrader>
namespace KWin namespace KWin
{ {
@ -132,14 +132,21 @@ ExampleClientModel::~ExampleClientModel()
void ExampleClientModel::init() void ExampleClientModel::init()
{ {
QList<QString> applications; if (const auto s = KMimeTypeTrader::self()->preferredService(QStringLiteral("inode/directory"))) {
applications << "konqbrowser" << "KMail2" << "systemsettings" << "dolphin"; m_services << s;
m_fileManager = s;
foreach (const QString& application, applications) { }
KService::Ptr service = KService::serviceByStorageId("kde4-" + application + ".desktop"); if (const auto s = KMimeTypeTrader::self()->preferredService(QStringLiteral("text/html"))) {
if (service) { m_services << s;
m_nameList << service->entryPath(); m_browser = s;
} }
if (const auto s = KMimeTypeTrader::self()->preferredService(QStringLiteral("message/rfc822"))) {
m_services << s;
m_email = s;
}
if (const auto s = KService::serviceByDesktopName(QStringLiteral("kdesystemsettings"))) {
m_services << s;
m_systemSettings = s;
} }
} }
@ -151,22 +158,22 @@ QVariant ExampleClientModel::data(const QModelIndex &index, int role) const
switch (role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
case Qt::UserRole: case Qt::UserRole:
return KDesktopFile(m_nameList.at(index.row())).readName(); return m_services.at(index.row())->name();
case Qt::UserRole+1: case Qt::UserRole+1:
return false; return false;
case Qt::UserRole+2: case Qt::UserRole+2:
return i18nc("An example Desktop Name", "Desktop 1"); return i18nc("An example Desktop Name", "Desktop 1");
case Qt::UserRole+3: case Qt::UserRole+3:
return QIcon::fromTheme(KDesktopFile(m_nameList.at(index.row())).readIcon()); return m_services.at(index.row())->icon();
case Qt::UserRole+4: case Qt::UserRole+4:
const QString desktopFile = KDesktopFile(m_nameList.at(index.row())).fileName().split('/').last(); const auto s = m_services.at(index.row());
if (desktopFile == "konqbrowser.desktop") { if (s == m_browser) {
return WindowThumbnailItem::Konqueror; return WindowThumbnailItem::Konqueror;
} else if (desktopFile == "KMail2.desktop") { } else if (s == m_email) {
return WindowThumbnailItem::KMail; return WindowThumbnailItem::KMail;
} else if (desktopFile == "systemsettings.desktop") { } else if (s == m_systemSettings) {
return WindowThumbnailItem::Systemsettings; return WindowThumbnailItem::Systemsettings;
} else if (desktopFile == "dolphin.desktop") { } else if (s == m_fileManager) {
return WindowThumbnailItem::Dolphin; return WindowThumbnailItem::Dolphin;
} }
return 0; return 0;
@ -177,8 +184,8 @@ QVariant ExampleClientModel::data(const QModelIndex &index, int role) const
QString ExampleClientModel::longestCaption() const QString ExampleClientModel::longestCaption() const
{ {
QString caption; QString caption;
for (QString item : m_nameList) { for (const auto item : m_services) {
QString name = KDesktopFile(item).readName(); const QString name = item->name();
if (name.size() > caption.size()) { if (name.size() > caption.size()) {
caption = name; caption = name;
} }
@ -189,7 +196,7 @@ QString ExampleClientModel::longestCaption() const
int ExampleClientModel::rowCount(const QModelIndex &parent) const int ExampleClientModel::rowCount(const QModelIndex &parent) const
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
return m_nameList.size(); return m_services.size();
} }
SwitcherItem::SwitcherItem(QObject *parent) SwitcherItem::SwitcherItem(QObject *parent)

View file

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_TABBOX_LAYOUTPREVIEW_H #ifndef KWIN_TABBOX_LAYOUTPREVIEW_H
#define KWIN_TABBOX_LAYOUTPREVIEW_H #define KWIN_TABBOX_LAYOUTPREVIEW_H
#include <KService>
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QQuickView> #include <QQuickView>
#include <QRect> #include <QRect>
@ -57,7 +58,11 @@ public:
private: private:
void init(); void init();
QStringList m_nameList; QList<KService::Ptr> m_services;
KService::Ptr m_fileManager;
KService::Ptr m_browser;
KService::Ptr m_email;
KService::Ptr m_systemSettings;
}; };

View file

@ -1300,13 +1300,14 @@ SceneXRenderDecorationRenderer::~SceneXRenderDecorationRenderer()
void SceneXRenderDecorationRenderer::render() void SceneXRenderDecorationRenderer::render()
{ {
const QRegion scheduled = getScheduled(); QRegion scheduled = getScheduled();
if (scheduled.isEmpty()) { if (scheduled.isEmpty()) {
return; return;
} }
if (areImageSizesDirty()) { if (areImageSizesDirty()) {
resizePixmaps(); resizePixmaps();
resetImageSizesDirty(); resetImageSizesDirty();
scheduled = client()->client()->decorationRect();
} }
const QRect top(QPoint(0, 0), m_sizes[int(DecorationPart::Top)]); const QRect top(QPoint(0, 0), m_sizes[int(DecorationPart::Top)]);