[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->confirmRootPw->setText(dlg->password);
|
||||
}
|
||||
|
||||
ui->labelNoUser->hide();
|
||||
}
|
||||
|
||||
delete dlg;
|
||||
@ -272,7 +274,7 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
|
||||
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) );
|
||||
}
|
||||
}
|
||||
@ -292,12 +294,8 @@ UsersPage::onActivate()
|
||||
{
|
||||
emit checkReady( isReady() );
|
||||
|
||||
// If there is no user yet, open the dialog as soon as the
|
||||
// page is enabled. This makes it easy for people who want
|
||||
// to create one user.
|
||||
if (m_userModel.rowCount() == 0) {
|
||||
addUserClicked();
|
||||
}
|
||||
ui->labelNoUser->setText( QObject::tr( "Please create at least one user." ) );
|
||||
ui->labelNoUser->show();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>694</width>
|
||||
<height>475</height>
|
||||
<height>447</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -109,7 +109,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>678</width>
|
||||
<height>249</height>
|
||||
<height>197</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -270,6 +270,18 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelNoUser">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -19,16 +19,19 @@
|
||||
#include <jobs/SetAvatarJob.h>
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include <QFile>
|
||||
#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()
|
||||
, m_avatarFile(avatarFile)
|
||||
, m_destPath(destPath)
|
||||
, m_owner(owner)
|
||||
, m_group(group)
|
||||
{
|
||||
}
|
||||
|
||||
@ -70,15 +73,23 @@ Calamares::JobResult SetAvatarJob::exec()
|
||||
|
||||
QString destination( destDir + m_destPath );
|
||||
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()) {
|
||||
cLog() << "Avatar file does not exist";
|
||||
return Calamares::JobResult::error( tr("Avatar file does not exist") );
|
||||
}
|
||||
|
||||
if (!avatarFile.copy(destination)) {
|
||||
cLog() << "Error copying:" << avatarFile.errorString();
|
||||
return Calamares::JobResult::error( tr("Error copying") );
|
||||
cLog() << "Error copying avatar:" << avatarFile.errorString();
|
||||
} 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();
|
||||
|
@ -25,7 +25,7 @@ class SetAvatarJob : public Calamares::Job
|
||||
{
|
||||
Q_OBJECT
|
||||
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 prettyDescription() const override;
|
||||
QString prettyStatusMessage() const override;
|
||||
@ -33,6 +33,9 @@ public:
|
||||
private:
|
||||
const QString m_avatarFile;
|
||||
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