diff --git a/kcms/useraccount/CMakeLists.txt b/kcms/useraccount/CMakeLists.txt index 96d2ea8e1..82ef52b18 100644 --- a/kcms/useraccount/CMakeLists.txt +++ b/kcms/useraccount/CMakeLists.txt @@ -1,26 +1,25 @@ add_definitions(-DTRANSLATION_DOMAIN=\"useraccount\") add_subdirectory(pics) set(kcm_useraccount_PART_SRCS main.cpp chfacedlg.cpp) ki18n_wrap_ui(kcm_useraccount_PART_SRCS main_widget.ui faceDlg.ui) -kconfig_add_kcfg_files(kcm_useraccount_PART_SRCS settings.kcfgc pass.kcfgc) +kconfig_add_kcfg_files(kcm_useraccount_PART_SRCS settings.kcfgc) add_library(kcm_useraccount MODULE ${kcm_useraccount_PART_SRCS}) target_include_directories(kcm_useraccount PUBLIC "$") target_link_libraries(kcm_useraccount KF5::KDELibs4Support KF5::KIOWidgets ) install(TARGETS kcm_useraccount DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES kcm_useraccount.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES kcm_useraccount.kcfg kcm_useraccount_pass.kcfg DESTINATION ${KCFG_INSTALL_DIR}) diff --git a/kcms/useraccount/kcm_useraccount_pass.kcfg b/kcms/useraccount/kcm_useraccount_pass.kcfg deleted file mode 100644 index c76e4a657..000000000 --- a/kcms/useraccount/kcm_useraccount_pass.kcfg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - OneStar - - - diff --git a/kcms/useraccount/main.cpp b/kcms/useraccount/main.cpp index 32c76fe3d..dc4d8c904 100644 --- a/kcms/useraccount/main.cpp +++ b/kcms/useraccount/main.cpp @@ -1,325 +1,323 @@ /** * Copyright (C) 2004 Frans Englich * * 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 * * * Please see the README * */ #include "main.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "settings.h" -#include "pass.h" #include #include #include #include #include #include #include #include #include #include K_PLUGIN_FACTORY(Factory, registerPlugin(); ) K_EXPORT_PLUGIN(Factory("useraccount")) KCMUserAccount::KCMUserAccount( QWidget *parent, const QVariantList &) : KCModule(parent) { QVBoxLayout *topLayout = new QVBoxLayout(this); topLayout->setSpacing(KDialog::spacingHint()); topLayout->setMargin(0); _mw = new MainWidget(this); topLayout->addWidget( _mw ); connect( _mw->btnChangeFace, SIGNAL(clicked()), SLOT(slotFaceButtonClicked())); connect( _mw->btnChangePassword, SIGNAL(clicked()), SLOT(slotChangePassword())); KGuiItem::assign(_mw->btnChangePassword, KGuiItem( i18n("Change &Password..."), "preferences-desktop-user-password" )); connect( _mw->leRealname, SIGNAL(textChanged(QString)), SLOT(changed())); connect( _mw->leOrganization, SIGNAL(textChanged(QString)), SLOT(changed())); connect( _mw->leEmail, SIGNAL(textChanged(QString)), SLOT(changed())); connect( _mw->leSMTP, SIGNAL(textChanged(QString)), SLOT(changed())); _ku = new KUser(); _kes = new KEMailSettings(); _mw->lblUsername->setText( _ku->loginName() ); QFont font( _mw->lblUsername->font() ); font.setPointSizeF( font.pointSizeF() * 1.41 ); font.setBold( true ); _mw->lblUsername->setFont( font ); _mw->lblUID->setText( QString().number(_ku->uid()) ); KAboutData *about = new KAboutData("kcm_useraccount", i18n("Password & User Information"), "0.1", QString(), KAboutLicense::GPL, i18n("(C) 2002, Braden MacDonald, (C) 2004 Ravikiran Rajagopal")); about->addAuthor(i18n("Frans Englich"), i18n("Maintainer"), "frans.englich@telia.com"); about->addAuthor(i18n("Ravikiran Rajagopal"), QString(), "ravi@kde.org"); about->addAuthor(i18n("Michael H\303\244ckel"), QString(), "haeckel@kde.org" ); about->addAuthor(i18n("Braden MacDonald"), i18n("Face editor"), "bradenm_k@shaw.ca"); about->addAuthor(i18n("Geert Jansen"), i18n("Password changer"), "jansen@kde.org", "http://www.stack.nl/~geertj/"); about->addAuthor(i18n("Daniel Molkentin")); about->addAuthor(i18n("Alex Zepeda")); about->addAuthor(i18n("Hans Karlsson"), i18n("Icons"), "karlsson.h@home.se"); about->addAuthor(i18n("Hermann Thomas"), i18n("Icons"), "h.thomas@gmx.de"); setAboutData(about); setQuickHelp( i18n("Here you can change your personal information, which " "will be used, for instance, in mail programs and word processors. You can " "change your login password by clicking Change Password....") ); - addConfig( KCFGPassword::self(), this ); load(); } void KCMUserAccount::slotChangePassword() { QString bin = KGlobal::dirs()->findExe("kdepasswd"); if ( bin.isEmpty() ) { kDebug() << "kcm_useraccount: kdepasswd was not found."; KMessageBox::sorry ( this, i18n( "A program error occurred: the internal " "program 'kdepasswd' could not be found. You will " "not be able to change your password.")); _mw->btnChangePassword->setEnabled(false); return; } QStringList lst; lst << _ku->loginName(); QProcess::startDetached(bin,lst); } KCMUserAccount::~KCMUserAccount() { delete _ku; delete _kes; } void KCMUserAccount::load() { _mw->lblUsername->setText(_ku->loginName()); _kes->setProfile(_kes->defaultProfileName()); QString realName = _kes->getSetting( KEMailSettings::RealName ); if (realName.isEmpty()) { realName = _ku->property(KUser::FullName).toString(); } _mw->leRealname->setText( realName ); _mw->leEmail->setText( _kes->getSetting( KEMailSettings::EmailAddress )); _mw->leOrganization->setText( _kes->getSetting( KEMailSettings::Organization )); _mw->leSMTP->setText( _kes->getSetting( KEMailSettings::OutServer )); // load user face _facePixmap = QPixmap( KCFGUserAccount::faceFile() ); _mw->btnChangeFace->setIcon( QIcon(_facePixmap) ); if (!_facePixmap.isNull()) { _mw->btnChangeFace->setIconSize(_facePixmap.size().boundedTo(QSize(74,74))); } KCModule::load(); /* KConfigXT */ } void KCMUserAccount::save() { KCModule::save(); /* KConfigXT */ /* * FIXME: there is apparently no way to set full name * non-interactively as a normal user on FreeBSD. */ #ifndef Q_OS_FREEBSD /* Save realname to /etc/passwd */ if ( _mw->leRealname->isModified() ) { // save icon file also with accountsservice QDBusInterface ainterface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", "org.freedesktop.Accounts", QDBusConnection::systemBus()); QDBusReply reply = ainterface.call("FindUserById", qlonglong(_ku->uid())); if (reply.isValid() && !reply.error().isValid()) { QDBusInterface uinterface("org.freedesktop.Accounts", reply.value().path(), "org.freedesktop.Accounts.User", QDBusConnection::systemBus(), this); QString name = _mw->leRealname->text(); QDBusReply ureply = uinterface.call("SetRealName", name); if (!ureply.isValid() || ureply.error().isValid()) { kDebug() << ureply.error().message(); KMessageBox::error( this, i18n("There was an error setting the name: %1" , name) ); } } } #endif /* Save the image */ if( !_facePixmap.isNull() ) { if( !_facePixmap.save( KCFGUserAccount::faceFile(), "PNG" )) { KMessageBox::error( this, i18n("There was an error saving the image: %1" , KCFGUserAccount::faceFile()) ); } // save icon file also with accountsservice QDBusInterface ainterface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", "org.freedesktop.Accounts", QDBusConnection::systemBus()); QDBusReply reply = ainterface.call("FindUserById", qlonglong(_ku->uid())); if (reply.isValid()) { QDBusInterface uinterface("org.freedesktop.Accounts", reply.value().path(), "org.freedesktop.Accounts.User", QDBusConnection::systemBus(), this); QDBusReply ureply = uinterface.call("SetIconFile", KCFGUserAccount::faceFile()); if (!ureply.isValid()) { kDebug() << ureply.error().message(); KMessageBox::error( this, i18n("There was an error setting the image: %1" , KCFGUserAccount::faceFile()) ); } } } else { // delete existing image if (QFile::exists(KCFGUserAccount::faceFile())) { if ( !KIO::NetAccess::del(KCFGUserAccount::faceFile(), this) ) { KMessageBox::error( this, i18n("There was an error deleting the image: %1" , KCFGUserAccount::faceFile()) ); } } } /* Save KDE's homebrewn settings */ _kes->setSetting( KEMailSettings::RealName, _mw->leRealname->text() ); _kes->setSetting( KEMailSettings::EmailAddress, _mw->leEmail->text() ); _kes->setSetting( KEMailSettings::Organization, _mw->leOrganization->text() ); _kes->setSetting( KEMailSettings::OutServer, _mw->leSMTP->text() ); } void KCMUserAccount::changeFace(const QPixmap &pix) { _facePixmap = pix; _mw->btnChangeFace->setIcon( QIcon(_facePixmap) ); if ( !_facePixmap.isNull() ) _mw->btnChangeFace->setIconSize(_facePixmap.size()); emit changed( true ); } void KCMUserAccount::slotFaceButtonClicked() { QString picsdir = QStandardPaths::locate( QStandardPaths::GenericDataLocation, "kdm/pics/users/", QStandardPaths::LocateDirectory ); ChFaceDlg* pDlg = new ChFaceDlg( picsdir, this ); if ( pDlg->exec() == QDialog::Accepted ) changeFace( pDlg->getFaceImage() ); delete pDlg; } /** * I merged faceButtonDropEvent into this /Frans * The function was called after checking event type and * the code is now below that if statement */ bool KCMUserAccount::eventFilter(QObject *, QEvent *e) { if (e->type() == QEvent::DragEnter) { QDragEnterEvent *ee = (QDragEnterEvent *) e; if (!KUrl::List::fromMimeData( ee->mimeData() ).isEmpty()) ee->accept(); else ee->ignore(); return true; } if (e->type() == QEvent::Drop) { KUrl *url = decodeImgDrop( (QDropEvent *) e, this); if (url) { QString pixPath; KIO::NetAccess::download(*url, pixPath, this); changeFace( QPixmap( pixPath ) ); KIO::NetAccess::removeTempFile(pixPath); delete url; } return true; } return false; } inline KUrl *KCMUserAccount::decodeImgDrop(QDropEvent *e, QWidget *wdg) { KUrl::List uris = KUrl::List::fromMimeData(e->mimeData()); if (!uris.isEmpty()) { KUrl *url = new KUrl(uris.first()); KMimeType::Ptr mime = KMimeType::findByUrl( *url ); if ( mime && KImageIO::isSupported( mime->name(), KImageIO::Reading ) ) return url; QStringList qs = KImageIO::pattern().split( '\n'); qs.erase(qs.begin()); QString msg = i18n( "%1 does not appear to be an image file.\n" "Please use files with these extensions:\n" "%2", url->fileName(), qs.join("\n")); KMessageBox::sorry( wdg, msg); delete url; } return 0; } #include "main.moc" diff --git a/kcms/useraccount/main_widget.ui b/kcms/useraccount/main_widget.ui index 3b0f0d8ec..781321af8 100644 --- a/kcms/useraccount/main_widget.ui +++ b/kcms/useraccount/main_widget.ui @@ -1,308 +1,272 @@ Frans Englich <frans.englich@telia.com> MainWidget 0 0 - 399 - 557 + 439 + 671 0 0 0 74 74 74 74 true Change your image 0 Qt::AlignVCenter false <i>Click to change your image</i> Qt::AlignVCenter false Change Password... Qt::Horizontal QSizePolicy::Expanding 158 18 User Information &Name: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter false leRealname true &Organization: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter false leOrganization true &Email address: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter false leEmail true &SMTP server: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter false leSMTP true User ID: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter false false - - - - At Password Prompt - - - - - - Show one bullet for each letter - - - - - - - Show three bullets for each letter - - - - - - - Show nothing - - - - - - Qt::Vertical QSizePolicy::Expanding 20 16 - - KButtonGroup - QGroupBox -
kbuttongroup.h
- 1 -
KLineEdit QLineEdit
klineedit.h
btnChangeFace leRealname leOrganization leEmail leSMTP btnChangePassword
diff --git a/kcms/useraccount/pass.kcfgc b/kcms/useraccount/pass.kcfgc deleted file mode 100644 index 21b4bb781..000000000 --- a/kcms/useraccount/pass.kcfgc +++ /dev/null @@ -1,5 +0,0 @@ -File=kcm_useraccount_pass.kcfg -ClassName=KCFGPassword -Singleton=true -Mutators=true -