Unverified Commit 3cf8e007 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳 Committed by Linus Jahn

Fix/Disable button coloring with some styles

Fixes the display of highlighted buttons with styles that don't support
coloring. Only Material and org.kde.desktop are
parent 2831de04
Pipeline #29172 passed with stages
in 52 minutes and 57 seconds
......@@ -199,6 +199,7 @@ target_link_libraries(${PROJECT_NAME}
Qt5::Multimedia
Qt5::Positioning
Qt5::Location
Qt5::QuickControls2
QXmpp::QXmpp
${__Qt5Widgets_LIBRARIES}
${__KF5Notifications_LIBRARIES}
......
......@@ -51,6 +51,7 @@ set(KAIDAN_SOURCES
# needed to trigger moc generation / to be displayed in IDEs
src/Enums.h
src/Globals.h
src/GuiStyle.h
# kaidan QXmpp extensions (need to be merged into QXmpp upstream)
src/qxmpp-exts/QXmppHttpUploadIq.cpp
......
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2020 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QObject>
#include <QQuickStyle>
class GuiStyle : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(bool buttonColoringEnabled READ buttonColoringEnabled CONSTANT)
public:
explicit GuiStyle(QObject *parent = nullptr) : QObject(parent)
{
}
inline static QString name()
{
return QQuickStyle::name();
}
inline static bool buttonColoringEnabled()
{
return name() == "Material" || name() == "org.kde.desktop";
}
};
......@@ -77,6 +77,7 @@
#include "MediaSettingModel.h"
#include "MediaUtils.h"
#include "MediaRecorder.h"
#include "GuiStyle.h"
#ifdef STATIC_BUILD
#include "static_plugins.h"
......@@ -395,6 +396,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qmlRegisterSingletonType<Kaidan>(APPLICATION_ID, 1, 0, "Kaidan", [](QQmlEngine *, QJSEngine *) {
return static_cast<QObject*>(Kaidan::instance());
});
qmlRegisterSingletonType<GuiStyle>(APPLICATION_ID, 1, 0, "Style", [](QQmlEngine *, QJSEngine *) {
return static_cast<QObject *>(new GuiStyle(QCoreApplication::instance()));
});
engine.load(QUrl("qrc:/qml/main.qml"));
if (engine.rootObjects().isEmpty())
......
......@@ -31,13 +31,19 @@
import QtQuick.Controls.Material 2.12 as Material
import org.kde.kirigami 2.8 as Kirigami
import im.kaidan.kaidan 1.0
/**
* This is a highlighted button.
*
* It is used for main actions.
*/
CenteredAdaptiveButton {
label.color: Kirigami.Theme.highlightedTextColor
// Not all styles actually support coloring buttons
label.color: {
Style.buttonColoringEnabled ? Kirigami.Theme.highlightedTextColor
: Kirigami.Theme.textColor
}
Kirigami.Theme.backgroundColor: Material.Material.accent
highlighted: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment