mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +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);
|
||||
|
||||
|
@ -124,8 +123,9 @@ void KIconConfig::init()
|
|||
mpConfig = KGlobal::config();
|
||||
mpEffect = new KIconEffect;
|
||||
mUsage = 0;
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
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++)
|
||||
{
|
||||
for(it = mGroups.constBegin(), i= KIconLoader::FirstGroup; it != mGroups.constEnd(); ++it, i++) {
|
||||
mbChanged[i] = true;
|
||||
mbAnimated[i] = false;
|
||||
if (mpLoader->theme())
|
||||
if (mpLoader->theme()) {
|
||||
mSizes[i] = mpLoader->theme()->defaultSize(i);
|
||||
else
|
||||
} 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 )
|
||||
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;
|
||||
// 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,33 +234,33 @@ 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]);
|
||||
|
||||
for (it2=mStates.constBegin(), j=0; it2!=mStates.constEnd(); ++it2, j++)
|
||||
{
|
||||
for (it2 = mStates.constBegin(), j = 0; it2 != mStates.constEnd(); ++it2, j++) {
|
||||
QString tmp = iconGroup.readEntry(*it2 + "Effect", QString());
|
||||
if (tmp == "togray")
|
||||
if (tmp == "togray") {
|
||||
effect = KIconEffect::ToGray;
|
||||
else if (tmp == "colorize")
|
||||
} else if (tmp == "colorize") {
|
||||
effect = KIconEffect::Colorize;
|
||||
else if (tmp == "togamma")
|
||||
} else if (tmp == "togamma") {
|
||||
effect = KIconEffect::ToGamma;
|
||||
else if (tmp == "desaturate")
|
||||
} else if (tmp == "desaturate") {
|
||||
effect = KIconEffect::DeSaturate;
|
||||
else if (tmp == "tomonochrome")
|
||||
} else if (tmp == "tomonochrome") {
|
||||
effect = KIconEffect::ToMonochrome;
|
||||
else if (tmp == "none")
|
||||
} else if (tmp == "none") {
|
||||
effect = KIconEffect::NoEffect;
|
||||
else continue;
|
||||
} 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].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,45 +322,48 @@ void KIconConfig::load()
|
|||
read();
|
||||
apply();
|
||||
emit changed(false);
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
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++)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
for (it2 = mStates.constBegin(), j = 0; it2 != mStates.constEnd(); ++it2, j++) {
|
||||
QString tmp;
|
||||
switch (mEffects[i][j].type)
|
||||
{
|
||||
case KIconEffect::ToGray:
|
||||
switch (mEffects[i][j].type) {
|
||||
case KIconEffect::ToGray: {
|
||||
tmp = "togray";
|
||||
break;
|
||||
case KIconEffect::ToGamma:
|
||||
}
|
||||
case KIconEffect::ToGamma: {
|
||||
tmp = "togamma";
|
||||
break;
|
||||
case KIconEffect::Colorize:
|
||||
}
|
||||
case KIconEffect::Colorize: {
|
||||
tmp = "colorize";
|
||||
break;
|
||||
case KIconEffect::DeSaturate:
|
||||
}
|
||||
case KIconEffect::DeSaturate: {
|
||||
tmp = "desaturate";
|
||||
break;
|
||||
case KIconEffect::ToMonochrome:
|
||||
}
|
||||
case KIconEffect::ToMonochrome: {
|
||||
tmp = "tomonochrome";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
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);
|
||||
|
@ -383,11 +376,9 @@ void KIconConfig::save()
|
|||
|
||||
emit changed(false);
|
||||
|
||||
// Emit KIPC change message.
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
{
|
||||
if (mbChanged[i])
|
||||
{
|
||||
// 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,8 +420,7 @@ void KIconConfig::EffectSetup(int state)
|
|||
QImage img = pm.toImage();
|
||||
|
||||
QString caption;
|
||||
switch (state)
|
||||
{
|
||||
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;
|
||||
|
@ -440,23 +428,23 @@ void KIconConfig::EffectSetup(int state)
|
|||
|
||||
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;
|
||||
|
@ -488,15 +475,15 @@ KIconEffectSetupDialog::KIconEffectSetupDialog(const Effect &effect,
|
|||
const Effect &defaultEffect,
|
||||
const QString &caption, const QImage &image,
|
||||
QWidget *parent, char *name)
|
||||
: KDialog( parent ),
|
||||
: 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();
|
||||
|
@ -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; }
|
||||
|
||||
|
|
|
@ -77,7 +77,6 @@ IconThemesConfig::IconThemesConfig(const KComponentData &inst, QWidget *parent)
|
|||
lh2->addWidget(m_previewDocument);
|
||||
lh2->addStretch(10);
|
||||
|
||||
|
||||
m_iconThemes=new QTreeWidget(this/*"IconThemeList"*/);
|
||||
QStringList columns;
|
||||
columns.append(i18n("Name"));
|
||||
|
@ -87,23 +86,24 @@ IconThemesConfig::IconThemesConfig(const KComponentData &inst, QWidget *parent)
|
|||
m_iconThemes->setRootIsDecorated(false);
|
||||
m_iconThemes->setSortingEnabled(true);
|
||||
m_iconThemes->sortByColumn(0, Qt::AscendingOrder);
|
||||
connect(m_iconThemes,SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
SLOT(themeSelected(QTreeWidgetItem *)));
|
||||
connect(
|
||||
m_iconThemes, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
this, SLOT(themeSelected(QTreeWidgetItem *))
|
||||
);
|
||||
|
||||
KPushButton *installButton=new KPushButton( KIcon("document-import"), i18n("Install Theme File..."), this);
|
||||
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()));
|
||||
connect(installButton, SIGNAL(clicked()), this, SLOT(installNewTheme()));
|
||||
|
||||
m_removeButton=new KPushButton( KIcon("edit-delete"), i18n("Remove Theme"), this);
|
||||
m_removeButton->setObjectName( QLatin1String("RemoveTheme" ));
|
||||
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()));
|
||||
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(removeSelectedTheme()));
|
||||
|
||||
topLayout->addWidget(
|
||||
new QLabel(i18n("Select the icon theme you want to use:"), this));
|
||||
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();
|
||||
|
@ -114,9 +114,10 @@ IconThemesConfig::IconThemesConfig(const KComponentData &inst, QWidget *parent)
|
|||
|
||||
loadThemes();
|
||||
|
||||
m_defaultTheme=iconThemeItem(KIconTheme::current());
|
||||
if (m_defaultTheme)
|
||||
m_defaultTheme = iconThemeItem(KIconTheme::current());
|
||||
if (m_defaultTheme) {
|
||||
m_iconThemes->setCurrentItem(m_defaultTheme);
|
||||
}
|
||||
updateRemoveButton();
|
||||
|
||||
m_iconThemes->setFocus();
|
||||
|
@ -128,11 +129,12 @@ 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)
|
||||
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;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void IconThemesConfig::loadThemes()
|
||||
|
@ -143,18 +145,22 @@ void IconThemesConfig::loadThemes()
|
|||
QString tname;
|
||||
QStringList::const_iterator it;
|
||||
QMap <QString, QString> themeNames;
|
||||
for (it=themelist.constBegin(); it != themelist.constEnd(); ++it)
|
||||
{
|
||||
for (it = themelist.constBegin(); it != themelist.constEnd(); ++it) {
|
||||
KIconTheme icontheme(*it);
|
||||
if (!icontheme.isValid()) kDebug() << "notvalid\n";
|
||||
if (icontheme.isHidden()) continue;
|
||||
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);
|
||||
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);
|
||||
|
@ -169,10 +175,11 @@ void IconThemesConfig::loadThemes()
|
|||
|
||||
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;
|
||||
|
@ -180,13 +187,15 @@ void IconThemesConfig::installNewTheme()
|
|||
|
||||
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"
|
||||
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());
|
||||
themeURL.prettyUrl()
|
||||
);
|
||||
}
|
||||
KMessageBox::sorry(this, sorryText);
|
||||
return;
|
||||
}
|
||||
|
@ -201,11 +210,12 @@ void IconThemesConfig::installNewTheme()
|
|||
}
|
||||
|
||||
if (!installThemes(themesNames, themeTmpFile)) {
|
||||
//FIXME: make me able to know what is wrong....
|
||||
// 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");
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -215,8 +225,9 @@ void IconThemesConfig::installNewTheme()
|
|||
loadThemes();
|
||||
|
||||
QTreeWidgetItem *item=iconThemeItem(KIconTheme::current());
|
||||
if (item)
|
||||
if (item) {
|
||||
m_iconThemes->setCurrentItem(item);
|
||||
}
|
||||
updateRemoveButton();
|
||||
}
|
||||
|
||||
|
@ -225,9 +236,7 @@ bool IconThemesConfig::installThemes(const QStringList &themes, const QString &a
|
|||
bool everythingOk = true;
|
||||
const QString localThemesDir(KGlobal::dirs()->saveLocation("icon"));
|
||||
|
||||
KProgressDialog progressDiag(this,
|
||||
i18n("Installing icon themes"),
|
||||
QString());
|
||||
KProgressDialog progressDiag(this, i18n("Installing icon themes"), QString());
|
||||
progressDiag.setModal(true);
|
||||
progressDiag.setAutoClose(true);
|
||||
QProgressBar* progressBar = progressDiag.progressBar();
|
||||
|
@ -242,8 +251,9 @@ bool IconThemesConfig::installThemes(const QStringList &themes, const QString &a
|
|||
progressDiag.setLabelText(i18n("<qt>Installing <strong>%1</strong> theme</qt>", it));
|
||||
kapp->processEvents();
|
||||
|
||||
if (progressDiag.wasCancelled())
|
||||
if (progressDiag.wasCancelled()) {
|
||||
break;
|
||||
}
|
||||
|
||||
QStringList themeFiles;
|
||||
foreach(const KArchiveEntry &karchiveentry, karchive.list(it + QDir::separator())) {
|
||||
|
@ -256,7 +266,7 @@ bool IconThemesConfig::installThemes(const QStringList &themes, const QString &a
|
|||
everythingOk = false;
|
||||
}
|
||||
|
||||
progressBar->setValue(progressBar->value()+1);
|
||||
progressBar->setValue(progressBar->value() + 1);
|
||||
}
|
||||
|
||||
return everythingOk;
|
||||
|
@ -287,61 +297,70 @@ QStringList IconThemesConfig::findThemeDirs(const QString &archiveName)
|
|||
void IconThemesConfig::removeSelectedTheme()
|
||||
{
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
if (!selected)
|
||||
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()));
|
||||
|
||||
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());
|
||||
|
||||
// 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() ));
|
||||
unlink(QFile::encodeName(icontheme.dir() + "/index.theme").data());
|
||||
KIO::del(KUrl(icontheme.dir()));
|
||||
|
||||
KIconLoader::global()->newIconLoader();
|
||||
|
||||
loadThemes();
|
||||
|
||||
QTreeWidgetItem *item=0L;
|
||||
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 (!deletingCurrentTheme) {
|
||||
item = iconThemeItem(KIconTheme::current());
|
||||
}
|
||||
if (!item) {
|
||||
item = iconThemeItem(KIconTheme::defaultThemeName());
|
||||
}
|
||||
|
||||
if (item)
|
||||
if (item) {
|
||||
m_iconThemes->setCurrentItem(item);
|
||||
}
|
||||
updateRemoveButton();
|
||||
|
||||
if (deletingCurrentTheme) // Change the configuration
|
||||
if (deletingCurrentTheme) {
|
||||
// Change the configuration
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
void IconThemesConfig::updateRemoveButton()
|
||||
{
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
bool enabled = false;
|
||||
if (selected)
|
||||
{
|
||||
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())
|
||||
if (selectedtheme == KIconTheme::current() || selectedtheme == KIconTheme::defaultThemeName()) {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
m_removeButton->setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
@ -374,11 +393,15 @@ void loadPreview(QLabel *label, KIconTheme& icontheme, const QStringList& iconna
|
|||
|
||||
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";
|
||||
if (!icontheme.isValid()) {
|
||||
kDebug() << "notvalid";
|
||||
}
|
||||
|
||||
updateRemoveButton();
|
||||
|
||||
|
@ -392,20 +415,23 @@ void IconThemesConfig::themeSelected(QTreeWidgetItem *item)
|
|||
|
||||
void IconThemesConfig::load()
|
||||
{
|
||||
m_defaultTheme=iconThemeItem(KIconTheme::current());
|
||||
if (m_defaultTheme)
|
||||
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)
|
||||
if (!m_bChanged) {
|
||||
return;
|
||||
}
|
||||
QTreeWidgetItem *selected = m_iconThemes->currentItem();
|
||||
if (!selected)
|
||||
if (!selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
KConfigGroup config(KSharedConfig::openConfig("kdeglobals", KConfig::SimpleConfig), "Icons");
|
||||
config.writeEntry("Theme", selected->data(0, ThemeNameRole).toString());
|
||||
|
@ -414,8 +440,7 @@ void IconThemesConfig::save()
|
|||
KIconTheme::reconfigure();
|
||||
emit changed(false);
|
||||
|
||||
for (int i=0; i<KIconLoader::LastGroup; i++)
|
||||
{
|
||||
for (int i = 0; i < KIconLoader::LastGroup; i++) {
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::IconChanged, i);
|
||||
}
|
||||
|
||||
|
@ -427,10 +452,13 @@ void IconThemesConfig::save()
|
|||
|
||||
void IconThemesConfig::defaults()
|
||||
{
|
||||
if (m_iconThemes->currentItem()==m_defaultTheme) return;
|
||||
if (m_iconThemes->currentItem() == m_defaultTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_defaultTheme)
|
||||
if (m_defaultTheme) {
|
||||
m_iconThemes->setCurrentItem(m_defaultTheme);
|
||||
}
|
||||
updateRemoveButton();
|
||||
|
||||
emit changed(true);
|
||||
|
|
|
@ -52,7 +52,7 @@ IconModule::IconModule(QWidget *parent, const QVariantList &)
|
|||
layout->addWidget(tab);
|
||||
|
||||
tab1 = new IconThemesConfig(IconsFactory::componentData(), this);
|
||||
tab1->setObjectName( QLatin1String( "themes" ) );
|
||||
tab1->setObjectName(QLatin1String("themes" ));
|
||||
tab->addTab(tab1, i18n("&Theme"));
|
||||
connect(tab1, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
|
||||
|
||||
|
@ -61,14 +61,16 @@ IconModule::IconModule(QWidget *parent, const QVariantList &)
|
|||
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",
|
||||
KAboutData* about = new KAboutData(
|
||||
"kcmicons", 0, ki18n("Icons"), "3.0",
|
||||
ki18n("Icons Control Panel Module"),
|
||||
KAboutData::License_GPL,
|
||||
ki18n("(c) 2000-2003 Geert Jansen"));
|
||||
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 );
|
||||
setAboutData(about);
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,14 +80,12 @@ void IconModule::load()
|
|||
tab2->load();
|
||||
}
|
||||
|
||||
|
||||
void IconModule::save()
|
||||
{
|
||||
tab1->save();
|
||||
tab2->save();
|
||||
}
|
||||
|
||||
|
||||
void IconModule::defaults()
|
||||
{
|
||||
tab1->defaults();
|
||||
|
@ -100,16 +100,16 @@ void IconModule::moduleChanged(bool state)
|
|||
|
||||
QString IconModule::quickHelp() const
|
||||
{
|
||||
return i18n("<h1>Icons</h1>"
|
||||
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>");
|
||||
"<p>You can also specify effects that should be applied to the icons.</p>"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_main.cpp"
|
||||
|
|
|
@ -51,5 +51,4 @@ private:
|
|||
KCModule *tab2;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue