~ubuntu-branches/ubuntu/utopic/kde4libs/utopic

« back to all changes in this revision

Viewing changes to plasma/applet.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-16 13:53:22 UTC
  • mfrom: (1.14.11)
  • Revision ID: package-import@ubuntu.com-20111216135322-joct6gdco90t3koc
Tags: 4:4.7.90-0ubuntu1
* New upstream beta release
* Remove kubuntu_mobile patches, kactivities is split out now and they 
  will be out of date, keep 
  kubuntu-mobile-07-serviceAvailabilityChanged-bool-signal.diff
  for binary compatibility reasons

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
#include <kauthorized.h>
55
55
#include <kcolorscheme.h>
56
56
#include <kdialog.h>
 
57
#include <kdesktopfile.h>
57
58
#include <kicon.h>
58
59
#include <kiconloader.h>
59
60
#include <kkeysequencewidget.h>
65
66
#include <kwindowsystem.h>
66
67
#include <kpushbutton.h>
67
68
 
 
69
#ifndef PLASMA_NO_KUTILS
 
70
#include <kcmoduleinfo.h>
 
71
#include <kcmoduleproxy.h>
 
72
#else
 
73
#include <kcmodule.h>
 
74
#endif
 
75
 
68
76
#ifndef PLASMA_NO_SOLID
69
77
#include <solid/powermanagement.h>
70
78
#endif
1882
1890
    }
1883
1891
 
1884
1892
    d->publishUI.publishCheckbox = 0;
1885
 
    if (d->package && d->configLoader) {
 
1893
    if (d->package) {
1886
1894
        KConfigDialog *dialog = 0;
1887
1895
 
1888
 
        QString uiFile = d->package->filePath("mainconfigui");
1889
 
        if (!uiFile.isEmpty()) {
 
1896
        const QString uiFile = d->package->filePath("mainconfigui");
 
1897
        KDesktopFile df(d->package->path() + "/metadata.desktop");
 
1898
        const QStringList kcmPlugins = df.desktopGroup().readEntry("X-Plasma-ConfigPlugins", QStringList());
 
1899
        if (!uiFile.isEmpty() || !kcmPlugins.isEmpty()) {
 
1900
            KConfigSkeleton *configLoader = d->configLoader ? d->configLoader : new KConfigSkeleton(0);
 
1901
            dialog = new AppletConfigDialog(0, d->configDialogId(), configLoader);
 
1902
 
 
1903
            if (!d->configLoader) {
 
1904
                // delete the temporary when this dialog is done
 
1905
                configLoader->setParent(dialog);
 
1906
            }
 
1907
 
 
1908
            dialog->setWindowTitle(d->configWindowTitle());
 
1909
            dialog->setAttribute(Qt::WA_DeleteOnClose, true);
 
1910
            bool hasPages = false;
 
1911
 
1890
1912
            QFile f(uiFile);
1891
1913
            QUiLoader loader;
1892
1914
            QWidget *w = loader.load(&f);
1893
1915
            if (w) {
1894
 
                dialog = new AppletConfigDialog(0, d->configDialogId(), d->configLoader);
1895
 
                dialog->setWindowTitle(d->configWindowTitle());
1896
 
                dialog->setAttribute(Qt::WA_DeleteOnClose, true);
1897
1916
                dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name()));
 
1917
                hasPages = true;
 
1918
            }
 
1919
 
 
1920
            foreach (const QString &kcm, kcmPlugins) {
 
1921
#ifndef PLASMA_NO_KUTILS
 
1922
                KCModuleProxy *module = new KCModuleProxy(kcm);
 
1923
                if (module->realModule()) {
 
1924
                    dialog->addPage(module, module->moduleInfo().moduleName(), module->moduleInfo().icon());
 
1925
                    hasPages = true;
 
1926
                } else {
 
1927
                    delete module;
 
1928
                }
 
1929
#else
 
1930
                KService::Ptr service = KService::serviceByStorageId(kcm);
 
1931
                if (service) {
 
1932
                    QString error;
 
1933
                    KCModule *module = service->createInstance<KCModule>(dialog, QVariantList(), &error);
 
1934
                    if (module) {
 
1935
                        connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool)));
 
1936
                        dialog->addPage(module, service->name(), service->icon());
 
1937
                        hasPages = true;
 
1938
                    } else {
 
1939
#ifndef NDEBUG
 
1940
                        kDebug() << "failed to load kcm" << kcm << "for" << name();
 
1941
#endif
 
1942
                    }
 
1943
                }
 
1944
#endif
 
1945
            }
 
1946
 
 
1947
            if (hasPages) {
1898
1948
                d->addGlobalShortcutsPage(dialog);
1899
1949
                d->addPublishPage(dialog);
1900
1950
                dialog->show();
 
1951
            } else {
 
1952
                delete dialog;
 
1953
                dialog = 0;
1901
1954
            }
1902
1955
        }
1903
1956
 
1968
2021
{
1969
2022
    KConfigSkeleton *nullManager = new KConfigSkeleton(0);
1970
2023
    KConfigDialog *dialog = new AppletConfigDialog(0, configDialogId(), nullManager);
 
2024
    nullManager->setParent(dialog);
1971
2025
    dialog->setFaceType(KPageDialog::Auto);
1972
2026
    dialog->setWindowTitle(configWindowTitle());
1973
2027
    dialog->setAttribute(Qt::WA_DeleteOnClose, true);
1975
2029
    dialog->showButton(KDialog::Default, false);
1976
2030
    QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
1977
2031
    QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()));
1978
 
    QObject::connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
1979
2032
    return dialog;
1980
2033
}
1981
2034
 
1987
2040
 
1988
2041
void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog)
1989
2042
{
 
2043
#ifndef PLASMA_NO_GLOBAL_SHORTCUTS
1990
2044
    if (isContainment) {
1991
2045
        return;
1992
2046
    }
2006
2060
 
2007
2061
    QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()), Qt::UniqueConnection);
2008
2062
    QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()), Qt::UniqueConnection);
 
2063
#endif
2009
2064
}
2010
2065
 
2011
2066
void AppletPrivate::addPublishPage(KConfigDialog *dialog)
2465
2520
        }
2466
2521
    } else if (d->aspectRatioMode == Plasma::ConstrainedSquare) {
2467
2522
        //enforce a size not wider than tall
2468
 
        if (ff == Horizontal && (which == Qt::MaximumSize || size().height() <= KIconLoader::SizeLarge)) {
 
2523
        if (ff == Horizontal) {
2469
2524
            hint.setWidth(size().height());
2470
2525
        //enforce a size not taller than wide
2471
2526
        } else if (ff == Vertical && (which == Qt::MaximumSize || size().width() <= KIconLoader::SizeLarge)) {