[users] adopt upstream changes
- Change permissions of avatar file after copying - Use Calamares utils rather than QProcess - Remove modal dialog and show warning message instead
This commit is contained in:
parent
c36641aa0a
commit
3725c46a3c
@ -193,6 +193,8 @@ UsersPage::addUserClicked() {
|
|||||||
ui->rootPw->setText(dlg->password);
|
ui->rootPw->setText(dlg->password);
|
||||||
ui->confirmRootPw->setText(dlg->password);
|
ui->confirmRootPw->setText(dlg->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->labelNoUser->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete dlg;
|
delete dlg;
|
||||||
@ -272,7 +274,7 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
|
|||||||
m_avatarFilePath.replace("~", home);
|
m_avatarFilePath.replace("~", home);
|
||||||
}
|
}
|
||||||
|
|
||||||
j = new SetAvatarJob( user->avatarFile, m_avatarFilePath );
|
j = new SetAvatarJob( user->avatarFile, m_avatarFilePath, user->username, defaultGroupsList[0] );
|
||||||
list.append( Calamares::job_ptr(j) );
|
list.append( Calamares::job_ptr(j) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,12 +294,8 @@ UsersPage::onActivate()
|
|||||||
{
|
{
|
||||||
emit checkReady( isReady() );
|
emit checkReady( isReady() );
|
||||||
|
|
||||||
// If there is no user yet, open the dialog as soon as the
|
ui->labelNoUser->setText( QObject::tr( "Please create at least one user." ) );
|
||||||
// page is enabled. This makes it easy for people who want
|
ui->labelNoUser->show();
|
||||||
// to create one user.
|
|
||||||
if (m_userModel.rowCount() == 0) {
|
|
||||||
addUserClicked();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>694</width>
|
<width>694</width>
|
||||||
<height>475</height>
|
<height>447</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -109,7 +109,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>678</width>
|
<width>678</width>
|
||||||
<height>249</height>
|
<height>197</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -270,6 +270,18 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelNoUser">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -19,16 +19,19 @@
|
|||||||
#include <jobs/SetAvatarJob.h>
|
#include <jobs/SetAvatarJob.h>
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
SetAvatarJob::SetAvatarJob(const QString &avatarFile, const QString &destPath)
|
SetAvatarJob::SetAvatarJob(const QString &avatarFile, const QString &destPath, const QString& owner, const QString& group)
|
||||||
: Calamares::Job()
|
: Calamares::Job()
|
||||||
, m_avatarFile(avatarFile)
|
, m_avatarFile(avatarFile)
|
||||||
, m_destPath(destPath)
|
, m_destPath(destPath)
|
||||||
|
, m_owner(owner)
|
||||||
|
, m_group(group)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,15 +73,23 @@ Calamares::JobResult SetAvatarJob::exec()
|
|||||||
|
|
||||||
QString destination( destDir + m_destPath );
|
QString destination( destDir + m_destPath );
|
||||||
QFile avatarFile( m_avatarFile );
|
QFile avatarFile( m_avatarFile );
|
||||||
|
QString userGroup( m_owner + ":" + m_group );
|
||||||
|
|
||||||
|
// We do not return errors in case of issues with the avatar, as it is not
|
||||||
|
// critical enough to stop the whole installation.
|
||||||
if (!avatarFile.exists()) {
|
if (!avatarFile.exists()) {
|
||||||
cLog() << "Avatar file does not exist";
|
cLog() << "Avatar file does not exist";
|
||||||
return Calamares::JobResult::error( tr("Avatar file does not exist") );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!avatarFile.copy(destination)) {
|
if (!avatarFile.copy(destination)) {
|
||||||
cLog() << "Error copying:" << avatarFile.errorString();
|
cLog() << "Error copying avatar:" << avatarFile.errorString();
|
||||||
return Calamares::JobResult::error( tr("Error copying") );
|
} else {
|
||||||
|
int ec = CalamaresUtils::System::instance()->
|
||||||
|
targetEnvCall({ "chown",
|
||||||
|
userGroup,
|
||||||
|
m_destPath });
|
||||||
|
if ( ec ) {
|
||||||
|
cLog() << "Error changing ownership of the avatar file. Exit code: " << ec;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
|
@ -25,7 +25,7 @@ class SetAvatarJob : public Calamares::Job
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SetAvatarJob( const QString& avatarFile, const QString& destPath );
|
SetAvatarJob( const QString& avatarFile, const QString& destPath, const QString& owner, const QString& group );
|
||||||
QString prettyName() const override;
|
QString prettyName() const override;
|
||||||
QString prettyDescription() const override;
|
QString prettyDescription() const override;
|
||||||
QString prettyStatusMessage() const override;
|
QString prettyStatusMessage() const override;
|
||||||
@ -33,6 +33,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
const QString m_avatarFile;
|
const QString m_avatarFile;
|
||||||
const QString m_destPath;
|
const QString m_destPath;
|
||||||
|
// Owner and group of the destination avatar file.
|
||||||
|
const QString m_owner;
|
||||||
|
const QString m_group;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user