mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kcontrol: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1023a46c82
commit
0f0e886656
6 changed files with 523 additions and 511 deletions
|
@ -56,7 +56,7 @@ KIconConfig::KIconConfig(const KComponentData &inst, QWidget *parent)
|
|||
top->addWidget(sep, 1, 1);
|
||||
// Preview at (2,0) - (2, 1)
|
||||
QGridLayout *g_lay = new QGridLayout();
|
||||
g_lay->setSpacing( 0);
|
||||
g_lay->setSpacing(0);
|
||||
top->addLayout(g_lay, 2, 0, 1, 2 );
|
||||
g_lay->addItem(new QSpacerItem(0, fontMetrics().lineSpacing()), 0, 0);
|
||||
|
||||
|
@ -70,14 +70,13 @@ KIconConfig::KIconConfig(const KComponentData &inst, QWidget *parent)
|
|||
connect(push, SIGNAL(clicked()), SLOT(slotEffectSetup2()));
|
||||
|
||||
m_pTab1 = new QWidget(this);
|
||||
m_pTab1->setObjectName( QLatin1String("General Tab" ));
|
||||
m_pTab1->setObjectName(QLatin1String("General Tab"));
|
||||
top->addWidget(m_pTab1, 0, 1);
|
||||
|
||||
QGridLayout *grid = new QGridLayout(m_pTab1);
|
||||
grid->setColumnStretch(1, 1);
|
||||
grid->setColumnStretch(2, 1);
|
||||
|
||||
|
||||
// Size
|
||||
QLabel *lbl = new QLabel(i18n("Size:"), m_pTab1);
|
||||
lbl->setFixedSize(lbl->sizeHint());
|
||||
|
@ -88,7 +87,7 @@ KIconConfig::KIconConfig(const KComponentData &inst, QWidget *parent)
|
|||
grid->addWidget(mpSizeBox, 0, 1, Qt::AlignLeft);
|
||||
|
||||
mpAnimatedCheck = new QCheckBox(i18n("Animate icons"), m_pTab1);
|
||||
connect(mpAnimatedCheck, SIGNAL(toggled(bool)), SLOT(slotAnimatedCheck(bool)));
|
||||
connect(mpAnimatedCheck, SIGNAL(toggled(bool)), this, SLOT(slotAnimatedCheck(bool)));
|
||||
grid->addWidget(mpAnimatedCheck, 2, 0, 1, 2, Qt::AlignLeft);
|
||||
grid->setRowStretch(3, 10);
|
||||
|
||||
|
@ -102,7 +101,7 @@ KIconConfig::KIconConfig(const KComponentData &inst, QWidget *parent)
|
|||
|
||||
KIconConfig::~KIconConfig()
|
||||
{
|
||||
delete mpEffect;
|
||||
delete mpEffect;
|
||||
}
|
||||
|
||||
QPushButton *KIconConfig::addPreviewIcon(int i, const QString &str, QWidget *parent, QGridLayout *lay)
|
||||
|
@ -124,8 +123,9 @@ void KIconConfig::init()
|
|||
mpConfig = KGlobal::config();
|
||||
mpEffect = new KIconEffect;
|
||||
mUsage = 0;
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
mbChanged[i] = false;
|
||||
for (int i = 0; i < KIconLoader::LastGroup; i++) {
|
||||
mbChanged[i] = false;
|
||||
}
|
||||
|
||||
// Fill list/checkboxen
|
||||
mpUsageList->addItem(i18n("Desktop"));
|
||||
|
@ -171,66 +171,60 @@ void KIconConfig::initDefaults()
|
|||
|
||||
KIconLoader::Group i;
|
||||
QStringList::ConstIterator it;
|
||||
for(it=mGroups.constBegin(), i=KIconLoader::FirstGroup; it!=mGroups.constEnd(); ++it, i++)
|
||||
{
|
||||
mbChanged[i] = true;
|
||||
mbAnimated[i] = false;
|
||||
if (mpLoader->theme())
|
||||
mSizes[i] = mpLoader->theme()->defaultSize(i);
|
||||
else
|
||||
mSizes[i] = defDefSizes[i];
|
||||
|
||||
mEffects[i][0] = mDefaultEffect[0];
|
||||
mEffects[i][1] = mDefaultEffect[1];
|
||||
mEffects[i][2] = mDefaultEffect[2];
|
||||
}
|
||||
// Animate desktop icons by default
|
||||
int group = mGroups.indexOf( "Desktop" );
|
||||
if ( group != -1 )
|
||||
mbAnimated[group] = true;
|
||||
|
||||
// This is the new default in KDE 2.2, in sync with the kiconeffect of kdelibs Nolden 2001/06/11
|
||||
int activeState = mStates.indexOf( "Active" );
|
||||
if ( activeState != -1 )
|
||||
{
|
||||
int group = mGroups.indexOf( "Desktop" );
|
||||
if ( group != -1 )
|
||||
{
|
||||
mEffects[ group ][ activeState ].type = KIconEffect::ToGamma;
|
||||
mEffects[ group ][ activeState ].value = 0.7f;
|
||||
for(it = mGroups.constBegin(), i= KIconLoader::FirstGroup; it != mGroups.constEnd(); ++it, i++) {
|
||||
mbChanged[i] = true;
|
||||
mbAnimated[i] = false;
|
||||
if (mpLoader->theme()) {
|
||||
mSizes[i] = mpLoader->theme()->defaultSize(i);
|
||||
} else {
|
||||
mSizes[i] = defDefSizes[i];
|
||||
}
|
||||
|
||||
group = mGroups.indexOf( "Panel" );
|
||||
if ( group != -1 )
|
||||
{
|
||||
mEffects[ group ][ activeState ].type = KIconEffect::ToGamma;
|
||||
mEffects[ group ][ activeState ].value = 0.7f;
|
||||
mEffects[i][0] = mDefaultEffect[0];
|
||||
mEffects[i][1] = mDefaultEffect[1];
|
||||
mEffects[i][2] = mDefaultEffect[2];
|
||||
}
|
||||
// Animate desktop icons by default
|
||||
int group = mGroups.indexOf("Desktop");
|
||||
if (group != -1) {
|
||||
mbAnimated[group] = true;
|
||||
}
|
||||
|
||||
// This is the new default in KDE 2.2, in sync with the kiconeffect of kdelibs Nolden 2001/06/11
|
||||
int activeState = mStates.indexOf("Active");
|
||||
if (activeState != -1) {
|
||||
int group = mGroups.indexOf("Desktop");
|
||||
if (group != -1) {
|
||||
mEffects[group][activeState].type = KIconEffect::ToGamma;
|
||||
mEffects[group][activeState].value = 0.7f;
|
||||
}
|
||||
|
||||
group = mGroups.indexOf("Panel");
|
||||
if (group != -1) {
|
||||
mEffects[group][activeState].type = KIconEffect::ToGamma;
|
||||
mEffects[group][activeState].value = 0.7f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KIconConfig::read()
|
||||
{
|
||||
if (mpLoader->theme())
|
||||
{
|
||||
for (KIconLoader::Group i=KIconLoader::FirstGroup; i<KIconLoader::LastGroup; i++)
|
||||
{
|
||||
if (mpLoader->theme()) {
|
||||
for (KIconLoader::Group i=KIconLoader::FirstGroup; i<KIconLoader::LastGroup; i++) {
|
||||
mAvSizes[i] = mpLoader->theme()->querySizes(i);
|
||||
|
||||
// ### Themes need to be fixed to include available sizes for Dialog icons
|
||||
if (i == KIconLoader::Dialog && mAvSizes[i].isEmpty())
|
||||
{
|
||||
if (i == KIconLoader::Dialog && mAvSizes[i].isEmpty()) {
|
||||
mAvSizes[i] = mAvSizes[KIconLoader::Desktop];
|
||||
}
|
||||
}
|
||||
|
||||
mTheme = mpLoader->theme()->current();
|
||||
mExample = mpLoader->theme()->example();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (KIconLoader::Group i=KIconLoader::FirstGroup; i<KIconLoader::LastGroup; i++)
|
||||
} else {
|
||||
for (KIconLoader::Group i=KIconLoader::FirstGroup; i<KIconLoader::LastGroup; i++) {
|
||||
mAvSizes[i] = QList<int>();
|
||||
}
|
||||
|
||||
mTheme.clear();
|
||||
mExample.clear();
|
||||
|
@ -240,36 +234,36 @@ void KIconConfig::read()
|
|||
|
||||
int i, j, effect;
|
||||
QStringList::ConstIterator it, it2;
|
||||
for (it=mGroups.constBegin(), i=0; it!=mGroups.constEnd(); ++it, i++)
|
||||
{
|
||||
for (it = mGroups.constBegin(), i = 0; it != mGroups.constEnd(); ++it, i++) {
|
||||
mbChanged[i] = false;
|
||||
|
||||
KConfigGroup iconGroup(mpConfig, *it + "Icons");
|
||||
mSizes[i] = iconGroup.readEntry("Size", mSizes[i]);
|
||||
mbAnimated[i] = iconGroup.readEntry("Animated", mbAnimated[i]);
|
||||
mSizes[i] = iconGroup.readEntry("Size", mSizes[i]);
|
||||
mbAnimated[i] = iconGroup.readEntry("Animated", mbAnimated[i]);
|
||||
|
||||
for (it2=mStates.constBegin(), j=0; it2!=mStates.constEnd(); ++it2, j++)
|
||||
{
|
||||
QString tmp = iconGroup.readEntry(*it2 + "Effect", QString());
|
||||
if (tmp == "togray")
|
||||
effect = KIconEffect::ToGray;
|
||||
else if (tmp == "colorize")
|
||||
effect = KIconEffect::Colorize;
|
||||
else if (tmp == "togamma")
|
||||
effect = KIconEffect::ToGamma;
|
||||
else if (tmp == "desaturate")
|
||||
effect = KIconEffect::DeSaturate;
|
||||
else if (tmp == "tomonochrome")
|
||||
effect = KIconEffect::ToMonochrome;
|
||||
else if (tmp == "none")
|
||||
effect = KIconEffect::NoEffect;
|
||||
else continue;
|
||||
mEffects[i][j].type = effect;
|
||||
mEffects[i][j].value = iconGroup.readEntry(*it2 + "Value", 0.0);
|
||||
mEffects[i][j].color = iconGroup.readEntry(*it2 + "Color",QColor());
|
||||
mEffects[i][j].color2 = iconGroup.readEntry(*it2 + "Color2", QColor());
|
||||
mEffects[i][j].transparent = iconGroup.readEntry(*it2 + "SemiTransparent", false);
|
||||
}
|
||||
for (it2 = mStates.constBegin(), j = 0; it2 != mStates.constEnd(); ++it2, j++) {
|
||||
QString tmp = iconGroup.readEntry(*it2 + "Effect", QString());
|
||||
if (tmp == "togray") {
|
||||
effect = KIconEffect::ToGray;
|
||||
} else if (tmp == "colorize") {
|
||||
effect = KIconEffect::Colorize;
|
||||
} else if (tmp == "togamma") {
|
||||
effect = KIconEffect::ToGamma;
|
||||
} else if (tmp == "desaturate") {
|
||||
effect = KIconEffect::DeSaturate;
|
||||
} else if (tmp == "tomonochrome") {
|
||||
effect = KIconEffect::ToMonochrome;
|
||||
} else if (tmp == "none") {
|
||||
effect = KIconEffect::NoEffect;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
mEffects[i][j].type = effect;
|
||||
mEffects[i][j].value = iconGroup.readEntry(*it2 + "Value", 0.0);
|
||||
mEffects[i][j].color = iconGroup.readEntry(*it2 + "Color", QColor());
|
||||
mEffects[i][j].color2 = iconGroup.readEntry(*it2 + "Color2", QColor());
|
||||
mEffects[i][j].transparent = iconGroup.readEntry(*it2 + "SemiTransparent", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,20 +275,17 @@ void KIconConfig::apply()
|
|||
QList<int>::Iterator it;
|
||||
mpSizeBox->clear();
|
||||
if (mUsage < KIconLoader::LastGroup) {
|
||||
for (it=mAvSizes[mUsage].begin(), i=0; it!=mAvSizes[mUsage].end(); ++it, i++)
|
||||
{
|
||||
for (it = mAvSizes[mUsage].begin(), i=0; it!=mAvSizes[mUsage].end(); ++it, i++) {
|
||||
mpSizeBox->addItem(QString().setNum(*it));
|
||||
dw = abs(mSizes[mUsage] - *it);
|
||||
if (dw < delta)
|
||||
{
|
||||
if (dw < delta) {
|
||||
delta = dw;
|
||||
index = i;
|
||||
size = *it;
|
||||
}
|
||||
|
||||
}
|
||||
if (index != -1)
|
||||
{
|
||||
if (index != -1) {
|
||||
mpSizeBox->setCurrentIndex(index);
|
||||
mSizes[mUsage] = size; // best or exact match
|
||||
}
|
||||
|
@ -314,8 +305,7 @@ void KIconConfig::preview(int i)
|
|||
|
||||
Effect &effect = mEffects[viewedGroup][i];
|
||||
|
||||
img = mpEffect->apply(img, effect.type,
|
||||
effect.value, effect.color, effect.color2, effect.transparent);
|
||||
img = mpEffect->apply(img, effect.type, effect.value, effect.color, effect.color2, effect.transparent);
|
||||
pm = QPixmap::fromImage(img);
|
||||
mpPreview[i]->setPixmap(pm);
|
||||
}
|
||||
|
@ -332,65 +322,66 @@ void KIconConfig::load()
|
|||
read();
|
||||
apply();
|
||||
emit changed(false);
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
mbChanged[i] = false;
|
||||
for (int i = 0; i < KIconLoader::LastGroup; i++) {
|
||||
mbChanged[i] = false;
|
||||
}
|
||||
preview();
|
||||
}
|
||||
|
||||
|
||||
void KIconConfig::save()
|
||||
{
|
||||
int i, j;
|
||||
QStringList::ConstIterator it, it2;
|
||||
for (it=mGroups.constBegin(), i=0; it!=mGroups.constEnd(); ++it, i++)
|
||||
{
|
||||
KConfigGroup cg(mpConfig, *it + "Icons");
|
||||
cg.writeEntry("Size", mSizes[i], KConfig::Normal|KConfig::Global);
|
||||
cg.writeEntry("Animated", mbAnimated[i], KConfig::Normal|KConfig::Global);
|
||||
for (it2=mStates.constBegin(), j=0; it2!=mStates.constEnd(); ++it2, j++)
|
||||
{
|
||||
QString tmp;
|
||||
switch (mEffects[i][j].type)
|
||||
{
|
||||
case KIconEffect::ToGray:
|
||||
tmp = "togray";
|
||||
break;
|
||||
case KIconEffect::ToGamma:
|
||||
tmp = "togamma";
|
||||
break;
|
||||
case KIconEffect::Colorize:
|
||||
tmp = "colorize";
|
||||
break;
|
||||
case KIconEffect::DeSaturate:
|
||||
tmp = "desaturate";
|
||||
break;
|
||||
case KIconEffect::ToMonochrome:
|
||||
tmp = "tomonochrome";
|
||||
break;
|
||||
default:
|
||||
tmp = "none";
|
||||
break;
|
||||
}
|
||||
cg.writeEntry(*it2 + "Effect", tmp, KConfig::Normal|KConfig::Global);
|
||||
cg.writeEntry(*it2 + "Value", mEffects[i][j].value, KConfig::Normal|KConfig::Global);
|
||||
for (it = mGroups.constBegin(), i = 0; it!=mGroups.constEnd(); ++it, i++) {
|
||||
KConfigGroup cg(mpConfig, *it + "Icons");
|
||||
cg.writeEntry("Size", mSizes[i], KConfig::Normal|KConfig::Global);
|
||||
cg.writeEntry("Animated", mbAnimated[i], KConfig::Normal|KConfig::Global);
|
||||
for (it2 = mStates.constBegin(), j = 0; it2 != mStates.constEnd(); ++it2, j++) {
|
||||
QString tmp;
|
||||
switch (mEffects[i][j].type) {
|
||||
case KIconEffect::ToGray: {
|
||||
tmp = "togray";
|
||||
break;
|
||||
}
|
||||
case KIconEffect::ToGamma: {
|
||||
tmp = "togamma";
|
||||
break;
|
||||
}
|
||||
case KIconEffect::Colorize: {
|
||||
tmp = "colorize";
|
||||
break;
|
||||
}
|
||||
case KIconEffect::DeSaturate: {
|
||||
tmp = "desaturate";
|
||||
break;
|
||||
}
|
||||
case KIconEffect::ToMonochrome: {
|
||||
tmp = "tomonochrome";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
tmp = "none";
|
||||
break;
|
||||
}
|
||||
}
|
||||
cg.writeEntry(*it2 + "Effect", tmp, KConfig::Normal|KConfig::Global);
|
||||
cg.writeEntry(*it2 + "Value", mEffects[i][j].value, KConfig::Normal|KConfig::Global);
|
||||
cg.writeEntry(*it2 + "Color", mEffects[i][j].color, KConfig::Normal|KConfig::Global);
|
||||
cg.writeEntry(*it2 + "Color2", mEffects[i][j].color2, KConfig::Normal|KConfig::Global);
|
||||
cg.writeEntry(*it2 + "SemiTransparent", mEffects[i][j].transparent, KConfig::Normal|KConfig::Global);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mpConfig->sync();
|
||||
|
||||
emit changed(false);
|
||||
|
||||
// Emit KIPC change message.
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
{
|
||||
if (mbChanged[i])
|
||||
{
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::IconChanged, i);
|
||||
mbChanged[i] = false;
|
||||
}
|
||||
// Emit IPC change message.
|
||||
for (int i = 0; i<KIconLoader::LastGroup; i++) {
|
||||
if (mbChanged[i]) {
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::IconChanged, i);
|
||||
mbChanged[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,19 +395,17 @@ void KIconConfig::defaults()
|
|||
|
||||
void KIconConfig::slotUsage(int index)
|
||||
{
|
||||
if (index == -1)
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
mUsage = index;
|
||||
if ( mUsage == KIconLoader::LastGroup )
|
||||
{
|
||||
if (mUsage == KIconLoader::LastGroup) {
|
||||
mpSizeBox->setEnabled(false);
|
||||
mpAnimatedCheck->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mpSizeBox->setEnabled(true);
|
||||
mpAnimatedCheck->setEnabled( mUsage == KIconLoader::Desktop );
|
||||
mpAnimatedCheck->setEnabled(mUsage == KIconLoader::Desktop);
|
||||
}
|
||||
|
||||
apply();
|
||||
|
@ -431,32 +420,31 @@ void KIconConfig::EffectSetup(int state)
|
|||
QImage img = pm.toImage();
|
||||
|
||||
QString caption;
|
||||
switch (state)
|
||||
{
|
||||
case 0 : caption = i18n("Setup Default Icon Effect"); break;
|
||||
case 1 : caption = i18n("Setup Active Icon Effect"); break;
|
||||
case 2 : caption = i18n("Setup Disabled Icon Effect"); break;
|
||||
switch (state) {
|
||||
case 0 : caption = i18n("Setup Default Icon Effect"); break;
|
||||
case 1 : caption = i18n("Setup Active Icon Effect"); break;
|
||||
case 2 : caption = i18n("Setup Disabled Icon Effect"); break;
|
||||
}
|
||||
|
||||
KIconEffectSetupDialog dlg(mEffects[viewedGroup][state], mDefaultEffect[state], caption, img, this);
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
{
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
if (mUsage == KIconLoader::LastGroup) {
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
for (int i = 0; i < KIconLoader::LastGroup; i++) {
|
||||
mEffects[i][state] = dlg.effect();
|
||||
}
|
||||
} else {
|
||||
mEffects[mUsage][state] = dlg.effect();
|
||||
}
|
||||
|
||||
// AK - can this call be moved therefore removing
|
||||
// code duplication?
|
||||
|
||||
emit changed(true);
|
||||
|
||||
if (mUsage == KIconLoader::LastGroup) {
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++) {
|
||||
mbChanged[i] = true;
|
||||
}
|
||||
} else {
|
||||
mbChanged[mUsage] = true;
|
||||
}
|
||||
|
@ -476,8 +464,7 @@ void KIconConfig::slotSize(int index)
|
|||
void KIconConfig::slotAnimatedCheck(bool check)
|
||||
{
|
||||
Q_ASSERT(mUsage < KIconLoader::LastGroup);
|
||||
if (mbAnimated[mUsage] != check)
|
||||
{
|
||||
if (mbAnimated[mUsage] != check) {
|
||||
mbAnimated[mUsage] = check;
|
||||
emit changed(true);
|
||||
mbChanged[mUsage] = true;
|
||||
|
@ -485,18 +472,18 @@ void KIconConfig::slotAnimatedCheck(bool check)
|
|||
}
|
||||
|
||||
KIconEffectSetupDialog::KIconEffectSetupDialog(const Effect &effect,
|
||||
const Effect &defaultEffect,
|
||||
const QString &caption, const QImage &image,
|
||||
QWidget *parent, char *name)
|
||||
: KDialog( parent ),
|
||||
mEffect(effect),
|
||||
mDefaultEffect(defaultEffect),
|
||||
mExample(image)
|
||||
const Effect &defaultEffect,
|
||||
const QString &caption, const QImage &image,
|
||||
QWidget *parent, char *name)
|
||||
: KDialog(parent),
|
||||
mEffect(effect),
|
||||
mDefaultEffect(defaultEffect),
|
||||
mExample(image)
|
||||
{
|
||||
setObjectName( name );
|
||||
setModal( true );
|
||||
setCaption( caption );
|
||||
setButtons( Default|Ok|Cancel );
|
||||
setObjectName(name);
|
||||
setModal(true);
|
||||
setCaption(caption);
|
||||
setButtons(KDialog::Default | KDialog::Ok | KDialog::Cancel);
|
||||
|
||||
mpEffect = new KIconEffect;
|
||||
|
||||
|
@ -509,9 +496,9 @@ KIconEffectSetupDialog::KIconEffectSetupDialog(const Effect &effect,
|
|||
|
||||
QGridLayout *top = new QGridLayout(page);
|
||||
top->setMargin(0);
|
||||
top->setColumnStretch(0,1);
|
||||
top->setColumnStretch(1,2);
|
||||
top->setRowStretch(1,1);
|
||||
top->setColumnStretch(0, 1);
|
||||
top->setColumnStretch(1, 2);
|
||||
top->setRowStretch(1, 1);
|
||||
|
||||
lbl = new QLabel(i18n("&Effect:"), page);
|
||||
top->addWidget(lbl, 0, 0, Qt::AlignLeft);
|
||||
|
@ -551,19 +538,17 @@ KIconEffectSetupDialog::KIconEffectSetupDialog(const Effect &effect,
|
|||
mpEffectSlider->setPageStep(5);
|
||||
connect(mpEffectSlider, SIGNAL(valueChanged(int)), SLOT(slotEffectValue(int)));
|
||||
form->addRow(i18n("&Amount:"), mpEffectSlider);
|
||||
mpEffectLabel = static_cast<QLabel *>(form->labelForField(mpEffectSlider));
|
||||
mpEffectLabel = static_cast<QLabel*>(form->labelForField(mpEffectSlider));
|
||||
|
||||
mpEColButton = new KColorButton(mpEffectGroup);
|
||||
connect(mpEColButton, SIGNAL(changed(const QColor &)),
|
||||
SLOT(slotEffectColor(const QColor &)));
|
||||
connect(mpEColButton, SIGNAL(changed(QColor)), this, SLOT(slotEffectColor(QColor)));
|
||||
form->addRow(i18n("Co&lor:"), mpEColButton);
|
||||
mpEffectColor = static_cast<QLabel *>(form->labelForField(mpEColButton));
|
||||
mpEffectColor = static_cast<QLabel*>(form->labelForField(mpEColButton));
|
||||
|
||||
mpECol2Button = new KColorButton(mpEffectGroup);
|
||||
connect(mpECol2Button, SIGNAL(changed(const QColor &)),
|
||||
SLOT(slotEffectColor2(const QColor &)));
|
||||
connect(mpECol2Button, SIGNAL(changed(QColor)), this, SLOT(slotEffectColor2(QColor)));
|
||||
form->addRow(i18n("&Second color:"), mpECol2Button);
|
||||
mpEffectColor2 = static_cast<QLabel *>(form->labelForField(mpECol2Button));
|
||||
mpEffectColor2 = static_cast<QLabel*>(form->labelForField(mpECol2Button));
|
||||
|
||||
init();
|
||||
preview();
|
||||
|
@ -571,7 +556,7 @@ KIconEffectSetupDialog::KIconEffectSetupDialog(const Effect &effect,
|
|||
|
||||
KIconEffectSetupDialog::~KIconEffectSetupDialog()
|
||||
{
|
||||
delete mpEffect;
|
||||
delete mpEffect;
|
||||
}
|
||||
|
||||
void KIconEffectSetupDialog::init()
|
||||
|
@ -606,8 +591,9 @@ void KIconEffectSetupDialog::slotEffectColor2(const QColor &col)
|
|||
|
||||
void KIconEffectSetupDialog::slotEffectType(int type)
|
||||
{
|
||||
if (type == -1)
|
||||
if (type == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
mEffect.type = type;
|
||||
mpEffectGroup->setEnabled(mEffect.type != KIconEffect::NoEffect);
|
||||
|
@ -636,8 +622,7 @@ void KIconEffectSetupDialog::preview()
|
|||
{
|
||||
QPixmap pm;
|
||||
QImage img = mExample.copy();
|
||||
img = mpEffect->apply(img, mEffect.type,
|
||||
mEffect.value, mEffect.color, mEffect.color2, mEffect.transparent);
|
||||
img = mpEffect->apply(img, mEffect.type, mEffect.value, mEffect.color, mEffect.color2, mEffect.transparent);
|
||||
pm = QPixmap::fromImage(img);
|
||||
mpPreview->setPixmap(pm);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ class KIconEffectSetupDialog: public KDialog
|
|||
public:
|
||||
KIconEffectSetupDialog(const Effect &, const Effect &,
|
||||
const QString &, const QImage &,
|
||||
QWidget *parent=0L, char *name=0L);
|
||||
QWidget *parent = nullptr, char *name = nullptr);
|
||||
~KIconEffectSetupDialog();
|
||||
Effect effect() { return mEffect; }
|
||||
|
||||
|
|
|
@ -53,73 +53,74 @@
|
|||
static const int ThemeNameRole = Qt::UserRole + 1;
|
||||
|
||||
IconThemesConfig::IconThemesConfig(const KComponentData &inst, QWidget *parent)
|
||||
: KCModule(inst, parent)
|
||||
: KCModule(inst, parent)
|
||||
{
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
|
||||
QFrame *m_preview=new QFrame(this);
|
||||
m_preview->setMinimumHeight(80);
|
||||
QFrame *m_preview=new QFrame(this);
|
||||
m_preview->setMinimumHeight(80);
|
||||
|
||||
QHBoxLayout *lh2=new QHBoxLayout( m_preview );
|
||||
lh2->setSpacing(0);
|
||||
m_previewExec=new QLabel(m_preview);
|
||||
m_previewExec->setPixmap(DesktopIcon("system-run"));
|
||||
m_previewFolder=new QLabel(m_preview);
|
||||
m_previewFolder->setPixmap(DesktopIcon("folder"));
|
||||
m_previewDocument=new QLabel(m_preview);
|
||||
m_previewDocument->setPixmap(DesktopIcon("document"));
|
||||
QHBoxLayout *lh2=new QHBoxLayout( m_preview );
|
||||
lh2->setSpacing(0);
|
||||
m_previewExec=new QLabel(m_preview);
|
||||
m_previewExec->setPixmap(DesktopIcon("system-run"));
|
||||
m_previewFolder=new QLabel(m_preview);
|
||||
m_previewFolder->setPixmap(DesktopIcon("folder"));
|
||||
m_previewDocument=new QLabel(m_preview);
|
||||
m_previewDocument->setPixmap(DesktopIcon("document"));
|
||||
|
||||
lh2->addStretch(10);
|
||||
lh2->addWidget(m_previewExec);
|
||||
lh2->addStretch(1);
|
||||
lh2->addWidget(m_previewFolder);
|
||||
lh2->addStretch(1);
|
||||
lh2->addWidget(m_previewDocument);
|
||||
lh2->addStretch(10);
|
||||
lh2->addStretch(10);
|
||||
lh2->addWidget(m_previewExec);
|
||||
lh2->addStretch(1);
|
||||
lh2->addWidget(m_previewFolder);
|
||||
lh2->addStretch(1);
|
||||
lh2->addWidget(m_previewDocument);
|
||||
lh2->addStretch(10);
|
||||
|
||||
m_iconThemes=new QTreeWidget(this/*"IconThemeList"*/);
|
||||
QStringList columns;
|
||||
columns.append(i18n("Name"));
|
||||
columns.append(i18n("Description"));
|
||||
m_iconThemes->setHeaderLabels(columns);
|
||||
m_iconThemes->setAllColumnsShowFocus( true );
|
||||
m_iconThemes->setRootIsDecorated(false);
|
||||
m_iconThemes->setSortingEnabled(true);
|
||||
m_iconThemes->sortByColumn(0, Qt::AscendingOrder);
|
||||
connect(
|
||||
m_iconThemes, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
this, SLOT(themeSelected(QTreeWidgetItem *))
|
||||
);
|
||||
|
||||
m_iconThemes=new QTreeWidget(this/*"IconThemeList"*/);
|
||||
QStringList columns;
|
||||
columns.append(i18n("Name"));
|
||||
columns.append(i18n("Description"));
|
||||
m_iconThemes->setHeaderLabels(columns);
|
||||
m_iconThemes->setAllColumnsShowFocus( true );
|
||||
m_iconThemes->setRootIsDecorated(false);
|
||||
m_iconThemes->setSortingEnabled(true);
|
||||
m_iconThemes->sortByColumn(0, Qt::AscendingOrder);
|
||||
connect(m_iconThemes,SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
SLOT(themeSelected(QTreeWidgetItem *)));
|
||||
KPushButton *installButton = new KPushButton(KIcon("document-import"), i18n("Install Theme File..."), this);
|
||||
installButton->setObjectName( QLatin1String("InstallNewTheme" ));
|
||||
installButton->setToolTip(i18n("Install a theme archive file you already have locally"));
|
||||
installButton->setWhatsThis(i18n("If you already have a theme archive locally, this button will unpack it and make it available for KDE applications"));
|
||||
connect(installButton, SIGNAL(clicked()), this, SLOT(installNewTheme()));
|
||||
|
||||
KPushButton *installButton=new KPushButton( KIcon("document-import"), i18n("Install Theme File..."), this);
|
||||
installButton->setObjectName( QLatin1String("InstallNewTheme" ));
|
||||
installButton->setToolTip(i18n("Install a theme archive file you already have locally"));
|
||||
installButton->setWhatsThis(i18n("If you already have a theme archive locally, this button will unpack it and make it available for KDE applications"));
|
||||
connect(installButton,SIGNAL(clicked()),SLOT(installNewTheme()));
|
||||
m_removeButton = new KPushButton(KIcon("edit-delete"), i18n("Remove Theme"), this);
|
||||
m_removeButton->setObjectName(QLatin1String("RemoveTheme"));
|
||||
m_removeButton->setToolTip(i18n("Remove the selected theme from your disk"));
|
||||
m_removeButton->setWhatsThis(i18n("This will remove the selected theme from your disk."));
|
||||
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(removeSelectedTheme()));
|
||||
|
||||
m_removeButton=new KPushButton( KIcon("edit-delete"), i18n("Remove Theme"), this);
|
||||
m_removeButton->setObjectName( QLatin1String("RemoveTheme" ));
|
||||
m_removeButton->setToolTip(i18n("Remove the selected theme from your disk"));
|
||||
m_removeButton->setWhatsThis(i18n("This will remove the selected theme from your disk."));
|
||||
connect(m_removeButton,SIGNAL(clicked()),SLOT(removeSelectedTheme()));
|
||||
topLayout->addWidget(new QLabel(i18n("Select the icon theme you want to use:"), this));
|
||||
topLayout->addWidget(m_preview);
|
||||
topLayout->addWidget(m_iconThemes);
|
||||
QHBoxLayout *lg = new QHBoxLayout();
|
||||
lg->addStretch(0);
|
||||
lg->addWidget(installButton);
|
||||
lg->addWidget(m_removeButton);
|
||||
topLayout->addLayout(lg);
|
||||
|
||||
topLayout->addWidget(
|
||||
new QLabel(i18n("Select the icon theme you want to use:"), this));
|
||||
topLayout->addWidget(m_preview);
|
||||
topLayout->addWidget(m_iconThemes);
|
||||
QHBoxLayout *lg = new QHBoxLayout();
|
||||
lg->addStretch(0);
|
||||
lg->addWidget(installButton);
|
||||
lg->addWidget(m_removeButton);
|
||||
topLayout->addLayout(lg);
|
||||
loadThemes();
|
||||
|
||||
loadThemes();
|
||||
m_defaultTheme = iconThemeItem(KIconTheme::current());
|
||||
if (m_defaultTheme) {
|
||||
m_iconThemes->setCurrentItem(m_defaultTheme);
|
||||
}
|
||||
updateRemoveButton();
|
||||
|
||||
m_defaultTheme=iconThemeItem(KIconTheme::current());
|
||||
if (m_defaultTheme)
|
||||
m_iconThemes->setCurrentItem(m_defaultTheme);
|
||||
updateRemoveButton();
|
||||
|
||||
m_iconThemes->setFocus();
|
||||
m_iconThemes->setFocus();
|
||||
}
|
||||
|
||||
IconThemesConfig::~IconThemesConfig()
|
||||
|
@ -128,313 +129,340 @@ IconThemesConfig::~IconThemesConfig()
|
|||
|
||||
QTreeWidgetItem *IconThemesConfig::iconThemeItem(const QString &name)
|
||||
{
|
||||
for (int i = 0; i < m_iconThemes->topLevelItemCount(); ++i)
|
||||
if (m_iconThemes->topLevelItem(i)->data(0, ThemeNameRole).toString()==name)
|
||||
return m_iconThemes->topLevelItem(i);
|
||||
|
||||
return 0L;
|
||||
for (int i = 0; i < m_iconThemes->topLevelItemCount(); ++i) {
|
||||
if (m_iconThemes->topLevelItem(i)->data(0, ThemeNameRole).toString() == name) {
|
||||
return m_iconThemes->topLevelItem(i);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void IconThemesConfig::loadThemes()
|
||||
{
|
||||
m_iconThemes->clear();
|
||||
const QStringList themelist(KIconTheme::list());
|
||||
QString name;
|
||||
QString tname;
|
||||
QStringList::const_iterator it;
|
||||
QMap <QString, QString> themeNames;
|
||||
for (it=themelist.constBegin(); it != themelist.constEnd(); ++it)
|
||||
{
|
||||
KIconTheme icontheme(*it);
|
||||
if (!icontheme.isValid()) kDebug() << "notvalid\n";
|
||||
if (icontheme.isHidden()) continue;
|
||||
m_iconThemes->clear();
|
||||
const QStringList themelist(KIconTheme::list());
|
||||
QString name;
|
||||
QString tname;
|
||||
QStringList::const_iterator it;
|
||||
QMap <QString, QString> themeNames;
|
||||
for (it = themelist.constBegin(); it != themelist.constEnd(); ++it) {
|
||||
KIconTheme icontheme(*it);
|
||||
if (!icontheme.isValid()) {
|
||||
kDebug() << "notvalid";
|
||||
}
|
||||
if (icontheme.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
name=icontheme.name();
|
||||
tname=name;
|
||||
name = icontheme.name();
|
||||
tname = name;
|
||||
|
||||
// Just in case we have duplicated icon theme names on separate directories
|
||||
for (int i = 2; themeNames.find(tname) != themeNames.end(); ++i)
|
||||
tname=QString("%1-%2").arg(name).arg(i);
|
||||
// Just in case we have duplicated icon theme names on separate directories
|
||||
for (int i = 2; themeNames.find(tname) != themeNames.end(); ++i) {
|
||||
tname = QString("%1-%2").arg(name).arg(i);
|
||||
}
|
||||
|
||||
QTreeWidgetItem *newitem = new QTreeWidgetItem();
|
||||
newitem->setText(0, name);
|
||||
newitem->setText(1, icontheme.description());
|
||||
newitem->setData(0, ThemeNameRole, *it);
|
||||
m_iconThemes->addTopLevelItem(newitem);
|
||||
QTreeWidgetItem *newitem = new QTreeWidgetItem();
|
||||
newitem->setText(0, name);
|
||||
newitem->setText(1, icontheme.description());
|
||||
newitem->setData(0, ThemeNameRole, *it);
|
||||
m_iconThemes->addTopLevelItem(newitem);
|
||||
|
||||
themeNames.insert(name, *it);
|
||||
}
|
||||
m_iconThemes->resizeColumnToContents(0);
|
||||
themeNames.insert(name, *it);
|
||||
}
|
||||
m_iconThemes->resizeColumnToContents(0);
|
||||
}
|
||||
|
||||
void IconThemesConfig::installNewTheme()
|
||||
{
|
||||
KUrl themeURL = KUrlRequesterDialog::getUrl(QString(), this,
|
||||
i18n("Drag or Type Theme URL"));
|
||||
KUrl themeURL = KUrlRequesterDialog::getUrl(QString(), this, i18n("Drag or Type Theme URL"));
|
||||
|
||||
if (themeURL.url().isEmpty()) return;
|
||||
if (themeURL.url().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
kDebug() << themeURL.prettyUrl();
|
||||
QString themeTmpFile;
|
||||
// themeTmpFile contains the name of the downloaded file
|
||||
kDebug() << themeURL.prettyUrl();
|
||||
QString themeTmpFile;
|
||||
// themeTmpFile contains the name of the downloaded file
|
||||
|
||||
if (!KIO::NetAccess::download(themeURL, themeTmpFile, this)) {
|
||||
QString sorryText;
|
||||
if (themeURL.isLocalFile())
|
||||
sorryText = i18n("Unable to find the icon theme archive %1.",
|
||||
themeURL.prettyUrl());
|
||||
else
|
||||
sorryText = i18n("Unable to download the icon theme archive;\n"
|
||||
"please check that address %1 is correct.",
|
||||
themeURL.prettyUrl());
|
||||
KMessageBox::sorry(this, sorryText);
|
||||
return;
|
||||
}
|
||||
if (!KIO::NetAccess::download(themeURL, themeTmpFile, this)) {
|
||||
QString sorryText;
|
||||
if (themeURL.isLocalFile()) {
|
||||
sorryText = i18n("Unable to find the icon theme archive %1.", themeURL.prettyUrl());
|
||||
} else {
|
||||
sorryText = i18n(
|
||||
"Unable to download the icon theme archive;\n"
|
||||
"please check that address %1 is correct.",
|
||||
themeURL.prettyUrl()
|
||||
);
|
||||
}
|
||||
KMessageBox::sorry(this, sorryText);
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList themesNames = findThemeDirs(themeTmpFile);
|
||||
if (themesNames.isEmpty()) {
|
||||
QString invalidArch(i18n("The file is not a valid icon theme archive."));
|
||||
KMessageBox::error(this, invalidArch);
|
||||
QStringList themesNames = findThemeDirs(themeTmpFile);
|
||||
if (themesNames.isEmpty()) {
|
||||
QString invalidArch(i18n("The file is not a valid icon theme archive."));
|
||||
KMessageBox::error(this, invalidArch);
|
||||
|
||||
KIO::NetAccess::removeTempFile(themeTmpFile);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!installThemes(themesNames, themeTmpFile)) {
|
||||
// FIXME: make me able to know what is wrong....
|
||||
// QStringList instead of bool?
|
||||
QString somethingWrong = i18n(
|
||||
"A problem occurred during the installation process; "
|
||||
"however, most of the themes in the archive have been installed"
|
||||
);
|
||||
KMessageBox::error(this, somethingWrong);
|
||||
}
|
||||
|
||||
KIO::NetAccess::removeTempFile(themeTmpFile);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!installThemes(themesNames, themeTmpFile)) {
|
||||
//FIXME: make me able to know what is wrong....
|
||||
// QStringList instead of bool?
|
||||
QString somethingWrong =
|
||||
i18n("A problem occurred during the installation process; "
|
||||
"however, most of the themes in the archive have been installed");
|
||||
KMessageBox::error(this, somethingWrong);
|
||||
}
|
||||
KIconLoader::global()->newIconLoader();
|
||||
loadThemes();
|
||||
|
||||
KIO::NetAccess::removeTempFile(themeTmpFile);
|
||||
|
||||
KIconLoader::global()->newIconLoader();
|
||||
loadThemes();
|
||||
|
||||
QTreeWidgetItem *item=iconThemeItem(KIconTheme::current());
|
||||
if (item)
|
||||
m_iconThemes->setCurrentItem(item);
|
||||
updateRemoveButton();
|
||||
QTreeWidgetItem *item=iconThemeItem(KIconTheme::current());
|
||||
if (item) {
|
||||
m_iconThemes->setCurrentItem(item);
|
||||
}
|
||||
updateRemoveButton();
|
||||
}
|
||||
|
||||
bool IconThemesConfig::installThemes(const QStringList &themes, const QString &archiveName)
|
||||
{
|
||||
bool everythingOk = true;
|
||||
const QString localThemesDir(KGlobal::dirs()->saveLocation("icon"));
|
||||
bool everythingOk = true;
|
||||
const QString localThemesDir(KGlobal::dirs()->saveLocation("icon"));
|
||||
|
||||
KProgressDialog progressDiag(this,
|
||||
i18n("Installing icon themes"),
|
||||
QString());
|
||||
progressDiag.setModal(true);
|
||||
progressDiag.setAutoClose(true);
|
||||
QProgressBar* progressBar = progressDiag.progressBar();
|
||||
progressBar->setMaximum(themes.count());
|
||||
progressDiag.show();
|
||||
KProgressDialog progressDiag(this, i18n("Installing icon themes"), QString());
|
||||
progressDiag.setModal(true);
|
||||
progressDiag.setAutoClose(true);
|
||||
QProgressBar* progressBar = progressDiag.progressBar();
|
||||
progressBar->setMaximum(themes.count());
|
||||
progressDiag.show();
|
||||
|
||||
KArchive karchive(archiveName);
|
||||
everythingOk = karchive.isReadable();
|
||||
kapp->processEvents();
|
||||
|
||||
foreach (const QString &it, themes) {
|
||||
progressDiag.setLabelText(i18n("<qt>Installing <strong>%1</strong> theme</qt>", it));
|
||||
KArchive karchive(archiveName);
|
||||
everythingOk = karchive.isReadable();
|
||||
kapp->processEvents();
|
||||
|
||||
if (progressDiag.wasCancelled())
|
||||
break;
|
||||
foreach (const QString &it, themes) {
|
||||
progressDiag.setLabelText(i18n("<qt>Installing <strong>%1</strong> theme</qt>", it));
|
||||
kapp->processEvents();
|
||||
|
||||
QStringList themeFiles;
|
||||
foreach(const KArchiveEntry &karchiveentry, karchive.list(it + QDir::separator())) {
|
||||
themeFiles << QFile::decodeName(karchiveentry.pathname);
|
||||
}
|
||||
if (!karchive.extract(themeFiles, localThemesDir)) {
|
||||
kWarning() << karchive.errorString();
|
||||
// we tell back that something went wrong, but try to install as much
|
||||
// as possible
|
||||
everythingOk = false;
|
||||
if (progressDiag.wasCancelled()) {
|
||||
break;
|
||||
}
|
||||
|
||||
QStringList themeFiles;
|
||||
foreach(const KArchiveEntry &karchiveentry, karchive.list(it + QDir::separator())) {
|
||||
themeFiles << QFile::decodeName(karchiveentry.pathname);
|
||||
}
|
||||
if (!karchive.extract(themeFiles, localThemesDir)) {
|
||||
kWarning() << karchive.errorString();
|
||||
// we tell back that something went wrong, but try to install as much
|
||||
// as possible
|
||||
everythingOk = false;
|
||||
}
|
||||
|
||||
progressBar->setValue(progressBar->value() + 1);
|
||||
}
|
||||
|
||||
progressBar->setValue(progressBar->value()+1);
|
||||
}
|
||||
|
||||
return everythingOk;
|
||||
return everythingOk;
|
||||
}
|
||||
|
||||
QStringList IconThemesConfig::findThemeDirs(const QString &archiveName)
|
||||
{
|
||||
QStringList foundThemes;
|
||||
QStringList foundThemes;
|
||||
|
||||
KArchive karchive(archiveName);
|
||||
if (!karchive.isReadable()) {
|
||||
kWarning() << karchive.errorString();
|
||||
return foundThemes;
|
||||
}
|
||||
|
||||
// iterate all the dirs looking for an index.theme file
|
||||
foreach (const KArchiveEntry &karchiveentry, karchive.list()) {
|
||||
if (karchiveentry.pathname.endsWith("/index.theme")) {
|
||||
const QString pathString = QFile::decodeName(karchiveentry.pathname);
|
||||
const QString themeDir = QFileInfo(pathString).path();
|
||||
foundThemes.append(themeDir);
|
||||
KArchive karchive(archiveName);
|
||||
if (!karchive.isReadable()) {
|
||||
kWarning() << karchive.errorString();
|
||||
return foundThemes;
|
||||
}
|
||||
}
|
||||
|
||||
return foundThemes;
|
||||
// iterate all the dirs looking for an index.theme file
|
||||
foreach (const KArchiveEntry &karchiveentry, karchive.list()) {
|
||||
if (karchiveentry.pathname.endsWith("/index.theme")) {
|
||||
const QString pathString = QFile::decodeName(karchiveentry.pathname);
|
||||
const QString themeDir = QFileInfo(pathString).path();
|
||||
foundThemes.append(themeDir);
|
||||
}
|
||||
}
|
||||
|
||||
return foundThemes;
|
||||
}
|
||||
|
||||
void IconThemesConfig::removeSelectedTheme()
|
||||
{
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
if (!selected)
|
||||
return;
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
if (!selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString question=i18n("<qt>Are you sure you want to remove the "
|
||||
QString question = i18n(
|
||||
"<qt>Are you sure you want to remove the "
|
||||
"<strong>%1</strong> icon theme?<br />"
|
||||
"<br />"
|
||||
"This will delete the files installed by this theme.</qt>",
|
||||
selected->text(0));
|
||||
selected->text(0)
|
||||
);
|
||||
|
||||
bool deletingCurrentTheme=(selected==iconThemeItem(KIconTheme::current()));
|
||||
bool deletingCurrentTheme=(selected==iconThemeItem(KIconTheme::current()));
|
||||
|
||||
int r=KMessageBox::warningContinueCancel(this,question,i18n("Confirmation"),KStandardGuiItem::del());
|
||||
if (r!=KMessageBox::Continue) return;
|
||||
int r = KMessageBox::warningContinueCancel(this,question,i18n("Confirmation"), KStandardGuiItem::del());
|
||||
if (r != KMessageBox::Continue) {
|
||||
return;
|
||||
}
|
||||
|
||||
KIconTheme icontheme(selected->data(0, ThemeNameRole).toString());
|
||||
KIconTheme icontheme(selected->data(0, ThemeNameRole).toString());
|
||||
|
||||
// delete the index file before the async KIO::del so loadThemes() will
|
||||
// ignore that dir.
|
||||
unlink(QFile::encodeName(icontheme.dir()+"/index.theme").data());
|
||||
KIO::del(KUrl( icontheme.dir() ));
|
||||
// delete the index file before the async KIO::del so loadThemes() will
|
||||
// ignore that dir.
|
||||
unlink(QFile::encodeName(icontheme.dir() + "/index.theme").data());
|
||||
KIO::del(KUrl(icontheme.dir()));
|
||||
|
||||
KIconLoader::global()->newIconLoader();
|
||||
KIconLoader::global()->newIconLoader();
|
||||
|
||||
loadThemes();
|
||||
loadThemes();
|
||||
|
||||
QTreeWidgetItem *item=0L;
|
||||
//Fallback to the default if we've deleted the current theme
|
||||
if (!deletingCurrentTheme)
|
||||
item=iconThemeItem(KIconTheme::current());
|
||||
if (!item)
|
||||
item=iconThemeItem(KIconTheme::defaultThemeName());
|
||||
QTreeWidgetItem *item = nullptr;
|
||||
//Fallback to the default if we've deleted the current theme
|
||||
if (!deletingCurrentTheme) {
|
||||
item = iconThemeItem(KIconTheme::current());
|
||||
}
|
||||
if (!item) {
|
||||
item = iconThemeItem(KIconTheme::defaultThemeName());
|
||||
}
|
||||
|
||||
if (item)
|
||||
m_iconThemes->setCurrentItem(item);
|
||||
updateRemoveButton();
|
||||
if (item) {
|
||||
m_iconThemes->setCurrentItem(item);
|
||||
}
|
||||
updateRemoveButton();
|
||||
|
||||
if (deletingCurrentTheme) // Change the configuration
|
||||
save();
|
||||
if (deletingCurrentTheme) {
|
||||
// Change the configuration
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
void IconThemesConfig::updateRemoveButton()
|
||||
{
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
bool enabled = false;
|
||||
if (selected)
|
||||
{
|
||||
QString selectedtheme = selected->data(0, ThemeNameRole).toString();
|
||||
KIconTheme icontheme(selectedtheme);
|
||||
QFileInfo fi(icontheme.dir());
|
||||
enabled = fi.isWritable();
|
||||
// Don't let users remove the current theme.
|
||||
if (selectedtheme == KIconTheme::current() ||
|
||||
selectedtheme == KIconTheme::defaultThemeName())
|
||||
enabled = false;
|
||||
}
|
||||
m_removeButton->setEnabled(enabled);
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
bool enabled = false;
|
||||
if (selected) {
|
||||
QString selectedtheme = selected->data(0, ThemeNameRole).toString();
|
||||
KIconTheme icontheme(selectedtheme);
|
||||
QFileInfo fi(icontheme.dir());
|
||||
enabled = fi.isWritable();
|
||||
// Don't let users remove the current theme.
|
||||
if (selectedtheme == KIconTheme::current() || selectedtheme == KIconTheme::defaultThemeName()) {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
m_removeButton->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void loadPreview(QLabel *label, KIconTheme& icontheme, const QStringList& iconnames)
|
||||
{
|
||||
const int size = qMin(48, icontheme.defaultSize(KIconLoader::Desktop));
|
||||
const QStringList iconthemenames = QStringList()
|
||||
<< icontheme.internalName()
|
||||
<< icontheme.inherits();
|
||||
<< icontheme.internalName()
|
||||
<< icontheme.inherits();
|
||||
foreach(const QString &iconthemename, iconthemenames) {
|
||||
foreach(const QString &name, iconnames) {
|
||||
KIconTheme kicontheme(iconthemename);
|
||||
QString icon = kicontheme.iconPath(QString("%1.png").arg(name), size, KIconLoader::MatchBest);
|
||||
if (!icon.isEmpty()) {
|
||||
label->setPixmap(QPixmap(icon).scaled(size, size));
|
||||
return;
|
||||
foreach(const QString &name, iconnames) {
|
||||
KIconTheme kicontheme(iconthemename);
|
||||
QString icon = kicontheme.iconPath(QString("%1.png").arg(name), size, KIconLoader::MatchBest);
|
||||
if (!icon.isEmpty()) {
|
||||
label->setPixmap(QPixmap(icon).scaled(size, size));
|
||||
return;
|
||||
}
|
||||
icon = kicontheme.iconPath(QString("%1.svg").arg(name), size, KIconLoader::MatchBest);
|
||||
if (icon.isEmpty() ) {
|
||||
icon = kicontheme.iconPath(QString("%1.svgz").arg(name), size, KIconLoader::MatchBest);
|
||||
}
|
||||
if (!icon.isEmpty()) {
|
||||
label->setPixmap(QPixmap(icon).scaled(size, size));
|
||||
return;
|
||||
}
|
||||
}
|
||||
icon = kicontheme.iconPath(QString("%1.svg").arg(name), size, KIconLoader::MatchBest);
|
||||
if (icon.isEmpty() ) {
|
||||
icon = kicontheme.iconPath(QString("%1.svgz").arg(name), size, KIconLoader::MatchBest);
|
||||
}
|
||||
if (!icon.isEmpty()) {
|
||||
label->setPixmap(QPixmap(icon).scaled(size, size));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
label->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
void IconThemesConfig::themeSelected(QTreeWidgetItem *item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString dirName(item->data(0, ThemeNameRole).toString());
|
||||
KIconTheme icontheme(dirName);
|
||||
if (!icontheme.isValid()) kDebug() << "notvalid\n";
|
||||
QString dirName(item->data(0, ThemeNameRole).toString());
|
||||
KIconTheme icontheme(dirName);
|
||||
if (!icontheme.isValid()) {
|
||||
kDebug() << "notvalid";
|
||||
}
|
||||
|
||||
updateRemoveButton();
|
||||
updateRemoveButton();
|
||||
|
||||
loadPreview(m_previewExec, icontheme, QStringList() << "system-run" << "exec");
|
||||
loadPreview(m_previewFolder, icontheme, QStringList() << "folder");
|
||||
loadPreview(m_previewDocument, icontheme, QStringList() << "document" << "text-x-generic");
|
||||
loadPreview(m_previewExec, icontheme, QStringList() << "system-run" << "exec");
|
||||
loadPreview(m_previewFolder, icontheme, QStringList() << "folder");
|
||||
loadPreview(m_previewDocument, icontheme, QStringList() << "document" << "text-x-generic");
|
||||
|
||||
emit changed(true);
|
||||
m_bChanged = true;
|
||||
emit changed(true);
|
||||
m_bChanged = true;
|
||||
}
|
||||
|
||||
void IconThemesConfig::load()
|
||||
{
|
||||
m_defaultTheme=iconThemeItem(KIconTheme::current());
|
||||
if (m_defaultTheme)
|
||||
m_iconThemes->setCurrentItem(m_defaultTheme);
|
||||
emit changed(false);
|
||||
m_bChanged = false;
|
||||
m_defaultTheme = iconThemeItem(KIconTheme::current());
|
||||
if (m_defaultTheme) {
|
||||
m_iconThemes->setCurrentItem(m_defaultTheme);
|
||||
}
|
||||
emit changed(false);
|
||||
m_bChanged = false;
|
||||
}
|
||||
|
||||
void IconThemesConfig::save()
|
||||
{
|
||||
if (!m_bChanged)
|
||||
return;
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
if (!selected)
|
||||
return;
|
||||
if (!m_bChanged) {
|
||||
return;
|
||||
}
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
if (!selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
KConfigGroup config(KSharedConfig::openConfig("kdeglobals", KConfig::SimpleConfig), "Icons");
|
||||
config.writeEntry("Theme", selected->data(0, ThemeNameRole).toString());
|
||||
config.sync();
|
||||
KConfigGroup config(KSharedConfig::openConfig("kdeglobals", KConfig::SimpleConfig), "Icons");
|
||||
config.writeEntry("Theme", selected->data(0, ThemeNameRole).toString());
|
||||
config.sync();
|
||||
|
||||
KIconTheme::reconfigure();
|
||||
emit changed(false);
|
||||
KIconTheme::reconfigure();
|
||||
emit changed(false);
|
||||
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
{
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::IconChanged, i);
|
||||
}
|
||||
for (int i = 0; i < KIconLoader::LastGroup; i++) {
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::IconChanged, i);
|
||||
}
|
||||
|
||||
KBuildSycocaProgressDialog::rebuildKSycoca(this);
|
||||
KBuildSycocaProgressDialog::rebuildKSycoca(this);
|
||||
|
||||
m_bChanged = false;
|
||||
m_removeButton->setEnabled(false);
|
||||
m_bChanged = false;
|
||||
m_removeButton->setEnabled(false);
|
||||
}
|
||||
|
||||
void IconThemesConfig::defaults()
|
||||
{
|
||||
if (m_iconThemes->currentItem()==m_defaultTheme) return;
|
||||
if (m_iconThemes->currentItem() == m_defaultTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_defaultTheme)
|
||||
m_iconThemes->setCurrentItem(m_defaultTheme);
|
||||
updateRemoveButton();
|
||||
if (m_defaultTheme) {
|
||||
m_iconThemes->setCurrentItem(m_defaultTheme);
|
||||
}
|
||||
updateRemoveButton();
|
||||
|
||||
emit changed(true);
|
||||
m_bChanged = true;
|
||||
emit changed(true);
|
||||
m_bChanged = true;
|
||||
}
|
||||
|
||||
#include "moc_iconthemes.cpp"
|
||||
|
|
|
@ -30,40 +30,40 @@
|
|||
|
||||
class IconThemesConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IconThemesConfig(const KComponentData &inst, QWidget *parent);
|
||||
virtual ~IconThemesConfig();
|
||||
IconThemesConfig(const KComponentData &inst, QWidget *parent);
|
||||
virtual ~IconThemesConfig();
|
||||
|
||||
void loadThemes();
|
||||
bool installThemes(const QStringList &themes, const QString &archiveName);
|
||||
QStringList findThemeDirs(const QString &archiveName);
|
||||
void loadThemes();
|
||||
bool installThemes(const QStringList &themes, const QString &archiveName);
|
||||
QStringList findThemeDirs(const QString &archiveName);
|
||||
|
||||
void updateRemoveButton();
|
||||
void updateRemoveButton();
|
||||
|
||||
void load();
|
||||
void save();
|
||||
void defaults();
|
||||
void load();
|
||||
void save();
|
||||
void defaults();
|
||||
|
||||
int buttons();
|
||||
int buttons();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void themeSelected(QTreeWidgetItem *item);
|
||||
void installNewTheme();
|
||||
void removeSelectedTheme();
|
||||
void themeSelected(QTreeWidgetItem *item);
|
||||
void installNewTheme();
|
||||
void removeSelectedTheme();
|
||||
|
||||
private:
|
||||
QTreeWidgetItem *iconThemeItem(const QString &name);
|
||||
QTreeWidgetItem *iconThemeItem(const QString &name);
|
||||
|
||||
QTreeWidget *m_iconThemes;
|
||||
KPushButton *m_removeButton;
|
||||
QTreeWidget *m_iconThemes;
|
||||
KPushButton *m_removeButton;
|
||||
|
||||
QLabel *m_previewExec;
|
||||
QLabel *m_previewFolder;
|
||||
QLabel *m_previewDocument;
|
||||
QTreeWidgetItem *m_defaultTheme;
|
||||
bool m_bChanged;
|
||||
QLabel *m_previewExec;
|
||||
QLabel *m_previewFolder;
|
||||
QLabel *m_previewDocument;
|
||||
QTreeWidgetItem *m_defaultTheme;
|
||||
bool m_bChanged;
|
||||
};
|
||||
|
||||
#endif // ICONTHEMES_H
|
||||
|
|
|
@ -43,73 +43,73 @@ K_EXPORT_PLUGIN(IconsFactory("kcmicons"))
|
|||
/**** IconModule ****/
|
||||
|
||||
IconModule::IconModule(QWidget *parent, const QVariantList &)
|
||||
: KCModule(IconsFactory::componentData(), parent)
|
||||
: KCModule(IconsFactory::componentData(), parent)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
|
||||
tab = new QTabWidget(this);
|
||||
layout->addWidget(tab);
|
||||
tab = new QTabWidget(this);
|
||||
layout->addWidget(tab);
|
||||
|
||||
tab1 = new IconThemesConfig(IconsFactory::componentData(), this);
|
||||
tab1->setObjectName( QLatin1String( "themes" ) );
|
||||
tab->addTab(tab1, i18n("&Theme"));
|
||||
connect(tab1, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
|
||||
tab1 = new IconThemesConfig(IconsFactory::componentData(), this);
|
||||
tab1->setObjectName(QLatin1String("themes" ));
|
||||
tab->addTab(tab1, i18n("&Theme"));
|
||||
connect(tab1, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
|
||||
|
||||
tab2 = new KIconConfig(IconsFactory::componentData(), this);
|
||||
tab2->setObjectName( QLatin1String( "effects" ) );
|
||||
tab->addTab(tab2, i18n("Ad&vanced"));
|
||||
connect(tab2, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
|
||||
tab2 = new KIconConfig(IconsFactory::componentData(), this);
|
||||
tab2->setObjectName( QLatin1String( "effects" ) );
|
||||
tab->addTab(tab2, i18n("Ad&vanced"));
|
||||
connect(tab2, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
|
||||
|
||||
KAboutData* about = new KAboutData("kcmicons", 0, ki18n("Icons"), "3.0",
|
||||
ki18n("Icons Control Panel Module"),
|
||||
KAboutData::License_GPL,
|
||||
ki18n("(c) 2000-2003 Geert Jansen"));
|
||||
about->addAuthor(ki18n("Geert Jansen"), KLocalizedString(), "jansen@kde.org");
|
||||
about->addAuthor(ki18n("Antonio Larrosa Jimenez"), KLocalizedString(), "larrosa@kde.org");
|
||||
about->addCredit(ki18n("Torsten Rahn"), KLocalizedString(), "torsten@kde.org");
|
||||
setAboutData( about );
|
||||
KAboutData* about = new KAboutData(
|
||||
"kcmicons", 0, ki18n("Icons"), "3.0",
|
||||
ki18n("Icons Control Panel Module"),
|
||||
KAboutData::License_GPL,
|
||||
ki18n("(c) 2000-2003 Geert Jansen")
|
||||
);
|
||||
about->addAuthor(ki18n("Geert Jansen"), KLocalizedString(), "jansen@kde.org");
|
||||
about->addAuthor(ki18n("Antonio Larrosa Jimenez"), KLocalizedString(), "larrosa@kde.org");
|
||||
about->addCredit(ki18n("Torsten Rahn"), KLocalizedString(), "torsten@kde.org");
|
||||
setAboutData(about);
|
||||
}
|
||||
|
||||
|
||||
void IconModule::load()
|
||||
{
|
||||
tab1->load();
|
||||
tab2->load();
|
||||
tab1->load();
|
||||
tab2->load();
|
||||
}
|
||||
|
||||
|
||||
void IconModule::save()
|
||||
{
|
||||
tab1->save();
|
||||
tab2->save();
|
||||
tab1->save();
|
||||
tab2->save();
|
||||
}
|
||||
|
||||
|
||||
void IconModule::defaults()
|
||||
{
|
||||
tab1->defaults();
|
||||
tab2->defaults();
|
||||
tab1->defaults();
|
||||
tab2->defaults();
|
||||
}
|
||||
|
||||
|
||||
void IconModule::moduleChanged(bool state)
|
||||
{
|
||||
emit changed(state);
|
||||
emit changed(state);
|
||||
}
|
||||
|
||||
QString IconModule::quickHelp() const
|
||||
{
|
||||
return i18n("<h1>Icons</h1>"
|
||||
"This module allows you to choose the icons for your desktop.<p>"
|
||||
"To choose an icon theme, click on its name and apply your choice by pressing the \"Apply\" button below. If you do not want to apply your choice you can press the \"Reset\" button to discard your changes.</p>"
|
||||
"<p>By pressing the \"Install Theme File...\" button you can install your new icon theme by writing its location in the box or browsing to the location."
|
||||
" Press the \"OK\" button to finish the installation.</p>"
|
||||
"<p>The \"Remove Theme\" button will only be activated if you select a theme that you installed using this module."
|
||||
" You are not able to remove globally installed themes here.</p>"
|
||||
"<p>You can also specify effects that should be applied to the icons.</p>");
|
||||
return i18n(
|
||||
"<h1>Icons</h1>"
|
||||
"This module allows you to choose the icons for your desktop.<p>"
|
||||
"To choose an icon theme, click on its name and apply your choice by pressing the \"Apply\" button below. If you do not want to apply your choice you can press the \"Reset\" button to discard your changes.</p>"
|
||||
"<p>By pressing the \"Install Theme File...\" button you can install your new icon theme by writing its location in the box or browsing to the location."
|
||||
" Press the \"OK\" button to finish the installation.</p>"
|
||||
"<p>The \"Remove Theme\" button will only be activated if you select a theme that you installed using this module."
|
||||
" You are not able to remove globally installed themes here.</p>"
|
||||
"<p>You can also specify effects that should be applied to the icons.</p>"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_main.cpp"
|
||||
|
|
|
@ -31,25 +31,24 @@
|
|||
|
||||
class IconModule : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IconModule(QWidget *parent, const QVariantList &);
|
||||
IconModule(QWidget *parent, const QVariantList &);
|
||||
|
||||
void load();
|
||||
void save();
|
||||
void defaults();
|
||||
QString quickHelp() const;
|
||||
void load();
|
||||
void save();
|
||||
void defaults();
|
||||
QString quickHelp() const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void moduleChanged(bool state);
|
||||
void moduleChanged(bool state);
|
||||
|
||||
private:
|
||||
QTabWidget *tab;
|
||||
QTabWidget *tab;
|
||||
|
||||
KCModule *tab1;
|
||||
KCModule *tab2;
|
||||
KCModule *tab1;
|
||||
KCModule *tab2;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue