mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-31 02:01:19 +00:00
Merge pull request #137 from Swordfish90/unstable
Import latest changes from unstable.
This commit is contained in:
commit
9deeb5e405
16
app/main.cpp
16
app/main.cpp
@ -1,12 +1,20 @@
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QStringList>
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
#include <QDebug>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
QString getNamedArgument(QStringList args, QString name) {
|
||||
int index = args.indexOf(name);
|
||||
return (index != -1) ? args[index + 1] : QString("");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
setenv("QT_QPA_PLATFORMTHEME", "", 1);
|
||||
@ -16,13 +24,18 @@ int main(int argc, char *argv[])
|
||||
// Manage command line arguments from the cpp side
|
||||
QStringList args = app.arguments();
|
||||
if (args.contains("-h") || args.contains("--help")) {
|
||||
qDebug() << "Usage: " + args.at(0) + " [--default-settings] [-h|--help]";
|
||||
qDebug() << "Usage: " + args.at(0) + " [--default-settings] [--workdir <dir>] [--program <prog>] [-h|--help]";
|
||||
qDebug() << " --default-settings Run cool-old-term with the default settings";
|
||||
qDebug() << " --workdir <dir> Change working directory to 'dir'";
|
||||
qDebug() << " --program <prog> Run the 'prog' in the new terminal.";
|
||||
qDebug() << " -p|--profile Run cool-old-term with the given profile.";
|
||||
qDebug() << " -h|--help Print this help.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
engine.rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir"));
|
||||
engine.rootContext()->setContextProperty("shellProgram", getNamedArgument(args, "--program"));
|
||||
|
||||
// Manage import paths
|
||||
QStringList importPathList = engine.importPathList();
|
||||
importPathList.prepend(QCoreApplication::applicationDirPath() + "/imports/");
|
||||
@ -32,4 +45,3 @@ int main(int argc, char *argv[])
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,14 @@ Item{
|
||||
}
|
||||
Component.onCompleted: {
|
||||
shadersettings.terminalFontChanged.connect(handleFontChange);
|
||||
|
||||
// Retrieve the variable set in main.cpp if arguments are passed.
|
||||
if (shellProgram)
|
||||
ksession.setShellProgram(shellProgram);
|
||||
if (workdir)
|
||||
ksession.initialWorkingDirectory = workdir;
|
||||
|
||||
ksession.startShellProgram();
|
||||
forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,9 @@ ShaderEffect {
|
||||
property real time: timeManager.time
|
||||
property variant randomFunctionSource: randfuncsource
|
||||
|
||||
// If something goes wrong activate the fallback version of the shader.
|
||||
property bool fallBack: false
|
||||
|
||||
blending: false
|
||||
|
||||
//Smooth random texture used for flickering effect.
|
||||
@ -84,7 +87,6 @@ ShaderEffect {
|
||||
vertexShader: "
|
||||
uniform highp mat4 qt_Matrix;
|
||||
uniform highp float time;
|
||||
uniform sampler2D randomFunctionSource;
|
||||
|
||||
uniform highp float disp_left;
|
||||
uniform highp float disp_right;
|
||||
@ -96,10 +98,13 @@ ShaderEffect {
|
||||
|
||||
varying highp vec2 qt_TexCoord0;" +
|
||||
|
||||
(brightness_flickering !== 0.0 ?"
|
||||
(!fallBack ? "
|
||||
uniform sampler2D randomFunctionSource;" : "") +
|
||||
|
||||
(!fallBack && brightness_flickering !== 0.0 ?"
|
||||
varying lowp float brightness;
|
||||
uniform lowp float brightness_flickering;" : "") +
|
||||
(horizontal_sincronization !== 0.0 ?"
|
||||
(!fallBack && horizontal_sincronization !== 0.0 ?"
|
||||
varying lowp float horizontal_distortion;
|
||||
uniform lowp float horizontal_sincronization;" : "") +
|
||||
"
|
||||
@ -107,11 +112,11 @@ ShaderEffect {
|
||||
qt_TexCoord0.x = (qt_MultiTexCoord0.x - disp_left) / (1.0 - disp_left - disp_right);
|
||||
qt_TexCoord0.y = (qt_MultiTexCoord0.y - disp_top) / (1.0 - disp_top - disp_bottom);
|
||||
vec2 coords = vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0)));" +
|
||||
(brightness_flickering !== 0.0 ? "
|
||||
(!fallBack && brightness_flickering !== 0.0 ? "
|
||||
brightness = 1.0 + (texture2D(randomFunctionSource, coords).g - 0.5) * brightness_flickering;"
|
||||
: "") +
|
||||
|
||||
(horizontal_sincronization !== 0.0 ? "
|
||||
(!fallBack && horizontal_sincronization !== 0.0 ? "
|
||||
float randval = 1.5 * texture2D(randomFunctionSource,(vec2(1.0) -coords) * 0.5).g;
|
||||
float negsinc = 1.0 - 0.6 * horizontal_sincronization;" + "
|
||||
horizontal_distortion = step(negsinc, randval) * (randval - negsinc) * 0.3*horizontal_sincronization;"
|
||||
@ -148,9 +153,16 @@ ShaderEffect {
|
||||
uniform lowp float jitter;" : "") +
|
||||
(rgb_shift !== 0 ? "
|
||||
uniform lowp float rgb_shift;" : "") +
|
||||
(brightness_flickering !== 0 ? "
|
||||
|
||||
(fallBack && (brightness_flickering || horizontal_sincronization) ? "
|
||||
uniform lowp sampler2D randomFunctionSource;" : "") +
|
||||
(fallBack && horizontal_sincronization !== 0 ? "
|
||||
uniform lowp float horizontal_sincronization;" : "") +
|
||||
(fallBack && brightness_flickering !== 0.0 ?"
|
||||
uniform lowp float brightness_flickering;" : "") +
|
||||
(!fallBack && brightness_flickering !== 0 ? "
|
||||
varying lowp float brightness;" : "") +
|
||||
(horizontal_sincronization !== 0 ? "
|
||||
(!fallBack && horizontal_sincronization !== 0 ? "
|
||||
varying lowp float horizontal_distortion;" : "") +
|
||||
|
||||
(glowing_line_strength !== 0 ? "
|
||||
@ -166,6 +178,20 @@ ShaderEffect {
|
||||
"vec2 cc = vec2(0.5) - qt_TexCoord0;" +
|
||||
"float distance = length(cc);" +
|
||||
|
||||
//FallBack if there are problem
|
||||
(fallBack && (brightness_flickering || horizontal_sincronization) ? "
|
||||
vec2 randCoords = vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0)));" : "") +
|
||||
|
||||
(fallBack && brightness_flickering !== 0.0 ? "
|
||||
float brightness = 1.0 + (texture2D(randomFunctionSource, randCoords).g - 0.5) * brightness_flickering;"
|
||||
: "") +
|
||||
|
||||
(fallBack && horizontal_sincronization !== 0.0 ? "
|
||||
float randval = 1.5 * texture2D(randomFunctionSource,(vec2(1.0) - randCoords) * 0.5).g;
|
||||
float negsinc = 1.0 - 0.6 * horizontal_sincronization;" + "
|
||||
float horizontal_distortion = step(negsinc, randval) * (randval - negsinc) * 0.3*horizontal_sincronization;"
|
||||
: "") +
|
||||
|
||||
(noise_strength ? "
|
||||
float noise = noise_strength;" : "") +
|
||||
|
||||
@ -238,5 +264,14 @@ ShaderEffect {
|
||||
"gl_FragColor = vec4(finalColor * screen_brightness, qt_Opacity);" +
|
||||
"}"
|
||||
|
||||
onStatusChanged: if (log) console.log(log) //Print warning messages
|
||||
onStatusChanged: {
|
||||
// Print warning messages
|
||||
if (log)
|
||||
console.log(log);
|
||||
|
||||
// Activate fallback mode
|
||||
if (status == ShaderEffect.Error) {
|
||||
fallBack = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
// Qt
|
||||
#include <QGuiApplication>
|
||||
#include <QtGui/QWindow>
|
||||
#include <QQuickWindow>
|
||||
|
||||
#include <QtCore/QByteRef>
|
||||
#include <QtCore/QDir>
|
||||
@ -143,7 +142,12 @@ WId Session::windowId() const
|
||||
// window = window->parentWidget();
|
||||
// }
|
||||
|
||||
return QGuiApplication::focusWindow()->winId();
|
||||
//return QGuiApplication::focusWindow()->winId();
|
||||
|
||||
//There is an issue here! Probably this always returns zero.
|
||||
//but I try to preseve the behavior there was before.
|
||||
QQuickWindow * window = _views.first()->window();
|
||||
return (window ? window->winId() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,6 @@ KSession::KSession(QObject *parent) :
|
||||
QObject(parent), m_session(createSession("KSession"))
|
||||
{
|
||||
connect(m_session, SIGNAL(finished()), this, SLOT(sessionFinished()));
|
||||
|
||||
m_session->run();
|
||||
}
|
||||
|
||||
KSession::~KSession()
|
||||
@ -159,33 +157,27 @@ void KSession::setEnvironment(const QStringList &environment)
|
||||
|
||||
void KSession::setShellProgram(const QString &progname)
|
||||
{
|
||||
if (!m_session)
|
||||
return;
|
||||
|
||||
m_session->setProgram(progname);
|
||||
}
|
||||
|
||||
void KSession::setWorkingDirectory(const QString &dir)
|
||||
void KSession::setInitialWorkingDirectory(const QString &dir)
|
||||
{
|
||||
if (!m_session)
|
||||
return;
|
||||
|
||||
_initialWorkingDirectory = dir;
|
||||
m_session->setInitialWorkingDirectory(dir);
|
||||
}
|
||||
|
||||
QString KSession::getInitialWorkingDirectory()
|
||||
{
|
||||
return _initialWorkingDirectory;
|
||||
}
|
||||
|
||||
void KSession::setArgs(QStringList &args)
|
||||
{
|
||||
if (!m_session)
|
||||
return;
|
||||
|
||||
m_session->setArguments(args);
|
||||
}
|
||||
|
||||
void KSession::setTextCodec(QTextCodec *codec)
|
||||
{
|
||||
if (!m_session)
|
||||
return;
|
||||
|
||||
m_session->setCodec(codec);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ class KSession : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString kbScheme READ getKeyBindings WRITE setKeyBindings NOTIFY changedKeyBindings)
|
||||
Q_PROPERTY(QString initialWorkingDirectory READ getInitialWorkingDirectory WRITE setInitialWorkingDirectory)
|
||||
|
||||
public:
|
||||
KSession(QObject *parent = 0);
|
||||
@ -43,9 +44,6 @@ public:
|
||||
//bool setup();
|
||||
void addView(KTerminalDisplay *displa);
|
||||
|
||||
//start shell program if it was not started in constructor
|
||||
void startShellProgram();
|
||||
|
||||
int getRandomSeed();
|
||||
QString getKeyBindings();
|
||||
|
||||
@ -54,11 +52,9 @@ public:
|
||||
//environment
|
||||
void setEnvironment(const QStringList & environment);
|
||||
|
||||
// Shell program, default is /bin/bash
|
||||
void setShellProgram(const QString & progname);
|
||||
|
||||
//working directory
|
||||
void setWorkingDirectory(const QString & dir);
|
||||
//Initial working directory
|
||||
void setInitialWorkingDirectory(const QString & dir);
|
||||
QString getInitialWorkingDirectory();
|
||||
|
||||
// Shell program args, default is none
|
||||
void setArgs(QStringList & args);
|
||||
@ -106,6 +102,11 @@ public slots:
|
||||
void setKeyBindings(const QString & kb);
|
||||
void setTitle(QString name);
|
||||
|
||||
void startShellProgram();
|
||||
|
||||
// Shell program, default is /bin/bash
|
||||
void setShellProgram(const QString & progname);
|
||||
|
||||
int getShellPID();
|
||||
void changeDir(const QString & dir);
|
||||
|
||||
@ -125,6 +126,7 @@ private slots:
|
||||
|
||||
private:
|
||||
//Konsole::KTerminalDisplay *m_terminalDisplay;
|
||||
QString _initialWorkingDirectory;
|
||||
Session *m_session;
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user