Applet::name() -> Applet::title()

since the applet user visible name/title can be set by the user, is not to be confused with the metadata coming from KPluginInfo
This commit is contained in:
Marco Martin 2013-02-12 11:30:25 +01:00
parent bd9e863c6d
commit 39151c048f
8 changed files with 38 additions and 34 deletions

View File

@ -382,10 +382,10 @@ bool Applet::isBusy() const
return d->isBusy();
}
QString Applet::name() const
QString Applet::title() const
{
if (!d->customName.isEmpty()) {
return d->customName;
if (!d->customTitle.isEmpty()) {
return d->customTitle;
}
if (d->isContainment) {
@ -404,9 +404,9 @@ QString Applet::name() const
return d->appletDescription.name();
}
void Applet::setName(const QString &name) const
void Applet::setTitle(const QString &title) const
{
d->customName = name;
d->customTitle = title;
}
QFont Applet::font() const
@ -737,7 +737,7 @@ void Applet::setGlobalShortcut(const KShortcut &shortcut)
{
if (!d->activationAction) {
d->activationAction = new KAction(this);
d->activationAction->setText(i18n("Activate %1 Widget", name()));
d->activationAction->setText(i18n("Activate %1 Widget", title()));
d->activationAction->setObjectName(QString("activate widget %1").arg(id())); // NO I18N
connect(d->activationAction, SIGNAL(triggered()), this, SIGNAL(activate()));
connect(d->activationAction, SIGNAL(globalShortcutChanged(QKeySequence)),
@ -855,7 +855,7 @@ void Applet::showConfigurationInterface()
QUiLoader loader;
QWidget *w = loader.load(&f);
if (w) {
dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name()));
dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", title()));
hasPages = true;
}
@ -891,7 +891,7 @@ void Applet::showConfigurationInterface()
hasPages = true;
} else {
#ifndef NDEBUG
kDebug() << "failed to load kcm" << kcm << "for" << name();
kDebug() << "failed to load kcm" << kcm << "for" << title();
#endif
}
}

View File

@ -235,18 +235,22 @@ class PLASMA_EXPORT Applet : public QObject
//METADATA
/**
* Returns the user-visible name for the applet, as specified in the
* .desktop file. Can be changed with @see setName
* Returns the user-visible title for the applet, as specified in the
* Name field of the .desktop file. Can be changed with @see setTitle
*
* @return the user-visible name for the applet.
* @since 5.0
* @return the user-visible title for the applet.
**/
QString name() const;
QString title() const;
/**
* Sets a custom name for this instance of the applet. E.g. a clock might
* Sets a custom title for this instance of the applet. E.g. a clock might
* use the timezone as its name rather than the .desktop file
*
* @since 5.0
* @param title the user-visible title for the applet.
*/
void setName(const QString &name) const;
void setTitle(const QString &title) const;
/**
* Returns a list of all known applets.

View File

@ -120,16 +120,16 @@ void Containment::init()
ContainmentPrivate::addDefaultActions(d->actions(), this);
bool unlocked = immutability() == Mutable;
//fix the text of the actions that need name()
//btw, do we really want to use name() when it's a desktopcontainment?
//fix the text of the actions that need title()
//btw, do we really want to use title() when it's a desktopcontainment?
QAction *closeApplet = action("remove");
if (closeApplet) {
closeApplet->setText(i18nc("%1 is the name of the applet", "Remove this %1", name()));
closeApplet->setText(i18nc("%1 is the name of the applet", "Remove this %1", title()));
}
QAction *configAction = action("configure");
if (configAction) {
configAction->setText(i18nc("%1 is the name of the applet", "%1 Settings", name()));
configAction->setText(i18nc("%1 is the name of the applet", "%1 Settings", title()));
}
QAction *appletBrowserAction = action("add widgets");
@ -858,12 +858,12 @@ void Containment::destroy(bool confirm)
if (isContainment() && confirm) {
//FIXME: should not be blocking
const QString title = i18nc("@title:window %1 is the name of the containment", "Remove %1", name());
const QString title = i18nc("@title:window %1 is the name of the containment", "Remove %1", Containment::title());
KGuiItem remove = KStandardGuiItem::remove();
remove.setText(title);
//FIXME: make the view accessible?
if (KMessageBox::warningContinueCancel(0/*view()*/,
i18nc("%1 is the name of the containment", "Do you really want to remove this %1?", name()),
i18nc("%1 is the name of the containment", "Do you really want to remove this %1?", Containment::title()),
title, remove) != KMessageBox::Continue) {
return;
}

View File

@ -83,7 +83,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
AppletPrivate::~AppletPrivate()
{
if (activationAction && activationAction->isGlobalShortcutEnabled()) {
//kDebug() << "reseting global action for" << q->name() << activationAction->objectName();
//kDebug() << "reseting global action for" << q->title() << activationAction->objectName();
activationAction->forgetGlobalShortcut();
}
@ -110,12 +110,12 @@ void AppletPrivate::init(const QString &packagePath)
QAction *closeApplet = actions->action("remove");
if (closeApplet) {
closeApplet->setText(i18nc("%1 is the name of the applet", "Remove this %1", q->name()));
closeApplet->setText(i18nc("%1 is the name of the applet", "Remove this %1", q->title()));
}
QAction *configAction = actions->action("configure");
if (configAction) {
configAction->setText(i18nc("%1 is the name of the applet", "%1 Settings", q->name()));
configAction->setText(i18nc("%1 is the name of the applet", "%1 Settings", q->title()));
}
QObject::connect(q, SIGNAL(activate()), q, SLOT(setFocus()));
@ -263,12 +263,12 @@ KActionCollection* AppletPrivate::defaultActions(QObject *parent)
QString AppletPrivate::configDialogId() const
{
return QString("%1settings%2").arg(appletId).arg(q->name());
return QString("%1settings%2").arg(appletId).arg(q->title());
}
QString AppletPrivate::configWindowTitle() const
{
return i18nc("@title:window", "%1 Settings", q->name());
return i18nc("@title:window", "%1 Settings", q->title());
}
QSet<QString> AppletPrivate::knownCategories()
@ -548,7 +548,7 @@ KConfigGroup *AppletPrivate::mainConfigGroup()
appletConfig = c->config();
appletConfig = KConfigGroup(&appletConfig, "Applets");
} else {
kWarning() << "requesting config for" << q->name() << "without a containment!";
kWarning() << "requesting config for" << q->title() << "without a containment!";
appletConfig = KConfigGroup(KSharedConfig::openConfig(), "Applets");
}

View File

@ -137,7 +137,7 @@ public:
// applet info we keep around in case its needed
KPluginInfo appletDescription;
QVariantList args;
QString customName;
QString customTitle;
// bookkeeping
KConfigGroup *mainConfig;

View File

@ -111,7 +111,7 @@ void ContainmentPrivate::initApplets()
applet->restore(*applet->d->mainConfigGroup());
applet->init();
#ifndef NDEBUG
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Applet" << applet->name();
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Applet" << applet->title();
#endif
}
@ -122,7 +122,7 @@ void ContainmentPrivate::initApplets()
}
#ifndef NDEBUG
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Containment's applets initialized" << q->name();
kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Containment's applets initialized" << q->title();
#endif
}
@ -165,7 +165,7 @@ void ContainmentPrivate::addAppletActions(KMenu &desktopMenu, Applet *applet, QE
}
}
KMenu *containmentMenu = new KMenu(i18nc("%1 is the name of the containment", "%1 Options", q->name()), &desktopMenu);
KMenu *containmentMenu = new KMenu(i18nc("%1 is the name of the containment", "%1 Options", q->title()), &desktopMenu);
addContainmentActions(*containmentMenu, event);
if (!containmentMenu->isEmpty()) {
int enabled = 0;
@ -409,7 +409,7 @@ Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &a
applet->setFailedToLaunch(true, i18n("Could not find requested component: %1", name));
}
//kDebug() << applet->name() << "sizehint:" << applet->sizeHint() << "geometry:" << applet->geometry();
//kDebug() << applet->title() << "sizehint:" << applet->sizeHint() << "geometry:" << applet->geometry();
q->addApplet(applet, appletGeometry.topLeft());
return applet;

View File

@ -444,7 +444,7 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPoi
QObject *appletGraphicObject = applet->property("graphicObject").value<QObject *>();
QObject *contGraphicObject = containment()->property("graphicObject").value<QObject *>();
qDebug() << "Applet added:" << applet << applet->name() << appletGraphicObject;
qDebug() << "Applet added:" << applet << applet->title() << appletGraphicObject;
if (applet && contGraphicObject && appletGraphicObject) {
appletGraphicObject->setProperty("visible", false);

View File

@ -54,8 +54,8 @@ void DesktopCorona::loadDefaultLayout()
cont->setScreen(0);
qDebug() << containmentForScreen(0);
Plasma::Applet *appl = cont->addApplet("org.kde.testapplet");
qDebug() << "Containment:" << cont << cont->name();
qDebug() << "Applet:" << appl->name() << appl;
qDebug() << "Containment:" << cont << cont->title();
qDebug() << "Applet:" << appl->title() << appl;
}
void DesktopCorona::checkScreens(bool signalWhenExists)