Commit d0db1577 authored by David Edmundson's avatar David Edmundson

Remove unused class SelectImageButton

Summary:
Was some old code by me, presumably for wallpaper selection years ago.
It's unused.

Test Plan: Compiles

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9677
parent 6ad59c86
......@@ -3,7 +3,6 @@ add_definitions(-DTRANSLATION_DOMAIN=\"screenlocker_kcm\")
set(screenlocker_kcm_SRCS
kcm.cpp
selectimagebutton.cpp
../greeter/wallpaper_integration.cpp
)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../)
......
......@@ -67,8 +67,6 @@ ScreenLockerKcm::ScreenLockerKcm(QWidget *parent, const QVariantList &args)
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
KConfigDialogManager::changedMap()->insert(QStringLiteral("SelectImageButton"), SIGNAL(imagePathChanged(QString)));
addConfig(KScreenSaverSettings::self(), m_ui);
m_actionCollection->setConfigGlobal(true);
......
/*
* Button for selecting an image.
*
* Copyright (C) 2011 Martin Klapetek <martin.klapetek@gmail.com>
* Copyright (C) 2011, 2012, 2014 David Edmundson <kde@davidedmundson.co.uk>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "selectimagebutton.h"
#include <QWidgetAction>
#include <QUrl>
#include <QFileDialog>
#include <QMenu>
#include <KLocalizedString>
#include <KMessageBox>
SelectImageButton::SelectImageButton(QWidget *parent)
: QToolButton(parent)
{
QMenu *menu = new QMenu(this);
setPopupMode(QToolButton::InstantPopup);
setIconSize(QSize(64,64));
menu->addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("Load from file..."), this, SLOT(onLoadImageFromFile()));
menu->addAction(QIcon::fromTheme(QStringLiteral("edit-clear")), i18n("Clear Image"), this, SLOT(onClearImage()));
setMenu(menu);
onClearImage();
}
SelectImageButton::~SelectImageButton() = default;
void SelectImageButton::setImagePath(const QString &imagePath)
{
m_imagePath = imagePath;
QPixmap image(imagePath);
if (!image.isNull()) {
QIcon imageIcon;
//scale oversized avatars to fit, but don't stretch smaller images
imageIcon.addPixmap(image.scaled(iconSize().boundedTo(image.size()), Qt::KeepAspectRatio));
setIcon(imageIcon);
} else {
setIcon(QIcon::fromTheme(QStringLiteral("image-x-generic")));
}
Q_EMIT imagePathChanged(m_imagePath);
}
QString SelectImageButton::imagePath() const
{
return m_imagePath;
}
void SelectImageButton::onLoadImageFromFile()
{
QUrl fileUrl = QFileDialog::getOpenFileUrl(this, i18n("Select image"), QUrl(), QStringLiteral("image/*"), 0, 0, QStringList() << QStringLiteral("file"));
if (!fileUrl.isEmpty()) {
setImagePath(fileUrl.path());
}
}
void SelectImageButton::onClearImage()
{
setImagePath(QString());
}
/*
* Button representing user's Avatar
*
* Copyright (C) 2011 Martin Klapetek <martin.klapetek@gmail.com>
* Copyright (C) 2011, 2012 David Edmundson <kde@davidedmundson.co.uk>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef SELECTIMAGEBUTTON_H
#define SELECTIMAGEBUTTON_H
#include <QToolButton>
class SelectImageButton : public QToolButton
{
Q_OBJECT
Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged USER true)
public:
SelectImageButton(QWidget* parent = 0);
virtual ~SelectImageButton();
//we use QString rather that QUrl because it seems to work better with KConfigXT
void setImagePath(const QString &imagePath);
QString imagePath() const;
Q_SIGNALS:
void imagePathChanged(QString);
private Q_SLOTS:
void onLoadImageFromFile();
void onClearImage();
private:
QString m_imagePath;
};
#endif //AVATAR_BUTTON_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment