aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-theme-engine/src
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2018-01-02 22:18:34 +0000
committerWeblate <noreply@weblate.org>2018-01-02 22:18:34 +0000
commit4bf6d3f38634dbb517055444a22d824d6eba99d8 (patch)
treebbe3e3e511f37222cdd9db145bde2f41a35e1260 /src-qt5/core/lumina-theme-engine/src
parentTranslated using Weblate (Danish) (diff)
parentMerge remote-tracking branch 'origin/master' (diff)
downloadlumina-4bf6d3f38634dbb517055444a22d824d6eba99d8.tar.gz
lumina-4bf6d3f38634dbb517055444a22d824d6eba99d8.tar.bz2
lumina-4bf6d3f38634dbb517055444a22d824d6eba99d8.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/lumina-theme-engine/src')
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp4
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/lthemeengine-sstest.pro11
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/main.cpp18
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp39
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h4
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui36
6 files changed, 108 insertions, 4 deletions
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp
index 670e1c9c..e581b016 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp
@@ -43,7 +43,7 @@ lthemeenginePlatformTheme::lthemeenginePlatformTheme(){
#endif
QGuiApplication::setFont(m_generalFont);
}
- qCDebug(llthemeengine) << "using lthemeengine plugin";
+ //qCDebug(llthemeengine) << "using lthemeengine plugin";
#ifdef QT_WIDGETS_LIB
if(!QStyleFactory::keys().contains("lthemeengine-style"))
qCCritical(llthemeengine) << "unable to find lthemeengine proxy style";
@@ -60,7 +60,7 @@ QPlatformMenuBar *lthemeenginePlatformTheme::createPlatformMenuBar() const{
if(m_checkDBusGlobalMenu){
QDBusConnection conn = QDBusConnection::sessionBus();
m_dbusGlobalMenuAvailable = conn.interface()->isServiceRegistered("com.canonical.AppMenu.Registrar");
- qCDebug(llthemeengine) << "D-Bus global menu:" << (m_dbusGlobalMenuAvailable ? "yes" : "no");
+ //qCDebug(llthemeengine) << "D-Bus global menu:" << (m_dbusGlobalMenuAvailable ? "yes" : "no");
}
return (m_dbusGlobalMenuAvailable ? new QDBusMenuBar() : nullptr);
}
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/lthemeengine-sstest.pro b/src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/lthemeengine-sstest.pro
new file mode 100644
index 00000000..fadc6fcb
--- /dev/null
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/lthemeengine-sstest.pro
@@ -0,0 +1,11 @@
+include(../../lthemeengine.pri)
+TEMPLATE = app
+QT *= widgets
+
+SOURCES += \
+ main.cpp
+
+TARGET = lthemeengine-sstest
+target.path = $${L_BINDIR}
+
+INSTALLS += target
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/main.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/main.cpp
new file mode 100644
index 00000000..bdab0a30
--- /dev/null
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/main.cpp
@@ -0,0 +1,18 @@
+#include <QApplication>
+//#include <QDebug>
+#include <QWidget>
+
+#include <LUtils.h>
+
+int main(int argc, char **argv){
+ if(argc<2){ return 1; } //error
+ unsetenv("QT_QPA_PLATFORMTHEME"); //Make sure we are not testing anything related to the current theme engine
+ QString stylesheet = LUtils::readFile(argv[1]).join("\n");
+ //qDebug() << "Found Stylesheet:" << stylesheet;
+ QApplication app(argc, argv);
+ app.setStyleSheet(stylesheet);
+ //qDebug() << " Using Stylesheet:" << app.styleSheet();
+ QWidget tmp(0,Qt::SplashScreen | Qt::BypassWindowManagerHint);
+ tmp.show(); //needed to actually run the parser on the stylesheet (unused/unchecked otherwise)
+ return 0;
+}
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp
index ac891a80..56289931 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp
@@ -4,6 +4,12 @@
#include "qsseditordialog.h"
#include "ui_qsseditordialog.h"
+#include <QTemporaryFile>
+#include <QTextStream>
+
+#include <LuminaXDG.h>
+#include <LUtils.h>
+
QSSEditorDialog::QSSEditorDialog(const QString &filePath, QWidget *parent) : QDialog(parent), m_ui(new Ui::QSSEditorDialog){
m_ui->setupUi(this);
m_filePath = filePath;
@@ -37,6 +43,11 @@ QSSEditorDialog::QSSEditorDialog(const QString &filePath, QWidget *parent) : QDi
for(int i=0; i<colors.length(); i++){ colorMenu->addAction( colors[i].section("::::",0,0) )->setWhatsThis(colors[i].section("::::",1,1) ); }
m_ui->tool_color->setMenu(colorMenu);
connect(colorMenu, SIGNAL(triggered(QAction*)), this, SLOT(colorPicked(QAction*)) );
+ validateTimer = new QTimer(this);
+ validateTimer->setInterval(500); //1/2 second after finish typing
+ validateTimer->setSingleShot(true);
+ connect(validateTimer, SIGNAL(timeout()), this, SLOT(validateStyleSheet()) );
+ connect(m_ui->textEdit, SIGNAL(textChanged()), validateTimer, SLOT(start()) );
}
QSSEditorDialog::~QSSEditorDialog(){
@@ -69,3 +80,31 @@ void QSSEditorDialog::colorPicked(QAction* act){
if(id.isEmpty()){ return; }
m_ui->textEdit->insertPlainText( QString("palette(%1)").arg(id) );
}
+
+bool QSSEditorDialog::isStyleSheetValid(const QString &styleSheet){
+ QTemporaryFile tempfile;
+ if(tempfile.open()){
+ QTextStream out(&tempfile);
+ out << styleSheet;
+ out.flush();
+ tempfile.close();
+ }
+ QStringList log = LUtils::getCmdOutput("lthemeengine-sstest", QStringList() << tempfile.fileName());
+ qDebug() << "Got Validation Log:" << log;
+ return log.join("").simplified().isEmpty();
+}
+
+void QSSEditorDialog::validateStyleSheet(){
+ qDebug() << "Validating StyleSheet:";
+ bool ok = isStyleSheetValid(m_ui->textEdit->toPlainText());
+
+ //Now update the button/label as needed
+ int sz = this->fontMetrics().height();
+ if(ok){
+ m_ui->label_status_icon->setPixmap(LXDG::findIcon("dialog-ok","").pixmap(sz,sz) );
+ m_ui->label_status_icon->setToolTip(tr("Valid StyleSheet"));
+ }else{
+ m_ui->label_status_icon->setPixmap(LXDG::findIcon("dialog-cancel","").pixmap(sz,sz) );
+ m_ui->label_status_icon->setToolTip(tr("Invalid StyleSheet"));
+ }
+}
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h
index 114611fe..f51434e9 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h
@@ -5,6 +5,7 @@
#include <QString>
#include <QMenu>
#include <QAction>
+#include <QTimer>
namespace Ui {
class QSSEditorDialog;
@@ -23,6 +24,8 @@ public:
private slots:
void on_buttonBox_clicked(QAbstractButton *button);
void colorPicked(QAction*);
+ bool isStyleSheetValid(const QString&);
+ void validateStyleSheet();
private:
void save();
@@ -30,6 +33,7 @@ private:
Ui::QSSEditorDialog *m_ui;
QString m_filePath;
QMenu *colorMenu;
+ QTimer *validateTimer;
};
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui
index f75a21c6..68a14fb1 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>643</width>
- <height>499</height>
+ <width>808</width>
+ <height>512</height>
</rect>
</property>
<property name="windowTitle">
@@ -53,6 +53,38 @@
</widget>
</item>
<item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_status_icon">
+ <property name="minimumSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
bgstack15