bool QDeclarativeSystemPalette::event(QEvent *event) { Q_D(QDeclarativeSystemPalette); if (event->type() == QEvent::ApplicationPaletteChange) { d->palette = QApplication::palette(); emit paletteChanged(); return true; } return QObject::event(event); }
void BrowserDock::polish() { m_categoryList.data()->setIcon( KIcon( "user-home" ) ); m_categoryList.data()->setMinimumSize( 100, 300 ); connect( m_breadcrumbWidget, SIGNAL(toHome()), this, SLOT(home()) ); // Keyboard shortcut for going back one level KAction *action = new KAction( KIcon( "go-up" ), i18n( "Go Up in Media Sources Pane" ), m_mainWidget ); Amarok::actionCollection()->addAction( "browser_previous", action ); connect( action, SIGNAL(triggered(bool)), m_categoryList.data(), SLOT(back()) ); action->setShortcut( KShortcut( Qt::Key_Backspace ) ); paletteChanged( palette() ); connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); }
void CQPaletteChooser:: setPaletteDef(const QString &paletteDef) { QString paletteDef1 = paletteDef.simplified(); if (paletteDef1 == paletteDef_) return; QPalette palette; if (! CQUtil::paletteFromString(palette, paletteDef1)) return; paletteDef_ = paletteDef1; palette_ = palette; edit_->setText(paletteDef_); emit paletteChanged(palette_); emit paletteChanged(paletteDef_); }
void SongkickApplet::init() { // Call the base implementation. Context::Applet::init(); QColor highlight = PaletteHandler::highlightColor().darker( 300 ); m_titleLabel = new QGraphicsSimpleTextItem( i18n("Concerts"), this ); QFont bigger = m_titleLabel->font(); bigger.setPointSize( bigger.pointSize() + 2 ); m_titleLabel->setFont( bigger ); m_titleLabel->setZValue( m_titleLabel->zValue() + 100 ); m_titleLabel->setDrawBackground( true ); QAction* reloadAction = new QAction( i18n("Reload Songkick"), this ); reloadAction->setIcon( KIcon( "view-refresh" ) ); reloadAction->setVisible( true ); reloadAction->setEnabled( true ); m_reloadIcon = addAction( reloadAction ); connect( m_reloadIcon, SIGNAL(clicked()), dataEngine( "amarok-songkick" ), SLOT(update()) ); m_songkickProxy = new QGraphicsProxyWidget( this ); m_songkick = new QTextBrowser; m_songkick->setAttribute( Qt::WA_NoSystemBackground ); m_songkick->setReadOnly( true ); m_songkick->setOpenExternalLinks( true ); m_songkick->setTextInteractionFlags( Qt::TextBrowserInteraction | Qt::TextSelectableByKeyboard ); m_songkickProxy->setWidget( m_songkick ); QPalette pal; QBrush brush( PaletteHandler::highlightColor().lighter( 170 ) ); brush.setStyle( Qt::SolidPattern ); pal.setBrush( QPalette::Active, QPalette::Base, brush ); pal.setBrush( QPalette::Inactive, QPalette::Base, brush ); pal.setBrush( QPalette::Disabled, QPalette::Base, brush ); pal.setBrush( QPalette::Window, brush ); m_songkick->setPalette( pal ); m_songkickProxy->setPalette( pal ); m_songkick->setStyleSheet( QString( "QTextBrowser { background-color: %1; border-width: 0px; border-radius: 0px; color: %2; }" ) .arg( PaletteHandler::highlightColor().lighter( 150 ).name() ) .arg( PaletteHandler::highlightColor().darker( 400 ).name() ) ); connect( dataEngine( "amarok-songkick" ), SIGNAL(sourceAdded(QString)), this, SLOT(connectSource(QString)) ); connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); constraintsEvent(); connectSource( "ontour" ); connectSource( "dates" ); }
Text::Text(Screen *screen) : QObject(screen) , m_screen(screen) , m_text_line(0) , m_start_index(0) , m_old_start_index(0) , m_end_index(0) , m_line(0) , m_old_line(0) , m_width(1) , m_style_dirty(true) , m_text_dirty(true) , m_visible(true) , m_visible_old(true) , m_forgroundColor(m_screen->defaultForgroundColor()) , m_backgroundColor(m_screen->defaultBackgroundColor()) { connect(m_screen->colorPalette(), SIGNAL(changed()), this, SLOT(paletteChanged())); connect(m_screen, SIGNAL(dispatchTextSegmentChanges()), this, SLOT(dispatchEvents())); }
void AbstractClient::updateColorScheme(QString path) { if (path.isEmpty()) { path = QStringLiteral("kdeglobals"); } if (!m_palette || m_colorScheme != path) { m_colorScheme = path; if (m_palette) { disconnect(m_palette.get(), &Decoration::DecorationPalette::changed, this, &AbstractClient::handlePaletteChange); } auto it = s_palettes.find(m_colorScheme); if (it == s_palettes.end() || it->expired()) { m_palette = std::make_shared<Decoration::DecorationPalette>(m_colorScheme); if (m_palette->isValid()) { s_palettes[m_colorScheme] = m_palette; } else { if (!s_defaultPalette) { s_defaultPalette = std::make_shared<Decoration::DecorationPalette>(QStringLiteral("kdeglobals")); s_palettes[QStringLiteral("kdeglobals")] = s_defaultPalette; } m_palette = s_defaultPalette; } if (m_colorScheme == QStringLiteral("kdeglobals")) { s_defaultPalette = m_palette; } } else { m_palette = it->lock(); } connect(m_palette.get(), &Decoration::DecorationPalette::changed, this, &AbstractClient::handlePaletteChange); emit paletteChanged(palette()); } }
TimeDialog::TimeDialog(QWidget* parent) : QWidget(parent, Qt::WindowFlags(Qt::Dialog | Qt::Window)) { setupUi(this); setWindowTitle(tr("MuseScore: Time Signatures")); QLayout* l = new QVBoxLayout(); l->setContentsMargins(0, 0, 0, 0); frame->setLayout(l); sp = MuseScore::newTimePalette(); sp->setReadOnly(false); sp->setSelectable(true); connect(zNominal, SIGNAL(valueChanged(int)), SLOT(zChanged(int))); connect(nNominal, SIGNAL(currentIndexChanged(int)), SLOT(nChanged(int))); connect(sp, SIGNAL(boxClicked(int)), SLOT(paletteChanged(int))); connect(sp, SIGNAL(changed()), SLOT(setDirty())); connect(addButton, SIGNAL(clicked()), SLOT(addClicked())); _timePalette = new PaletteScrollArea(sp); QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); _timePalette->setSizePolicy(policy); _timePalette->setRestrictHeight(false); l->addWidget(_timePalette); _dirty = false; if (useFactorySettings || !sp->read(dataPath + "/" + "timesigs")) { Fraction sig(4,4); groups->setSig(sig, Groups::endings(sig)); } for (int i = 0; i < sp->size(); ++i) // cells can be changed sp->setCellReadOnly(i, false); sp->setSelected(2); paletteChanged(2); }
void WinWindow::setGamma(float newGamma) { if (!useColormap && !hasGamma && !has3DFXGamma) return; // save gamma gammaVal = newGamma; // build gamma ramps or adjust colormap if (useColormap) { makeColormap(pfd); paletteChanged(); } else { WORD map[6][256]; for (int i = 0; i < 256; i++) { BYTE v = getIntensityValue((float)i / 255.0f); map[0][i] = map[1][i] = map[2][i] = map[3][i] = map[4][i] = map[5][i] = (WORD)v + ((WORD)v << 8); } setGammaRamps((const WORD*)map); } }
bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid()) return false; if (index.column() != 0 && role == BrushRole) { const QBrush br = qVariantValue<QBrush>(value); const QPalette::ColorRole r = static_cast<QPalette::ColorRole>(index.row()); const QPalette::ColorGroup g = columnToGroup(index.column()); m_palette.setBrush(g, r, br); QModelIndex idxBegin = PaletteModel::index(r, 0); QModelIndex idxEnd = PaletteModel::index(r, 3); if (m_compute) { m_palette.setBrush(QPalette::Inactive, r, br); switch (r) { case QPalette::WindowText: case QPalette::Text: case QPalette::ButtonText: case QPalette::Base: break; case QPalette::Dark: m_palette.setBrush(QPalette::Disabled, QPalette::WindowText, br); m_palette.setBrush(QPalette::Disabled, QPalette::Dark, br); m_palette.setBrush(QPalette::Disabled, QPalette::Text, br); m_palette.setBrush(QPalette::Disabled, QPalette::ButtonText, br); idxBegin = PaletteModel::index(0, 0); idxEnd = PaletteModel::index(m_roleNames.count() - 1, 3); break; case QPalette::Window: m_palette.setBrush(QPalette::Disabled, QPalette::Base, br); m_palette.setBrush(QPalette::Disabled, QPalette::Window, br); idxBegin = PaletteModel::index(QPalette::Base, 0); break; case QPalette::Highlight: //m_palette.setBrush(QPalette::Disabled, QPalette::Highlight, c.dark(120)); break; default: m_palette.setBrush(QPalette::Disabled, r, br); break; } } emit paletteChanged(m_palette); emit dataChanged(idxBegin, idxEnd); return true; } if (index.column() == 0 && role == Qt::EditRole) { uint mask = m_palette.resolve(); const bool isMask = qVariantValue<bool>(value); const int r = index.row(); if (isMask) mask |= (1 << r); else { m_palette.setBrush(QPalette::Active, static_cast<QPalette::ColorRole>(r), m_parentPalette.brush(QPalette::Active, static_cast<QPalette::ColorRole>(r))); m_palette.setBrush(QPalette::Inactive, static_cast<QPalette::ColorRole>(r), m_parentPalette.brush(QPalette::Inactive, static_cast<QPalette::ColorRole>(r))); m_palette.setBrush(QPalette::Disabled, static_cast<QPalette::ColorRole>(r), m_parentPalette.brush(QPalette::Disabled, static_cast<QPalette::ColorRole>(r))); mask &= ~(1 << index.row()); } m_palette.resolve(mask); emit paletteChanged(m_palette); const QModelIndex idxEnd = PaletteModel::index(r, 3); emit dataChanged(index, idxEnd); return true; } return false; }
TApp::TApp() : m_currentScene(0) , m_currentXsheet(0) , m_currentFrame(0) , m_currentColumn(0) , m_currentLevel(0) , m_currentTool(0) , m_currentObject(0) , m_currentSelection(0) , m_currentOnionSkinMask(0) , m_currentFx(0) , m_mainWindow(0) , m_autosaveTimer(0) , m_autosaveSuspended(false) , m_isStarting(false) , m_isPenCloseToTablet(false) { m_currentScene = new TSceneHandle(); m_currentXsheet = new TXsheetHandle(); m_currentFrame = new TFrameHandle(); m_currentColumn = new TColumnHandle(); m_currentLevel = new TXshLevelHandle(); m_currentTool = new ToolHandle(); m_currentObject = new TObjectHandle(); m_currentOnionSkinMask = new TOnionSkinMaskHandle(); m_currentFx = new TFxHandle(); m_currentSelection = TSelectionHandle::getCurrent(); m_paletteController = new PaletteController(); bool ret = true; ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetChanged()), this, SLOT(onXsheetChanged())); ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetSoundChanged()), this, SLOT(onXsheetSoundChanged())); ret = ret && QObject::connect(m_currentScene, SIGNAL(sceneSwitched()), this, SLOT(onSceneSwitched())); ret = ret && QObject::connect(m_currentScene, SIGNAL(sceneChanged()), this, SLOT(onSceneChanged())); ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetSwitched()), this, SLOT(onXsheetSwitched())); ret = ret && QObject::connect(m_currentFrame, SIGNAL(frameSwitched()), this, SLOT(onFrameSwitched())); ret = ret && QObject::connect(m_currentFrame, SIGNAL(frameSwitched()), this, SLOT(onImageChanged())); ret = ret && QObject::connect(m_currentFx, SIGNAL(fxSwitched()), this, SLOT(onFxSwitched())); ret = ret && QObject::connect(m_currentColumn, SIGNAL(columnIndexSwitched()), this, SLOT(onColumnIndexSwitched())); ret = ret && QObject::connect(m_currentColumn, SIGNAL(columnIndexSwitched()), this, SLOT(onImageChanged())); ret = ret && QObject::connect(m_currentLevel, SIGNAL(xshLevelSwitched(TXshLevel *)), this, SLOT(onImageChanged())); ret = ret && QObject::connect(m_currentLevel, SIGNAL(xshLevelSwitched(TXshLevel *)), this, SLOT(onXshLevelSwitched(TXshLevel *))); ret = ret && QObject::connect(m_currentLevel, SIGNAL(xshLevelChanged()), this, SLOT(onXshLevelChanged())); ret = ret && QObject::connect(m_currentObject, SIGNAL(objectSwitched()), this, SLOT(onObjectSwitched())); ret = ret && QObject::connect(m_currentObject, SIGNAL(splineChanged()), this, SLOT(onSplineChanged())); ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(), SIGNAL(paletteChanged()), this, SLOT(onPaletteChanged())); ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(), SIGNAL(colorStyleSwitched()), this, SLOT(onLevelColorStyleSwitched())); ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(), SIGNAL(colorStyleChangedOnMouseRelease()), this, SLOT(onLevelColorStyleChanged())); ret = ret && QObject::connect(m_paletteController->getCurrentCleanupPalette(), SIGNAL(paletteChanged()), m_currentScene, SIGNAL(sceneChanged())); TMeasureManager::instance()->addCameraMeasures(getCurrentCameraSize); m_autosaveTimer = new QTimer(this); ret = ret && connect(m_autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave())); Preferences *preferences = Preferences::instance(); if (preferences->isRasterOptimizedMemory()) { if (!TBigMemoryManager::instance()->init( (int)(/*15*1024*/ TSystem::getFreeMemorySize(true) * .8))) DVGui::warning(tr("Error allocating memory: not enough memory.")); } ret = ret && connect(preferences, SIGNAL(stopAutoSave()), SLOT(onStopAutoSave())); ret = ret && connect(preferences, SIGNAL(startAutoSave()), SLOT(onStartAutoSave())); ret = ret && connect(m_currentTool, SIGNAL(toolEditingFinished()), SLOT(onToolEditingFinished())); if (preferences->isAutosaveEnabled()) m_autosaveTimer->start(preferences->getAutosavePeriod() * 1000 * 60); UnitParameters::setCurrentDpiGetter(getCurrentDpi); assert(ret); }
void PanelKMenu::initialize() { // kDebug(1210) << "PanelKMenu::initialize()"; updateRecent(); if (initialized()) { return; } if (loadSidePixmap()) { // in case we've been through here before, let's disconnect disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); } else { sidePixmap = sideTilePixmap = QPixmap(); } // add services PanelServiceMenu::initialize(); /* FIXME: no more insertTitle! now what? if (KickerSettings::showMenuTitles()) { int id; id = insertTitle(i18n("All Applications"), -1, 0); setItemEnabled( id, false ); id = insertTitle(i18n("Actions"), -1 , -1); setItemEnabled( id, false ); } */ // create recent menu section createRecentMenuItems(); bool need_separator = false; // insert bookmarks if (KickerSettings::useBookmarks() && KAuthorized::authorizeKAction("bookmarks")) { // Need to create a new popup each time, it's deleted by subMenus.clear() KMenu * bookmarkParent = new KMenu(this); bookmarkParent->setObjectName("bookmarks" ); delete bookmarkMenu; // can't reuse old one, the popup has been deleted bookmarkMenu = new KBookmarkMenu( KBookmarkManager::userBookmarksManager(), 0, bookmarkParent, actionCollection ); insertItem(Plasma::menuIconSet("bookmark"), i18n("Bookmarks"), bookmarkParent); subMenus.append(bookmarkParent); need_separator = true; } // insert quickbrowser if (KickerSettings::useBrowser()) { PanelQuickBrowser *browserMnu = new PanelQuickBrowser(this); browserMnu->initialize(); insertItem(Plasma::menuIconSet("kdisknav"), i18n("Quick Browser"), Plasma::reduceMenu(browserMnu)); subMenus.append(browserMnu); need_separator = true; } // insert dynamic menus QStringList menu_ext = KickerSettings::menuExtensions(); if (!menu_ext.isEmpty()) { for (QStringList::ConstIterator it=menu_ext.begin(); it!=menu_ext.end(); ++it) { MenuInfo info(*it); if (!info.isValid()) continue; KPanelMenu *menu = info.load(); if (menu) { insertItem(Plasma::menuIconSet(info.icon()), info.name(), menu); dynamicSubMenus.append(menu); need_separator = true; } } } if (need_separator) addSeparator(); // run command if (KAuthorized::authorizeKAction("run_command")) { insertItem(Plasma::menuIconSet("system-run"), i18n("Run Command..."), this, SLOT( slotRunCommand())); addSeparator(); } if (KDisplayManager().isSwitchable() && KAuthorized::authorizeKAction("switch_user")) { sessionsMenu = new QMenu( this ); insertItem(Plasma::menuIconSet("switchuser"), i18n("Switch User"), sessionsMenu); connect( sessionsMenu, SIGNAL(aboutToShow()), SLOT(slotPopulateSessions()) ); connect( sessionsMenu, SIGNAL(activated(int)), SLOT(slotSessionActivated(int)) ); } /* If the user configured ksmserver to */ KConfig ksmserver("ksmserverrc", KConfig::CascadeConfig); if (ksmserver.group("General").readEntry( "loginMode" ) == "restoreSavedSession") { insertItem(Plasma::menuIconSet("document-save"), i18n("Save Session"), this, SLOT(slotSaveSession())); } if (KAuthorized::authorizeKAction("lock_screen")) { insertItem(Plasma::menuIconSet("system-lock-screen"), i18n("Lock Session"), this, SLOT(slotLock())); } if (KAuthorized::authorizeKAction("logout")) { insertItem(Plasma::menuIconSet("application-exit"), i18n("Log Out..."), this, SLOT(slotLogout())); } #if 0 // WABA: tear off handles don't work together with dynamically updated // menus. We can't update the menu while torn off, and we don't know // when it is torn off. if (KGlobalSettings::insertTearOffHandle()) insertTearOffHandle(); #endif setInitialized(true); }
MoodbarManager::MoodbarManager() : m_cache( new KImageCache( "Amarok-moodbars", 10 * 1024 ) ) , m_lastPaintMode( 0 ) { connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); }
void QDeclarativeSystemPalette::setColorGroup(QDeclarativeSystemPalette::ColorGroup colorGroup) { Q_D(QDeclarativeSystemPalette); d->group = (QPalette::ColorGroup)colorGroup; emit paletteChanged(); }
void PaletteEditor::stopsChangedAction() { static const int GradientBufferLastIdx = GradientBufferSize - 1; static const qreal dx = 1.0 / GradientBufferSize; QSize s( m_gradientLabel->maximumSize() ); QRect r( QPoint(0, 0), QSize(s.width(), (s.height() / 2.0 ) ) ); QImage palette_image(s, QImage::Format_RGB32); QPainter painter(&palette_image); GradientStops stops(m_gradientStops->getStops()); qStableSort(stops.begin(), stops.end(), GradientStop::lessThanGradientStopComparison); // now apply the ends and update the palette GradientStops ends( m_gradientEnds->getStops() ); QGradient::Spread spread((QGradient::Spread)m_gradientSpreadGroup->checkedId()); GradientStop n_stop(stops.first()); QRgb ccolor = n_stop.second.rgba(); for (int n = 0, fpos = n_stop.first * GradientBufferSize ; n < fpos ; n++) m_gradient[qMin(n, GradientBufferLastIdx)] = ccolor; int last_stop_idx = stops.size() - 1; for (int begin_idx = 0; begin_idx < last_stop_idx ; begin_idx++) { GradientStop a = stops.at(begin_idx); GradientStop b = stops.at(begin_idx + 1); QColor ac = a.second; QColor bc = b.second; qreal d = ( b.first - a.first ); qreal rdx, gdx, bdx, adx; if (b.colorspace == 0) { rdx = ( (bc.red() - ac.red() ) / d ) * dx; gdx = ( (bc.green() - ac.green() ) / d ) * dx; bdx = ( (bc.blue() - ac.blue() ) / d ) * dx; adx = ( (bc.alpha() - ac.alpha() ) / d ) * dx; } else { rdx = ( (bc.hue() - ac.hue() ) / d ) * dx; gdx = ( (bc.saturation() - ac.saturation() ) / d ) * dx; bdx = ( (bc.value() - ac.value() ) / d ) * dx; adx = ( (bc.alpha() - ac.alpha() ) / d ) * dx; if (b.colorspace == 1) { if (rdx == 0.0) rdx = 180.0 / d * dx; else if (rdx < 0) rdx *= -1; } else { if (rdx == 0.0) rdx = -180.0 / d * dx; else if (rdx > 0) rdx *= -1; } } int n = a.first * GradientBufferSize ; int nb = (int)(b.first * GradientBufferSize ); for (int i = 0 ; n < nb ; i++, n++) { if (b.colorspace == 0) { m_gradient[n] = qRgba( qBound(0, (int)( ac.red() + rdx * i + 0.5 ), 255), qBound(0, (int)( ac.green() + gdx * i + 0.5 ), 255), qBound(0, (int)( ac.blue() + bdx * i + 0.5 ), 255), qBound(0, (int)( ac.alpha() + adx * i + 0.5 ), 255)); } else { int h = (int)( ac.hue() + rdx * i + 0.5 ); if (h < 0) h += 360; m_gradient[n] = QColor::fromHsv(h % 360, qBound(0, (int)( ac.saturation() + gdx * i + 0.5 ), 255), qBound(0, (int)( ac.value() + bdx * i + 0.5 ), 255), qBound(0, (int)( ac.alpha() + adx * i + 0.5 ), 255)).rgba(); } } } n_stop = stops.last(); ccolor = n_stop.second.rgba(); for (int n = n_stop.first * GradientBufferSize ; n < GradientBufferSize ; n++) m_gradient[n] = ccolor; qreal start(ends.at(0).first); qreal end(ends.at(1).first); int begin_idx = start * 256 ; int end_idx = end * 256 ; int ibuf_size = end_idx - begin_idx; flam3_palette_entry* ibuf = new flam3_palette_entry[ibuf_size](); // a very acute filter qreal c2 = 0.01; qreal c3 = 1.0; qreal c4 = 0.01; qreal norm = c2 + c3 + c4; qreal k = 0.0; qreal skip( (GradientBufferSize / 256.0) / qMax(qreal(1.0/GradientBufferSize), end - start) ); for (int n = 0 ; n < ibuf_size ; n++, k += skip) { int j = k; QRgb a2( m_gradient[qBound(0, j + 0, GradientBufferLastIdx)] ); QRgb a3( m_gradient[qMin(j + 1, GradientBufferLastIdx)] ); QRgb a4( m_gradient[qMin(j + 2, GradientBufferLastIdx)] ); ibuf[n].color[0] = (qRed(a2)*c2 + qRed(a3)*c3 + qRed(a4)*c4 ) / (norm * 255.); ibuf[n].color[1] = (qGreen(a2)*c2 + qGreen(a3)*c3 + qGreen(a4)*c4 ) / (norm * 255.); ibuf[n].color[2] = (qBlue(a2)*c2 + qBlue(a3)*c3 + qBlue(a4)*c4 ) / (norm * 255.); ibuf[n].color[3] = (qAlpha(a2)*c2 + qAlpha(a3)*c3 + qAlpha(a4)*c4 ) / (norm * 255.); } // update the gradient editor label painter.fillRect(QRect(QPoint(0,0), s), checkers); if (ibuf_size == 256) { for (int n = 0, h = s.height() ; n < 256 ; n++) { painter.setPen(QColor::fromRgbF(ibuf[n].color[0], ibuf[n].color[1], ibuf[n].color[2], ibuf[n].color[3])); painter.drawLine(n, 0, n, h); } } else { for (int n = 0, h = s.height(), j = 0 ; n < 256 ; n++, j += 4) { QRgb a2( m_gradient[qBound(0, j + 0, GradientBufferLastIdx)] ); QRgb a3( m_gradient[qMin(j + 1, GradientBufferLastIdx)] ); QRgb a4( m_gradient[qMin(j + 2, GradientBufferLastIdx)] ); QRgb r((qRed(a2)*c2 + qRed(a3)*c3 + qRed(a4)*c4 ) / norm ); QRgb g((qGreen(a2)*c2 + qGreen(a3)*c3 + qGreen(a4)*c4 ) / norm ); QRgb b((qBlue(a2)*c2 + qBlue(a3)*c3 + qBlue(a4)*c4 ) / norm ); QRgb a((qAlpha(a2)*c2 + qAlpha(a3)*c3 + qAlpha(a4)*c4 ) / norm ); QColor c(r, g, b, a); painter.setPen(c); painter.drawLine(n, 0, n, h); } } m_gradientLabel->setPixmap(QPixmap::fromImage(palette_image)); // Rescale the gradient colors into the palette with a simple filter if (spread == QGradient::PadSpread) { QRgb fc(m_gradient[0]); flam3_palette_entry e = { 0., { qRed(fc)/255., qGreen(fc)/255., qBlue(fc)/255., qAlpha(fc)/255. }}; for (int n = 0 ; n < begin_idx ; n++) p[n] = e; for (int n = begin_idx, j = 0 ; n < end_idx ; n++, j++) p[n] = ibuf[j]; fc = m_gradient[GradientBufferLastIdx]; e = (flam3_palette_entry){ 1., { qRed(fc)/255., qGreen(fc)/ 255., qBlue(fc)/255., qAlpha(fc)/255. }}; for (int n = end_idx ; n < 256 ; n++) p[n] = e; } else if (spread == QGradient::RepeatSpread) { for (int n = begin_idx, j = 0 ; n < 256 ; n++, j++) p[n] = ibuf[j % ibuf_size]; for (int n = begin_idx - 1, j = ibuf_size * 4096 - 1 ; n >= 0 ; n--, j--) p[n] = ibuf[j % ibuf_size]; } else if (spread == QGradient::ReflectSpread) { for (int n = begin_idx, j = 0, h = 4096*ibuf_size -1 ; n < begin_idx + ibuf_size ; n++, j++, h--) { for (int k = n, q = n + ibuf_size ; k < 256 ; k += 2*ibuf_size, q += 2*ibuf_size ) { p[k] = ibuf[j % ibuf_size]; if (q < 256) p[q] = ibuf[h % ibuf_size]; } } for (int n = begin_idx - 1, j = ibuf_size * 4096 - 1, h = 0 ; n >= begin_idx - ibuf_size ; n--, j--, h++) { for (int k = n, q = n - ibuf_size ; k >= 0 ; k -= 2*ibuf_size, q -= 2*ibuf_size ) { p[k] = ibuf[h % ibuf_size]; if (q >= 0) p[q] = ibuf[j % ibuf_size]; } } } delete[] ibuf; setPaletteView(); emit paletteChanged(); }
KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KConfig *_config, QWidget *parent, const char *) : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone) { QString strWin1, strWin2, strWin3, strAllKey, strAll1, strAll2, strAll3; QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint()); QGrid *grid; QGroupBox *box; QLabel *label; QString strMouseButton1, strMouseButton3, strMouseWheel; QString txtButton1, txtButton3, txtButton4; QStringList items; bool leftHandedMouse = (KGlobalSettings::mouseSettings().handed == KGlobalSettings::KMouseSettings::LeftHanded); /** Titlebar doubleclick ************/ QHBoxLayout *hlayout = new QHBoxLayout(layout); label = new QLabel(i18n("&Titlebar double-click:"), this); hlayout->addWidget(label); QWhatsThis::add(label, i18n("Here you can customize mouse click behavior when double clicking on the" " titlebar of a window.")); QComboBox *combo = new QComboBox(this); combo->insertItem(i18n("Maximize")); combo->insertItem(i18n("Maximize (vertical only)")); combo->insertItem(i18n("Maximize (horizontal only)")); combo->insertItem(i18n("Minimize")); combo->insertItem(i18n("Shade")); combo->insertItem(i18n("Lower")); combo->insertItem(i18n("On All Desktops")); combo->insertItem(i18n("Nothing")); combo->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); connect(combo, SIGNAL(activated(int)), SLOT(changed())); hlayout->addWidget(combo); coTiDbl = combo; QWhatsThis::add(combo, i18n("Behavior on <em>double</em> click into the titlebar.")); label->setBuddy(combo); /** Mouse Wheel Events **************/ QHBoxLayout *hlayoutW = new QHBoxLayout(layout); strMouseWheel = i18n("Titlebar wheel event:"); label = new QLabel(strMouseWheel, this); hlayoutW->addWidget(label); txtButton4 = i18n("Handle mouse wheel events"); QWhatsThis::add(label, txtButton4); // Titlebar and frame mouse Wheel QComboBox *comboW = new QComboBox(this); comboW->insertItem(i18n("Raise/Lower")); comboW->insertItem(i18n("Shade/Unshade")); comboW->insertItem(i18n("Maximize/Restore")); comboW->insertItem(i18n("Keep Above/Below")); comboW->insertItem(i18n("Move to Previous/Next Desktop")); comboW->insertItem(i18n("Change Opacity")); comboW->insertItem(i18n("Nothing")); comboW->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); connect(comboW, SIGNAL(activated(int)), SLOT(changed())); hlayoutW->addWidget(comboW); coTiAct4 = comboW; QWhatsThis::add(comboW, txtButton4); label->setBuddy(comboW); /** Titlebar and frame **************/ box = new QVGroupBox(i18n("Titlebar && Frame"), this, "Titlebar and Frame"); box->layout()->setMargin(KDialog::marginHint()); box->layout()->setSpacing(KDialog::spacingHint()); layout->addWidget(box); QWhatsThis::add(box, i18n("Here you can customize mouse click behavior when clicking on the" " titlebar or the frame of a window.")); grid = new QGrid(4, Qt::Vertical, box); new QLabel(grid); // dummy strMouseButton1 = i18n("Left button:"); txtButton1 = i18n( "In this row you can customize left click behavior when clicking into" " the titlebar or the frame."); strMouseButton3 = i18n("Right button:"); txtButton3 = i18n( "In this row you can customize right click behavior when clicking into" " the titlebar or the frame."); if(leftHandedMouse) { qSwap(strMouseButton1, strMouseButton3); qSwap(txtButton1, txtButton3); } label = new QLabel(strMouseButton1, grid); QWhatsThis::add(label, txtButton1); label = new QLabel(i18n("Middle button:"), grid); QWhatsThis::add(label, i18n("In this row you can customize middle click behavior when clicking into" " the titlebar or the frame.")); label = new QLabel(strMouseButton3, grid); QWhatsThis::add(label, txtButton3); label = new QLabel(i18n("Active"), grid); label->setAlignment(AlignCenter); QWhatsThis::add(label, i18n("In this column you can customize mouse clicks into the titlebar" " or the frame of an active window.")); // Titlebar and frame, active, mouse button 1 combo = new QComboBox(grid); combo->insertItem(i18n("Raise")); combo->insertItem(i18n("Lower")); combo->insertItem(i18n("Operations Menu")); combo->insertItem(i18n("Toggle Raise & Lower")); combo->insertItem(i18n("Nothing")); connect(combo, SIGNAL(activated(int)), SLOT(changed())); coTiAct1 = combo; txtButton1 = i18n( "Behavior on <em>left</em> click into the titlebar or frame of an " "<em>active</em> window."); txtButton3 = i18n( "Behavior on <em>right</em> click into the titlebar or frame of an " "<em>active</em> window."); // Be nice to left handed users if(leftHandedMouse) qSwap(txtButton1, txtButton3); QWhatsThis::add(combo, txtButton1); // Titlebar and frame, active, mouse button 2 items << i18n("Raise") << i18n("Lower") << i18n("Operations Menu") << i18n("Toggle Raise & Lower") << i18n("Nothing") << i18n("Shade"); combo = new QComboBox(grid); combo->insertStringList(items); connect(combo, SIGNAL(activated(int)), SLOT(changed())); coTiAct2 = combo; QWhatsThis::add(combo, i18n("Behavior on <em>middle</em> click into the titlebar or frame of an <em>active</em> window.")); // Titlebar and frame, active, mouse button 3 combo = new QComboBox(grid); combo->insertStringList(items); connect(combo, SIGNAL(activated(int)), SLOT(changed())); coTiAct3 = combo; QWhatsThis::add(combo, txtButton3); txtButton1 = i18n( "Behavior on <em>left</em> click into the titlebar or frame of an " "<em>inactive</em> window."); txtButton3 = i18n( "Behavior on <em>right</em> click into the titlebar or frame of an " "<em>inactive</em> window."); // Be nice to left handed users if(leftHandedMouse) qSwap(txtButton1, txtButton3); label = new QLabel(i18n("Inactive"), grid); label->setAlignment(AlignCenter); QWhatsThis::add(label, i18n("In this column you can customize mouse clicks into the titlebar" " or the frame of an inactive window.")); items.clear(); items << i18n("Activate & Raise") << i18n("Activate & Lower") << i18n("Activate") << i18n("Shade") << i18n("Operations Menu") << i18n("Raise") << i18n("Lower") << i18n("Nothing"); combo = new QComboBox(grid); combo->insertStringList(items); connect(combo, SIGNAL(activated(int)), SLOT(changed())); coTiInAct1 = combo; QWhatsThis::add(combo, txtButton1); combo = new QComboBox(grid); combo->insertStringList(items); connect(combo, SIGNAL(activated(int)), SLOT(changed())); coTiInAct2 = combo; QWhatsThis::add(combo, i18n("Behavior on <em>middle</em> click into the titlebar or frame of an <em>inactive</em> window.")); combo = new QComboBox(grid); combo->insertStringList(items); connect(combo, SIGNAL(activated(int)), SLOT(changed())); coTiInAct3 = combo; QWhatsThis::add(combo, txtButton3); /** Maximize Button ******************/ box = new QHGroupBox(i18n("Maximize Button"), this, "Maximize Button"); box->layout()->setMargin(KDialog::marginHint()); box->layout()->setSpacing(KDialog::spacingHint()); layout->addWidget(box); QWhatsThis::add(box, i18n("Here you can customize behavior when clicking on the maximize button.")); QString strMouseButton[] = {i18n("Left button:"), i18n("Middle button:"), i18n("Right button:")}; QString txtButton[] = {i18n("Behavior on <em>left</em> click onto the maximize button."), i18n("Behavior on <em>middle</em> click onto the maximize button."), i18n("Behavior on <em>right</em> click onto the maximize button.")}; if(leftHandedMouse) // Be nice to lefties { qSwap(strMouseButton[0], strMouseButton[2]); qSwap(txtButton[0], txtButton[2]); } createMaxButtonPixmaps(); for(int b = 0; b < 3; ++b) { if(b != 0) new QWidget(box); // Spacer QLabel *label = new QLabel(strMouseButton[b], box); QWhatsThis::add(label, txtButton[b]); label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum)); coMax[b] = new ToolTipComboBox(box, tbl_Max); for(int t = 0; t < 3; ++t) coMax[b]->insertItem(maxButtonPixmaps[t]); connect(coMax[b], SIGNAL(activated(int)), SLOT(changed())); connect(coMax[b], SIGNAL(activated(int)), coMax[b], SLOT(changed())); QWhatsThis::add(coMax[b], txtButton[b]); coMax[b]->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum)); } connect(kapp, SIGNAL(kdisplayPaletteChanged()), SLOT(paletteChanged())); layout->addStretch(); load(); }
void PanelKMenu::initialize() { // kdDebug(1210) << "PanelKMenu::initialize()" << endl; updateRecent(); if (initialized()) { return; } if (loadSidePixmap()) { // in case we've been through here before, let's disconnect disconnect(kapp, SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); connect(kapp, SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); } else { sidePixmap = sideTilePixmap = QPixmap(); } // add services PanelServiceMenu::initialize(); if (KickerSettings::showMenuTitles()) { int id; id = insertItem(new PopupMenuTitle(i18n("All Applications"), font()), -1 /* id */, 0); setItemEnabled( id, false ); id = insertItem(new PopupMenuTitle(i18n("Actions"), font()), -1 /* id */, -1); setItemEnabled( id, false ); } // create recent menu section createRecentMenuItems(); bool need_separator = false; // insert bookmarks if (KickerSettings::useBookmarks() && kapp->authorizeKAction("bookmarks")) { // Need to create a new popup each time, it's deleted by subMenus.clear() KPopupMenu * bookmarkParent = new KPopupMenu( this, "bookmarks" ); if(!bookmarkOwner) bookmarkOwner = new KBookmarkOwner; delete bookmarkMenu; // can't reuse old one, the popup has been deleted bookmarkMenu = new KBookmarkMenu( KonqBookmarkManager::self(), bookmarkOwner, bookmarkParent, actionCollection, true, false ); insertItem(KickerLib::menuIconSet("bookmark"), i18n("Bookmarks"), bookmarkParent); subMenus.append(bookmarkParent); need_separator = true; } // insert quickbrowser if (KickerSettings::useBrowser()) { PanelQuickBrowser *browserMnu = new PanelQuickBrowser(this); browserMnu->initialize(); insertItem(KickerLib::menuIconSet("kdisknav"), i18n("Quick Browser"), KickerLib::reduceMenu(browserMnu)); subMenus.append(browserMnu); need_separator = true; } // insert dynamic menus QStringList menu_ext = KickerSettings::menuExtensions(); if (!menu_ext.isEmpty()) { for (QStringList::ConstIterator it=menu_ext.begin(); it!=menu_ext.end(); ++it) { MenuInfo info(*it); if (!info.isValid()) continue; KPanelMenu *menu = info.load(); if (menu) { insertItem(KickerLib::menuIconSet(info.icon()), info.name(), menu); dynamicSubMenus.append(menu); need_separator = true; } } } if (need_separator) insertSeparator(); // insert client menus, if any if (clients.count() > 0) { QIntDictIterator<KickerClientMenu> it(clients); while (it){ if (it.current()->text.at(0) != '.') insertItem( it.current()->icon, it.current()->text, it.current(), it.currentKey() ); ++it; } insertSeparator(); } // run command if (kapp->authorize("run_command")) { insertItem(KickerLib::menuIconSet("run"), i18n("Run Command..."), this, SLOT( slotRunCommand())); insertSeparator(); } if (DM().isSwitchable() && kapp->authorize("switch_user")) { sessionsMenu = new QPopupMenu( this ); insertItem(KickerLib::menuIconSet("switchuser"), i18n("Switch User"), sessionsMenu); connect( sessionsMenu, SIGNAL(aboutToShow()), SLOT(slotPopulateSessions()) ); connect( sessionsMenu, SIGNAL(activated(int)), SLOT(slotSessionActivated(int)) ); } /* If the user configured ksmserver to */ KConfig ksmserver("ksmserverrc", false, false); ksmserver.setGroup("General"); if (ksmserver.readEntry( "loginMode" ) == "restoreSavedSession") { insertItem(KickerLib::menuIconSet("filesave"), i18n("Save Session"), this, SLOT(slotSaveSession())); } if (kapp->authorize("lock_screen")) { insertItem(KickerLib::menuIconSet("lock"), i18n("Lock Session"), this, SLOT(slotLock())); } if (kapp->authorize("logout")) { insertItem(KickerLib::menuIconSet("exit"), i18n("Log Out..."), this, SLOT(slotLogout())); } #if 0 // WABA: tear off handles don't work together with dynamically updated // menus. We can't update the menu while torn off, and we don't know // when it is torn off. if (KGlobalSettings::insertTearOffHandle()) insertTearOffHandle(); #endif setInitialized(true); }
void AbstractClient::handlePaletteChange() { emit paletteChanged(palette()); }
void PaletteEditor::paletteRotatedAction(int /*idx*/) { setPaletteView(); emit paletteChanged(); }