summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-07-01 15:18:54 +0200
committerSimon Rettberg2022-07-01 15:18:54 +0200
commit9ce1c23c3d9a81ef6aaf86a264fca457ead3a7f2 (patch)
treea384cecb465bf46ed95e5f55e8f8006fa594cb63
parentAdd user-session-enabled and shib-session-button-text (diff)
downloadslxgreeter-29r2.tar.gz
slxgreeter-29r2.tar.xz
slxgreeter-29r2.zip
Fix showing browser immediately if only shib-login is enabledv29r2
-rw-r--r--src/loginform.cpp52
-rw-r--r--src/loginform.h2
-rw-r--r--src/loginrpc.cpp2
-rw-r--r--src/mainwindow.cpp9
-rw-r--r--src/settings.h1
-rw-r--r--src/webview.cpp7
6 files changed, 50 insertions, 23 deletions
diff --git a/src/loginform.cpp b/src/loginform.cpp
index 769c104..50bd08e 100644
--- a/src/loginform.cpp
+++ b/src/loginform.cpp
@@ -43,7 +43,8 @@ LoginForm::LoginForm(QWidget *parent) :
ui(new Ui::LoginForm),
browser(nullptr),
clearMsg(false),
- capsOn(-1)
+ capsOn(-1),
+ pageCount(0)
{
ui->setupUi(this);
origSize = shibSize = sizeHint();
@@ -166,8 +167,8 @@ void LoginForm::initialize()
});
resetFormTimer.start(Settings::resetForm() * 1000);
}
+ ui->backButton->hide();
- int pageCount = 0;
if (Settings::guestSessionEnabled()) {
pageCount++;
if (!Settings::guestSessionButtonText().isEmpty()) {
@@ -194,19 +195,7 @@ void LoginForm::initialize()
if (!Settings::shibSessionButtonText().isEmpty()) {
ui->shibButton->setText(Settings::shibSessionButtonText());
}
- connect(ui->shibButton, &QAbstractButton::released, this, [this]() {
- if (browser == nullptr) {
- browser = new WebView(ui->shibPage);
- ui->verticalLayout_5->addWidget(browser);
- connect(browser, &WebView::triggerReset, [this](const QString &message) {
- this->showMessage(message, true);
- ui->loginChooser->setCurrentWidget(ui->welcomePage);
- });
- connect(browser, &WebView::startAuthentication, this, &LoginForm::startAuthAs);
- }
- browser->reset(Settings::shibUrl());
- ui->loginChooser->setCurrentWidget(ui->shibPage);
- });
+ connect(ui->shibButton, &QAbstractButton::released, this, &LoginForm::showShibWindow);
// Reduce minimum size of hostname/icon bar
ui->frame->setMinimumSize(10, 30);
ui->frame->setMaximumSize(99999, ui->iconLabel->height());
@@ -223,10 +212,10 @@ void LoginForm::initialize()
}
if (pageCount > 1) {
- ui->loginChooser->setCurrentWidget(ui->welcomePage);
connect(ui->backButton, &QAbstractButton::released, this, [this]() {
resetForm();
});
+ ui->loginChooser->setCurrentWidget(ui->welcomePage);
connect(ui->loginChooser, &QStackedWidget::currentChanged, this, [this]() {
if (ui->loginChooser->currentWidget() == ui->welcomePage) {
ui->backButton->hide();
@@ -239,7 +228,7 @@ void LoginForm::initialize()
ui->userInput->setFocus();
});
} else if (Settings::shibSessionEnabled()) {
- ui->loginChooser->setCurrentWidget(ui->shibPage);
+ this->showShibWindow();
} else if (Settings::guestSessionEnabled()) {
ui->loginChooser->setCurrentWidget(ui->guestPage);
} else {
@@ -276,7 +265,6 @@ void LoginForm::initialize()
// Load regexp for name substitution
NameReplace::loadSubs();
- ui->backButton->hide();
ui->leaveComboBox->setDisabled(ui->leaveComboBox->count() <= 1);
ui->passwordInput->clear();
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
@@ -284,6 +272,25 @@ void LoginForm::initialize()
checkCaps();
}
+void LoginForm::showShibWindow() {
+ if (browser == nullptr) {
+ browser = new WebView(ui->shibPage);
+ ui->verticalLayout_5->addWidget(browser);
+ connect(browser, &WebView::triggerReset, [this](const QString &message) {
+ this->showMessage(message, true);
+ if (pageCount == 1) {
+ showShibWindow();
+ } else {
+ ui->loginChooser->setCurrentWidget(ui->welcomePage);
+ }
+ });
+ connect(browser, &WebView::startAuthentication, this, &LoginForm::startAuthAs);
+ }
+ browser->reset(Settings::shibUrl());
+ ui->loginChooser->setCurrentWidget(ui->shibPage);
+ setBrowserSize();
+}
+
void LoginForm::checkCaps()
{
unsigned int mask = getKeyMask(QX11Info::display());
@@ -465,12 +472,17 @@ void LoginForm::keyPressEvent(QKeyEvent *event)
void LoginForm::resetForm()
{
- if (Settings::guestSessionEnabled() || Settings::shibSessionEnabled()) {
+ std::cerr << "PageCount: " << pageCount;
+ if (pageCount > 1) {
ui->loginChooser->setCurrentWidget(ui->welcomePage);
}
ui->passwordInput->clear();
ui->userInput->clear();
- ui->userInput->setFocus();
+ if (pageCount == 1) {
+ if (Settings::userSessionEnabled()) {
+ ui->userInput->setFocus();
+ }
+ }
}
bool LoginForm::eventFilter(QObject *object, QEvent *event)
diff --git a/src/loginform.h b/src/loginform.h
index 9f65194..10e1d2b 100644
--- a/src/loginform.h
+++ b/src/loginform.h
@@ -49,6 +49,7 @@ public slots:
private slots:
void setBrowserSize();
+ void showShibWindow();
signals:
void resized();
@@ -81,6 +82,7 @@ private:
bool clearMsg;
int capsOn;
+ int pageCount;
};
#endif // LOGINFORM_H
diff --git a/src/loginrpc.cpp b/src/loginrpc.cpp
index 24b5b11..df28600 100644
--- a/src/loginrpc.cpp
+++ b/src/loginrpc.cpp
@@ -69,7 +69,7 @@ void LoginRpc::handleCommandV1(const QString &command)
// Get all outputs
QStringList setMode("--verbose");
p.setProcessChannelMode(QProcess::MergedChannels);
- p.start("xrandr");
+ p.start("xrandr", QStringList());
p.waitForFinished(2000);
QString out = QString::fromLocal8Bit(p.readAll());
QRegularExpression re("^(\\S+)\\s.*?(\\w*connected)", QRegularExpression::MultilineOption);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b331da5..ce117ee 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -19,6 +19,7 @@
#include <QAbstractTextDocumentLayout>
#include <QDateTime>
#include <QPainter>
+#include <QFile>
#include <sys/types.h>
#include <sys/socket.h>
@@ -68,6 +69,14 @@ MainWindow::MainWindow(bool primary, int screen, const QRect &screenRect, QWidge
createClock();
createNewsWindow();
+ if (QFile::exists(CONFIG_QSS_FILE)) {
+ QFile qss(CONFIG_QSS_FILE);
+ if (qss.open(QFile::ReadOnly)) {
+ this->setStyleSheet(qss.readAll());
+ } else {
+ qDebug() << "Cannot open" << CONFIG_QSS_FILE << "for reading";
+ }
+ }
setGeometry(screenRect);
}
diff --git a/src/settings.h b/src/settings.h
index 7542db1..fe5f530 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -6,6 +6,7 @@
#define CONFIG_FILE "/etc/lightdm/qt-lightdm-greeter.conf"
#define CONFIG_FOLDER "/etc/lightdm/qt-lightdm-greeter.conf.d"
+#define CONFIG_QSS_FILE "/etc/lightdm/qt-lightdm-greeter.qss"
class Settings;
extern Settings *s_settings;
diff --git a/src/webview.cpp b/src/webview.cpp
index 802a5f8..4f46a27 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -41,9 +41,9 @@ WebView::WebView(QWidget* parent)
connect(page(), SIGNAL(downloadRequested(QNetworkRequest)),this,SLOT(downloadRequest(QNetworkRequest)));
connect(_timerAbortMessage, &QTimer::timeout, this, &WebView::downloadDeniedMessage);
connect(_timerReset, &QTimer::timeout, this, [this]() {
- emit triggerReset(tr("Inactivity Timeout"));
this->stop();
this->page()->mainFrame()->setContent("");
+ emit triggerReset(tr("Inactivity Timeout"));
});
connect(this, &QWebView::loadFinished, this, &WebView::onLoadFinished);
}
@@ -124,9 +124,9 @@ void WebView::onLoadFinished(bool ok)
if (!user.isNull() && !pass.isNull()) {
emit startAuthentication(user.toPlainText(), "shib=" + _token + pass.toPlainText());
} else if (!err.isNull()) {
- emit triggerReset(err.toPlainText());
this->stop();
this->page()->mainFrame()->setContent("");
+ emit triggerReset(err.toPlainText());
} else {
_timerReset->start(60000);
}
@@ -150,4 +150,7 @@ void WebView::reset(const QString baseUrl)
this->setUrl(url);
_timerAbortMessage->stop();
_timerReset->stop();
+ QTimer::singleShot(5000, [this]() {
+ _timerReset->stop();
+ });
}