Ejemplo n.º 1
0
bool
KWD::Decorator::enableDecorations (Time timestamp)
{
    QList <WId>::ConstIterator it;
    unsigned int nchildren;
    WId       *children;
    WId       root, parent;
    long int  select;

    mDmSnTimestamp = timestamp;

    if (!pluginManager ()->loadPlugin (""))
	return false;

    updateAllShadowOptions ();

    KWD::trapXError ();
    (void) QApplication::desktop (); // trigger creation of desktop widget
    KWD::popXError ();

    updateShadow ();

    /* FIXME: Implement proper decoration lists and remove this */
    mDecorNormal = new KWD::Window (mCompositeWindow,
                                    QX11Info::appRootWindow (),
                                    0, Window::Default);
    mDecorActive = new KWD::Window (mCompositeWindow,
				    QX11Info::appRootWindow (),
				    0, Window::DefaultActive);

    mActiveId = KWindowSystem::activeWindow ();

    connect (KWindowSystem::self (), SIGNAL (windowAdded (WId)),
	     SLOT (handleWindowAdded (WId)));
    connect (KWindowSystem::self (), SIGNAL (windowRemoved (WId)),
	     SLOT (handleWindowRemoved (WId)));
    connect (KWindowSystem::self (), SIGNAL (activeWindowChanged (WId)),
	     SLOT (handleActiveWindowChanged (WId)));
    connect (KWindowSystem::self (),
	     SIGNAL (windowChanged (WId, const unsigned long *)),
	     SLOT (handleWindowChanged (WId, const unsigned long *)));

    foreach (WId id, KWindowSystem::windows ())
	handleWindowAdded (id);

    /* Find the switcher and add it too
     * FIXME: Doing XQueryTree and then
     * XGetWindowProperty on every window
     * like this is really expensive, surely
     * there is a better way to do this */

    XQueryTree (QX11Info::display (), QX11Info::appRootWindow (),
                &root, &parent, &children, &nchildren);

    for (unsigned int i = 0; i < nchildren; i++)
    {
        if (KWD::readWindowProperty (children[i],
                                     Atoms::switchSelectWindow, &select))
        {
            handleWindowAdded(children[i]);
            break;
        }
    }

    connect (Plasma::Theme::defaultTheme (), SIGNAL (themeChanged ()),
	     SLOT (plasmaThemeChanged ()));

    // select for client messages
    XSelectInput (QX11Info::display (), QX11Info::appRootWindow (),
                  SubstructureNotifyMask |
                  StructureNotifyMask |
                  PropertyChangeMask);

    return true;
}
Ejemplo n.º 2
0
void EventApplet::init()
{
    KConfigGroup cg = config();

    disabledResources = cg.readEntry("DisabledResources", QStringList());

    QString normalEventFormat = cg.readEntry("NormalEventFormat", QString("%{startDate} %{startTime} %{summary}"));
    QString todoFormat = cg.readEntry("TodoFormat", QString("%{dueDate} %{summary}"));
    QString noDueDateFormat = cg.readEntry("NoDueDateFormat", QString("%{summary}"));
    int dtFormat = cg.readEntry("DateFormat", ShortDateFormat);
    QString dtString = cg.readEntry("CustomDateFormat", QString("dd.MM."));
    m_period = cg.readEntry("Period", 365);

    m_urgency = cg.readEntry("UrgencyTime", 15);
    m_birthdayUrgency = cg.readEntry("BirthdayUrgencyTime", 14);

    m_urgentBg = QColor(cg.readEntry("UrgentColor", QString("#FF0000")));
    m_urgentBg.setAlphaF(cg.readEntry("UrgentOpacity", 10)/100.0);
    m_colors.insert(urgentColorPos, m_urgentBg);
    m_passedFg = QColor(cg.readEntry("PassedColor", QString("#C3C3C3")));
    m_colors.insert(passedColorPos, m_passedFg);
    
    m_todoBg = QColor(cg.readEntry("TodoColor", QString("#FFD235")));
    m_todoBg.setAlphaF(cg.readEntry("TodoOpacity", 10)/100.0);
    m_colors.insert(todoColorPos, m_todoBg);

    m_showFinishedTodos = cg.readEntry("ShowFinishedTodos", FALSE);
    
    m_finishedTodoBg = QColor(cg.readEntry("FinishedTodoColor", QString("#6FACE0")));
    m_finishedTodoBg.setAlphaF(cg.readEntry("FinishedTodoOpacity", 10)/100.0);
    m_colors.insert(finishedTodoColorPos, m_finishedTodoBg);

    int opacity = cg.readEntry("KOOpacity", 10);
    setupCategoryColors(opacity);

    QString koConfigPath = KStandardDirs::locateLocal("config", "korganizerrc");
    m_categoryColorWatch = new KDirWatch(this);
    m_categoryColorWatch->addFile(koConfigPath);
    connect(m_categoryColorWatch, SIGNAL(created(const QString &)), this, SLOT(koConfigChanged()));
    connect(m_categoryColorWatch, SIGNAL(dirty(const QString &)), this, SLOT(koConfigChanged()));

    connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(plasmaThemeChanged()));
    
    QStringList keys, values;
    keys << i18n("Birthday") << i18n("Holiday");
    values << QString("%{startDate} %{yearsSince}. %{summary}") << QString("%{startDate} %{summary} to %{endDate}");
    keys = cg.readEntry("CategoryFormatsKeys", keys);
    values = cg.readEntry("CategoryFormatsValues", values);

    for (int i = 0; i < keys.size(); ++i) {
        m_categoryFormat.insert(keys.at(i), values.at(i));
    }

    QStringList headerList;
    headerList << i18n("Today") << i18n("Events of today") << QString::number(0);
    headerList << i18n("Tomorrow") << i18n("Events for tomorrow") << QString::number(1);
    headerList << i18n("Week") << i18n("Events of the next week") << QString::number(2);
    headerList << i18n("Next 4 weeks") << i18n("Events for the next 4 weeks") << QString::number(8);
    headerList << i18n("Later") << i18n("Events later than 4 weeks") << QString::number(29);
    m_headerItemsList = cg.readEntry("HeaderItems", headerList);

    m_delegate = new EventItemDelegate(this, normalEventFormat, todoFormat, noDueDateFormat, dtFormat, dtString);
    m_delegate->setCategoryFormats(m_categoryFormat);

    graphicsWidget();

    Plasma::ToolTipManager::self()->registerWidget(this);
    createToolTip();

    lastCheckTime = QDateTime::currentDateTime();
    m_timer = new QTimer();
    connect(m_timer, SIGNAL(timeout()), this, SLOT(timerExpired()));
    QTimer::singleShot(0, this, SLOT(setupModel()));
}