Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding qeyes plugin * load() returns success/failure * remove unneeded printf() * Add qeyes plugin to the list of plugin * Add dialog to confiure plugin * add qeyes.desktop * Add translation, changed name from qeyesplugin to qeyes * add several eyes type * look in the lxqt specific data dir for the eyes type * Several changes: - add support for translation of the text - reload the availables eyes not a dialog creation (which happend once), but when the dialog is showed - using QStringLiteral when possible - renamed "<internal>" as "QEyes default" * compare the old_types with the value and not the key * Add forgotten Q_OBJECT * Add qeyes.ts file * Do adjustSize() after populating the QComboBox() * Stop to import 'skins' from foreign projects
- Loading branch information
Showing
57 changed files
with
1,484 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
set(PLUGIN "qeyes") | ||
|
||
set(HEADERS | ||
qeyes.h | ||
qeyesimagewidget.h | ||
qeyesvectorwidget.h | ||
qeyeswidget.h | ||
qeyesconfigdialog.h | ||
) | ||
|
||
set(SOURCES | ||
qeyes.cpp | ||
qeyesimagewidget.cpp | ||
qeyesvectorwidget.cpp | ||
qeyeswidget.cpp | ||
qeyesconfigdialog.cpp | ||
) | ||
|
||
set(LIBRARIES | ||
${LIBRARIES} | ||
) | ||
|
||
add_subdirectory(types) | ||
|
||
BUILD_LXQT_PLUGIN(${PLUGIN}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* qeyes - an xeyes clone | ||
* | ||
* Copyright (C) 2022 Goffredo Baroncelli <kreijack@inwind.it> | ||
* | ||
* This program 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 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program 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 this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <QtWidgets/QHBoxLayout> | ||
#include <QtWidgets/QPushButton> | ||
#include <QtWidgets/QDialog> | ||
#include <QtCore/QFile> | ||
#include <QtCore/QTextStream> | ||
|
||
#include "../panel/pluginsettings.h" | ||
|
||
#include "qeyesconfigdialog.h" | ||
#include "qeyes.h" | ||
|
||
ILXQtPanelPlugin *QEyesPluginLibrary::instance(const ILXQtPanelPluginStartupInfo &startupInfo) const | ||
{ | ||
return new QEyesPlugin(startupInfo); | ||
} | ||
|
||
QEyesPlugin::QEyesPlugin(const ILXQtPanelPluginStartupInfo &startupInfo) : | ||
QObject(), | ||
ILXQtPanelPlugin(startupInfo) | ||
{ | ||
w0 = new QWidget(); | ||
l = new QVBoxLayout(); | ||
l->setSpacing(0); | ||
l->setMargin(0); | ||
l->setContentsMargins (0, 0, 0, 0); | ||
w0->setLayout(l); | ||
|
||
w = new QEyesVectorWidget(); | ||
l->addWidget(w); | ||
w->setTransparent(true); | ||
vectorEyes = true; | ||
|
||
settingsChanged(); | ||
realign(); | ||
} | ||
|
||
void QEyesPlugin::realign() { | ||
const auto g = panel()->globalGeometry(); | ||
if (panel()->isHorizontal()) { | ||
w->setMinimumHeight(g.height() / 2); | ||
w->setMinimumWidth(0.8 * g.height() * w->getNumEyes() ); | ||
} else { | ||
w->setMinimumWidth(g.width() / 2); | ||
w->setMinimumHeight(g.width()); | ||
} | ||
w->update(); | ||
} | ||
|
||
|
||
static bool loadImage(QString path, QEyesImageWidget *w) { | ||
QFile file(path + QStringLiteral("/config")); | ||
file.open(QIODevice::ReadOnly); | ||
QTextStream in(&file); | ||
QString eye, pupil; | ||
int num=1, wall=1; | ||
|
||
while(!in.atEnd()) { | ||
QString line = in.readLine(); | ||
QStringList fields = line.split(QLatin1String("=")); | ||
const auto name = fields.at(0).trimmed(); | ||
auto value = fields.at(1).trimmed(); | ||
if (value.size() > 1 && value.at(0) == QChar(QLatin1Char('"'))) | ||
value = value.mid(1, value.size() - 2); | ||
if (name == QStringLiteral("wall-thickness")) { | ||
wall = value.toInt(); | ||
} else if (name == QStringLiteral("eye-pixmap")) { | ||
eye = path + QStringLiteral("/") + value; | ||
} else if (name == QStringLiteral("pupil-pixmap")) { | ||
pupil = path + QStringLiteral("/") + value; | ||
} else if (name.trimmed() == QStringLiteral("num-eyes")) { | ||
num = value.toInt(); | ||
} | ||
} | ||
|
||
return w->load(eye, pupil, wall, num); | ||
} | ||
|
||
void QEyesPlugin::settingsChanged() { | ||
PluginSettings *_settings = settings(); | ||
|
||
const auto type = _settings->value(QStringLiteral("eye_type"), | ||
internalEye).toString(); | ||
|
||
if (type == internalEye && !vectorEyes) { | ||
l->removeWidget(w); | ||
delete w; | ||
w = new QEyesVectorWidget(); | ||
l->addWidget(w); | ||
w->setTransparent(true); | ||
vectorEyes = true; | ||
} else if (type != internalEye && vectorEyes) { | ||
l->removeWidget(w); | ||
delete w; | ||
w = new QEyesImageWidget(); | ||
l->addWidget(w); | ||
w->setTransparent(true); | ||
vectorEyes = false; | ||
} | ||
|
||
if (type != internalEye && !vectorEyes) { | ||
if (!loadImage(type, dynamic_cast<QEyesImageWidget*>(w))) { | ||
l->removeWidget(w); | ||
delete w; | ||
w = new QEyesVectorWidget(); | ||
l->addWidget(w); | ||
w->setTransparent(true); | ||
vectorEyes = true; | ||
|
||
_settings->setValue(QStringLiteral("eye_type"), | ||
internalEye); | ||
std::cerr << "ERROR: crash during load image\n" ; | ||
} | ||
} | ||
|
||
w->setNumEyes(_settings->value(QStringLiteral("num_eyes"), | ||
QLatin1String("2")).toInt()); | ||
realign(); | ||
} | ||
|
||
QDialog * QEyesPlugin::configureDialog() { | ||
return new QEyesConfigDialog(settings(), this); | ||
} | ||
|
||
const QString QEyesPlugin::internalEye = QStringLiteral("<internal>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* qeyes - an xeyes clone | ||
* | ||
* Copyright (C) 2022 Goffredo Baroncelli <kreijack@inwind.it> | ||
* | ||
* This program 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 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program 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 this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
|
||
#include <iostream> | ||
|
||
#include <QtWidgets/QApplication> | ||
#include <QtCore/QCommandLineParser> | ||
#include <QtWidgets/QVBoxLayout> | ||
|
||
#include "../panel/ilxqtpanelplugin.h" | ||
|
||
#include "qeyesvectorwidget.h" | ||
#include "qeyesimagewidget.h" | ||
|
||
class QEyesPlugin : public QObject, public ILXQtPanelPlugin | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QEyesPlugin(const ILXQtPanelPluginStartupInfo &startupInfo); | ||
|
||
virtual QWidget *widget() override { return w0; } | ||
virtual QString themeId() const override{ | ||
return QStringLiteral("QEyesPlugin"); | ||
} | ||
virtual void realign() override; | ||
virtual Flags flags() const override { return HaveConfigDialog ; } | ||
virtual QDialog * configureDialog() override; | ||
virtual void settingsChanged() override; | ||
static const QString internalEye; | ||
|
||
private: | ||
QWidget *w0; | ||
QVBoxLayout *l; | ||
QAbstractEyesWidget *w; | ||
bool vectorEyes = true; | ||
|
||
}; | ||
|
||
class QEyesPluginLibrary: public QObject, public ILXQtPanelPluginLibrary | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID "lxqt.org/Panel/PluginInterface/3.0") | ||
Q_INTERFACES(ILXQtPanelPluginLibrary) | ||
public: | ||
ILXQtPanelPlugin *instance(const ILXQtPanelPluginStartupInfo &startupInfo) const; | ||
}; | ||
|
||
|
Oops, something went wrong.