File indexing completed on 2024-10-06 13:18:50

0001 /*
0002  * SPDX-FileCopyrightText: 2019 Mikhail Zolotukhin <zomial@protonmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #include <QProcessEnvironment>
0008 #include <QStandardPaths>
0009 
0010 #include "config.h"
0011 #include "themepreviewer.h"
0012 
0013 const QString ThemePreviewer::gtk3PreviewerExecutablePath = QStandardPaths::findExecutable(QStringLiteral("gtk3_preview"), {CMAKE_INSTALL_FULL_LIBEXECDIR});
0014 
0015 ThemePreviewer::ThemePreviewer(QObject *parent)
0016     : QObject(parent)
0017     , gtk3PreviewerProccess()
0018 {
0019 }
0020 
0021 void ThemePreviewer::showGtk3App(const QString &themeName)
0022 {
0023     if (gtk3PreviewerProccess.state() == QProcess::ProcessState::NotRunning) {
0024         QProcessEnvironment gtk3PreviewEnvironment = QProcessEnvironment::systemEnvironment();
0025         gtk3PreviewEnvironment.insert(QStringLiteral("GTK_THEME"), themeName);
0026         gtk3PreviewerProccess.setProcessEnvironment(gtk3PreviewEnvironment);
0027 
0028         gtk3PreviewerProccess.start(gtk3PreviewerExecutablePath, QStringList());
0029     } else {
0030         gtk3PreviewerProccess.close();
0031     }
0032 }