diff options
author | Michele Calgaro <[email protected]> | 2019-04-14 15:07:33 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2019-04-14 15:07:33 +0900 |
commit | c53dbf95cb42a7bb22e8690bf699fda32e657845 (patch) | |
tree | 896452138f10e9106e1533720efd0bb3923eb45c /tdeioslave/trash/ktrashpropswidget.cpp | |
parent | 691c9204a1a6dcbce52d41e62a988044e48270d4 (diff) | |
download | tdebase-c53dbf95cb42a7bb22e8690bf699fda32e657845.tar.gz tdebase-c53dbf95cb42a7bb22e8690bf699fda32e657845.zip |
Improved code for trash bin management.
1. When size limit is used, a file bigger than the trash size can't be
trashed anymore (a warning message is shown).
2. When size limit is used and warning policy selected, files can't be
trashed anymore if the total size of the trash will exceed the set size
(a warning message is shown).
3. When the trash size settings are modified, the content of the trash
is adjusted based on the new settings.
4. Fixed load/saving of trash options when more than one trash folder exists.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdeioslave/trash/ktrashpropswidget.cpp')
-rw-r--r-- | tdeioslave/trash/ktrashpropswidget.cpp | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/tdeioslave/trash/ktrashpropswidget.cpp b/tdeioslave/trash/ktrashpropswidget.cpp index b4f5c5e6f..40e12cb4f 100644 --- a/tdeioslave/trash/ktrashpropswidget.cpp +++ b/tdeioslave/trash/ktrashpropswidget.cpp @@ -62,7 +62,6 @@ KTrashPropsWidget::KTrashPropsWidget(TQWidget *parent, const char *name) inhibitChangedSignal = true; load(); - trashChanged(0); } KTrashPropsWidget::~KTrashPropsWidget() @@ -90,11 +89,8 @@ void KTrashPropsWidget::setupGui() mountPoints->setCurrentItem(0); connect(mountPoints, TQT_SIGNAL(highlighted(int)), TQT_SLOT(trashChanged(int))); } - else - { - mCurrentTrash = map[0]; - } + mCurrentTrash = map[0]; mUseTimeLimit = new TQCheckBox(i18n("Delete files older than:"), this); wlayout->addMultiCellWidget(mUseTimeLimit, multiTrashRow + 0, multiTrashRow + 0, 0, 1); mDays = new TQSpinBox(1, 365, 1, this); @@ -150,28 +146,36 @@ void KTrashPropsWidget::setDirty() void KTrashPropsWidget::load() { - readConfig(); + inhibitChangedSignal = true; - mUseTimeLimit->setChecked(mConfigMap[mCurrentTrash].useTimeLimit); - mUseSizeLimit->setChecked(mConfigMap[mCurrentTrash].useSizeLimit); - mSizeLimitType = mConfigMap[mCurrentTrash].sizeLimitType; - if (mSizeLimitType == SIZE_LIMIT_FIXED) + readConfig(); + if (mConfigMap.contains(mCurrentTrash)) { - mRbFixedSize->setChecked(true); + mUseTimeLimit->setChecked(mConfigMap[mCurrentTrash].useTimeLimit); + mUseSizeLimit->setChecked(mConfigMap[mCurrentTrash].useSizeLimit); + mSizeLimitType = mConfigMap[mCurrentTrash].sizeLimitType; + if (mSizeLimitType == SIZE_LIMIT_FIXED) + { + mRbFixedSize->setChecked(true); + } + else + { + mRbPercentSize->setChecked(true); + } + mDays->setValue(mConfigMap[mCurrentTrash].days); + mPercentSize->setValue(mConfigMap[mCurrentTrash].percent); + mFixedSize->setValue(mConfigMap[mCurrentTrash].fixedSize); + mFixedSizeUnit->setCurrentItem(mConfigMap[mCurrentTrash].fixedSizeUnit); + mLimitReachedAction->setCurrentItem(mConfigMap[mCurrentTrash].actionType); + percentSizeChanged(mPercentSize->value()); + fixedSizeChanged(mFixedSize->value()); } else { - mRbPercentSize->setChecked(true); + setDefaultValues(); } - mDays->setValue(mConfigMap[mCurrentTrash].days); - mPercentSize->setValue(mConfigMap[mCurrentTrash].percent); - mFixedSize->setValue(mConfigMap[mCurrentTrash].fixedSize); - mFixedSizeUnit->setCurrentItem(mConfigMap[mCurrentTrash].fixedSizeUnit); - mLimitReachedAction->setCurrentItem(mConfigMap[mCurrentTrash].actionType); - percentSizeChanged(mPercentSize->value()); - fixedSizeChanged(mFixedSize->value()); - useTypeChanged(); + useTypeChanged(); inhibitChangedSignal = false; } @@ -199,6 +203,13 @@ void KTrashPropsWidget::save() } writeConfig(); + + // Adjust trash size if necessary + TrashImpl::TrashDirMap trashDirs = mTrashImpl->trashDirectories(); + for (TrashImpl::TrashDirMap::ConstIterator it = trashDirs.begin(); it != trashDirs.end(); ++it) + { + mTrashImpl->resizeTrash(it.key()); + } } void KTrashPropsWidget::setDefaultValues() @@ -214,7 +225,6 @@ void KTrashPropsWidget::setDefaultValues() { mRbPercentSize->setChecked(true); } - mDays->setValue(mConfigMap[mCurrentTrash].days); mPercentSize->setValue(1); mFixedSize->setValue(500); @@ -363,7 +373,7 @@ void KTrashPropsWidget::trashChanged(int value) mUseTimeLimit->setChecked(entry.useTimeLimit); mDays->setValue(entry.days); mUseSizeLimit->setChecked(entry.useSizeLimit); - if (mSizeLimitType == SIZE_LIMIT_FIXED) + if (entry.sizeLimitType == SIZE_LIMIT_FIXED) { mRbFixedSize->setChecked(true); } @@ -419,13 +429,13 @@ void KTrashPropsWidget::readConfig() config.setGroup(groups[i]); ConfigEntry entry; entry.useTimeLimit = config.readBoolEntry("UseTimeLimit", false); - entry.days = config.readNumEntry("Days", 7); + entry.days = config.readNumEntry("Days", 32000); entry.useSizeLimit = config.readBoolEntry("UseSizeLimit", true); entry.sizeLimitType = config.readNumEntry("SizeLimitType", SIZE_LIMIT_PERCENT); entry.percent = config.readDoubleNumEntry("Percent", 10); entry.fixedSize = config.readDoubleNumEntry("FixedSize", 500); entry.fixedSizeUnit = config.readNumEntry("FixedSizeUnit", SIZE_ID_MB); - entry.actionType = config.readNumEntry("LimitReachedAction", 0); + entry.actionType = config.readNumEntry("LimitReachedAction", ACTION_WARNING); mConfigMap.insert(groups[i], entry); } } |