Ejemplo n.º 1
0
bool AppletScript::isRegisteredAsDragHandle(QGraphicsItem *item)
{
    if (applet()) {
        return applet()->isRegisteredAsDragHandle(item);
    }
    return false;
}
Ejemplo n.º 2
0
void AppletScript::showConfigurationInterface()
{
    if (applet()) {
        KConfigDialog *dialog = applet()->d->generateGenericConfigDialog();
        applet()->d->addStandardConfigurationPages(dialog);
        dialog->show();
    }
}
Ejemplo n.º 3
0
AppletInterface::AppletInterface(SimpleJavaScriptApplet *parent)
    : QObject(parent),
      m_appletScriptEngine(parent),
      m_actionSignals(0)
{
    connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus()));
    connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving()));
}
Ejemplo n.º 4
0
QSizeF AppletScript::size() const
{
    if (applet()) {
        return applet()->size();
    }

    return QSizeF();
}
Ejemplo n.º 5
0
KConfigDialog *AppletScript::standardConfigurationDialog()
{
    if (applet()) {
        return applet()->d->generateGenericConfigDialog();
    }

    return 0;
}
Ejemplo n.º 6
0
QPainterPath AppletScript::shape() const
{
    if (applet()) {
        QPainterPath path;
        path.addRect(applet()->boundingRect());
        return path;
    }

    return QPainterPath();
}
Ejemplo n.º 7
0
AppletInterface::AppletInterface(AbstractJsAppletScript *parent)
    : QObject(parent),
      m_appletScriptEngine(parent),
      m_actionSignals(0)
{
    connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus()));
    connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving()));
    connect(applet(), SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SIGNAL(immutableChanged()));
    connect(applet(), SIGNAL(newStatus(Plasma::ItemStatus)), this, SIGNAL(statusChanged()));
    connect(m_appletScriptEngine, SIGNAL(formFactorChanged()),
            this, SIGNAL(formFactorChanged()));
    connect(m_appletScriptEngine, SIGNAL(locationChanged()),
            this, SIGNAL(locationChanged()));
    connect(m_appletScriptEngine, SIGNAL(contextChanged()),
            this, SIGNAL(contextChanged()));
}
int main()
{
    KComponentData cd("notifications-to-orgkdenotifications-update");
    QString file = KStandardDirs::locateLocal("config", "plasma-desktop-appletsrc");

    if (file.isEmpty()) {
        return 0;
    }

    KConfig config(file);
    KConfigGroup containments(&config, "Containments");
    foreach (const QString &group, containments.groupList()) {
        KConfigGroup applets(&containments, group);
        applets = KConfigGroup(&applets, "Applets");
        foreach (const QString &appletGroup, applets.groupList()) {
            KConfigGroup applet(&applets, appletGroup);
            QString plugin = applet.readEntry("plugin", QString());
            if (plugin == "notifications") {
                applet.writeEntry("plugin", "org.kde.notifications");
            } else if (plugin == "systemtray") {
                KConfigGroup subApplets(&applet, "Configuration");
                subApplets = KConfigGroup(&subApplets, "Applets");
                foreach (const QString &subAppletGroup, subApplets.groupList()) {
                    
                    KConfigGroup subApplet(&subApplets, subAppletGroup);
                    QString subPlugin = subApplet.readEntry("plugin", QString());

                    if (subPlugin == "notifications") {
                        subApplet.writeEntry("plugin", "org.kde.notifications");
                    }
                }
            }
        }
    }
Ejemplo n.º 9
0
void SingleView::updateGeometry()
{
    if (!m_containment) {
        return;
    }

    //kDebug() << "New applet geometry is" << m_applet->geometry();

    if (m_applet) {
        if (m_applet->size().toSize() != size()) {
            m_applet->resize(size());
        }

        setSceneRect(m_applet->sceneBoundingRect());
    }

    if ((windowFlags() & Qt::FramelessWindowHint) &&
            applet()->backgroundHints() != Plasma::Applet::NoBackground) {

        // TODO: Use the background's mask for blur
        QRegion mask;
        mask += QRect(QPoint(), size());

        Plasma::WindowEffects::enableBlurBehind(winId(), true, mask);
    }
}
Ejemplo n.º 10
0
void DashboardApplet::loadFinished(bool success)
{
    WebApplet::loadFinished(success);
    if (success) {
        view()->resize(view()->mainFrame()->contentsSize());
        applet()->resize(view()->mainFrame()->contentsSize());
    }
}
Ejemplo n.º 11
0
void usage(FILE * f, char * const arg0)
{
	fprintf(f, "Usage: %s [OPTIONS]\n\n"
		   "Options:\n"
		   " -t or --timeout SECOND Set time-out in seconds [default=-1].\n"
		   " -s or --row-size SIZE  Set row size in bytes [default=16].\n"
		   " -h or --help           Display this message.\n"
		   " -v or --version        Display the version.\n"
		   "", applet(arg0));
}
Ejemplo n.º 12
0
QList<QAction*> AppletInterface::contextualActions() const
{
    QList<QAction*> actions;
    Plasma::Applet *a = applet();

    foreach (const QString &name, m_actions) {
        QAction *action = a->action(name);

        if (action) {
            actions << action;
        }
    }
Ejemplo n.º 13
0
void AppletInterface::setActiveConfig(const QString &name)
{
    if (name == "main") {
        m_currentConfig.clear();
        return;
    }

    Plasma::ConfigLoader *loader = m_configs.value(name, 0);

    if (!loader) {
        QString path = applet()->package()->filePath("config", name + ".xml");
        if (path.isEmpty()) {
            return;
        }

        QFile f(path);
        KConfigGroup cg = applet()->config();
        loader = new Plasma::ConfigLoader(&cg, &f, this);
        m_configs.insert(name, loader);
    }

    m_currentConfig = name;
}
Ejemplo n.º 14
0
//----  --------------------------------------------------------------------------------------------------------
// Function:	WinMain
// Required:	HINSTANCE hThisInstance - the instance of this application
// 		HINSTANCE hPrevInstance - not used
// 		LPSTR lpCmdLine - command line arguments
// 		int nCmdShow - Show / Hide window indicator
// Returns:	int
// Purpose:	Creates the window class as well as the main and tooltip
// 		windows
//----  --------------------------------------------------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInstance,
                    HINSTANCE hPrevInstance UNUSED,
                    LPSTR lpCmdLine UNUSED,
                    int nCmdShow UNUSED)

{
  MSG messages;

  // If Windows Explorer is running as the shell, then don't start
  if (ELIsExplorerShell())
  {
    return 1;
  }

  // Check to see if Explorer is already running, if so exit
  HANDLE hMutex = CreateMutex(NULL, false, TEXT("Explorer"));
  if (GetLastError() == ERROR_ALREADY_EXISTS)
  {
    WCHAR app[MAX_PATH], args[MAX_LINE_LENGTH];
    ELParseCommand(GetCommandLine(), app, args);
    std::wstring commandLine = TEXT("%WINDIR%\\Explorer.exe ");
    commandLine = ELExpandVars(commandLine);
    commandLine += args;
    ELExecuteFileOrCommand(commandLine);
    CloseHandle(hMutex);
    return 2;
  }

  Applet applet(hInstance);

  if (!applet.Initialize())
  {
    return 3;
  }

  // Run the message loop. It will run until GetMessage() returns 0
  while (GetMessage (&messages, NULL, 0, 0))
  {
    // Translate virtual-key messages into character messages
    TranslateMessage(&messages);
    // Send message to WindowProcedure
    DispatchMessage(&messages);
  }

  // Clean-up the Mutex
  CloseHandle(hMutex);

  // The program return-value is 0 - The value that PostQuitMessage() gave
  return (int)messages.wParam;
}
Ejemplo n.º 15
0
Animation *AppletScript::loadAnimationFromPackage(const QString &name, QObject *parent)
{
    if (applet()) {
        const QString scopedName = applet()->pluginName() + ":" + name;
        if (!AnimationScriptEngine::isAnimationRegistered(scopedName)) {
            KConfig conf(applet()->package()->path() + "/metadata.desktop", KConfig::SimpleConfig);
            KConfigGroup animConf(&conf, "Animations");
            QString file;
            foreach (const QString &possibleFile, animConf.keyList()) {
                const QStringList anims = animConf.readEntry(possibleFile, QStringList());
                if (anims.contains(name)) {
                        file = possibleFile;
                        break;
                }
            }

            if (file.isEmpty()) {
                return 0;
            }

            const QString path = applet()->package()->filePath("animations", file);
            if (path.isEmpty()) {
                kDebug() << "file path was empty for" << file;
                return 0;
            }

            if (!AnimationScriptEngine::loadScript(path, applet()->pluginName() + ':') ||
                !AnimationScriptEngine::isAnimationRegistered(scopedName)) {
                kDebug() << "script engine loading failed for" << path;
                return 0;
            }
        }

        Animation *anim = Animator::create(scopedName, parent ? parent : this);
        return anim;
    }
Ejemplo n.º 16
0
QList<QAction*> AppletInterface::contextualActions() const
{
    QList<QAction*> actions;
    Plasma::Applet *a = applet();
    if (a->hasFailedToLaunch()) {
        return actions;
    }

    foreach (const QString &name, m_actions) {
        QAction *action = a->action(name);

        if (action) {
            actions << action;
        }
    }
Ejemplo n.º 17
0
QScriptValue AppletInterface::readConfig(const QString &entry) const
{
    Plasma::ConfigLoader *config = 0;
    QVariant result;
    
    if (m_currentConfig.isEmpty()) {
        config = applet()->configScheme();
    } else {
        config = m_configs.value(m_currentConfig, 0);
    }

    if (config) {
        result = config->property(entry);
    }
    return m_appletScriptEngine->variantToScriptValue(result);
}
Ejemplo n.º 18
0
void AppletInterface::writeConfig(const QString &entry, const QVariant &value)
{
    Plasma::ConfigLoader *config = 0;
    if (m_currentConfig.isEmpty()) {
        config = applet()->configScheme();
    } else {
        config = m_configs.value(m_currentConfig, 0);
    }

    if (config) {
        KConfigSkeletonItem *item = config->findItemByName(entry);
        if (item) {
            item->setProperty(value);
            config->writeConfig();
            m_appletScriptEngine->configNeedsSaving();
        }
    }
}
bool DeclarativeAppletScript::init()
{
    //make possible to import extensions from the package
    //FIXME: probably to be removed, would make possible to use native code from within the package :/
    //m_interface->qmlObject()->engine()->addImportPath(package()->path()+"/contents/imports");

    Plasma::Applet *a = applet();
    Plasma::Containment *pc = qobject_cast<Plasma::Containment *>(a);

    if (pc && pc->isContainment()) {
        m_interface = new ContainmentInterface(this, m_args);

        //fail? so it's a normal Applet
    } else {
        m_interface = new AppletInterface(this, m_args);
    }

    m_interface->setParent(this);

    return true;
}
Ejemplo n.º 20
0
static int run_applet_l(const char *arg, ...)
{
	int (*applet)(int, char **);
	va_list ap;
	int ret, optind_saved, argc;
	char **argv;
	const char *argv0_saved;

	optind_saved = optind;
	argv0_saved = argv0;

	applet = lookup_applet(arg);
	if (!applet)
		return -1;

	/* This doesn't NULL terminate argv, but you should be using argc */
	va_start(ap, arg);
	argc = 0;
	argv = NULL;
	while (arg) {
		argv = xrealloc(argv, sizeof(*argv) * ++argc);
		argv[argc - 1] = xstrdup(arg);
		arg = va_arg(ap, const char *);
	}
	va_end(ap);

	optind = 0;
	argv0 = argv[0];
	ret = applet(argc, argv);

	while (argc--)
		free(argv[argc]);
	free(argv);

	optind = optind_saved;
	argv0 = argv0_saved;

	return ret;
}
Ejemplo n.º 21
0
//-----
// Function:	WinMain
// Required:	HINSTANCE hThisInstance - the instance of this application
// 		HINSTANCE hPrevInstance - not used
// 		LPSTR lpCmdLine - command line arguments
// 		int nCmdShow - Show / Hide window indicator
// Returns:	int
// Purpose:	Creates the window class as well as the main and tooltip
// 		windows
//-----
int WINAPI WinMain (HINSTANCE hInstance,
                    HINSTANCE hPrevInstance UNUSED,
                    LPSTR lpCmdLine UNUSED,
                    int nCmdShow UNUSED)
{
  MSG messages;

  Applet applet(hInstance);

  if (!ELIsExplorerShell())
  {
    if (!applet.Initialize())
    {
      return 1;
    }
  }
  else
  {
    if (!applet.PortableInitialize())
    {
      return 2;
    }
  }

  // Run the message loop. It will run until GetMessage() returns 0
  while (GetMessage (&messages, NULL, 0, 0))
  {
    // Translate virtual-key messages into character messages
    TranslateMessage(&messages);
    // Send message to WindowProcedure
    DispatchMessage(&messages);
  }

  // The program return-value is 0 - The value that PostQuitMessage() gave
  return (int)messages.wParam;
}
Ejemplo n.º 22
0
void AppletInterface::setBusy(bool busy)
{
    applet()->setBusy(busy);
}
Ejemplo n.º 23
0
bool AppletInterface::isBusy()
{
    return applet()->isBusy();
}
Ejemplo n.º 24
0
void AppletScript::unregisterAsDragHandle(QGraphicsItem *item)
{
    if (applet()) {
        applet()->unregisterAsDragHandle(item);
    }
}
Ejemplo n.º 25
0
void AppletScript::setHasConfigurationInterface(bool hasInterface)
{
    if (applet()) {
        applet()->setHasConfigurationInterface(hasInterface);
    }
}
Ejemplo n.º 26
0
void AppletScript::showMessage(const QIcon &icon, const QString &message, const MessageButtons buttons)
{
    if (applet()) {
        applet()->showMessage(icon, message, buttons);
    }
}
Ejemplo n.º 27
0
void AppletScript::addStandardConfigurationPages(KConfigDialog *dialog)
{
    if (applet()) {
        applet()->d->addStandardConfigurationPages(dialog);
    }
}
Ejemplo n.º 28
0
void AppletScript::setConfigurationRequired(bool req, const QString &reason)
{
    if (applet()) {
        applet()->setConfigurationRequired(req, reason);
    }
}
Ejemplo n.º 29
0
void AppletScript::setFailedToLaunch(bool failed, const QString &reason)
{
    if (applet()) {
        applet()->setFailedToLaunch(failed, reason);
    }
}
Ejemplo n.º 30
0
void AppletScript::configNeedsSaving() const
{
    if (applet()) {
        emit applet()->configNeedsSaving();
    }
}