mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
Apply the view properties to sub directories without using a modal window. This allows the user to proceed with the work during the view properties are applied.
svn path=/trunk/playground/utils/dolphin/; revision=611369
This commit is contained in:
parent
904168ad2a
commit
31d1457195
|
@ -50,9 +50,9 @@ ViewProperties::ViewProperties(const KUrl& url) :
|
|||
return;
|
||||
}
|
||||
|
||||
// we try and save it to a file in the directory being viewed
|
||||
// if the directory is not writable by the user or the directory is not local
|
||||
// we store the properties information in a local file
|
||||
// We try and save it to a file in the directory being viewed.
|
||||
// If the directory is not writable by the user or the directory is not local,
|
||||
// we store the properties information in a local file.
|
||||
QString rootDir("/"); // TODO: should this be set to the root of the bookmark, if any?
|
||||
if (cleanUrl.isLocalFile()) {
|
||||
QFileInfo info(m_filepath);
|
||||
|
|
|
@ -30,23 +30,21 @@
|
|||
class QFile;
|
||||
|
||||
/**
|
||||
* @short Maintains the view properties like 'view mode' or 'show hidden files' for a directory.
|
||||
* @brief Maintains the view properties like 'view mode' or 'show hidden files' for a directory.
|
||||
*
|
||||
* The view properties are automatically stored inside
|
||||
* the directory as hidden file called '.dolphinview'. To read out the view properties
|
||||
* just construct an instance by passing the Url of the directory:
|
||||
*
|
||||
* \code
|
||||
* ViewProperties props(KUrl("/home/peter/Documents"));
|
||||
* const DolphinView::Mode mode = props.viewMode();
|
||||
* const bool showHiddenFiles = props.isShowHiddenFilesEnabled();
|
||||
* \endcode
|
||||
*
|
||||
* When modifying a view property, the '.dolphinview' file is automatically updated
|
||||
* inside the destructor.
|
||||
*
|
||||
* @author Peter Penz
|
||||
*/
|
||||
// TODO: provide detailed design description, as mapping the user model to
|
||||
// the physical modal is not trivial.
|
||||
class ViewProperties
|
||||
{
|
||||
public:
|
||||
|
@ -71,7 +69,6 @@ public:
|
|||
void updateTimeStamp();
|
||||
void save();
|
||||
|
||||
|
||||
private:
|
||||
bool m_changedProps;
|
||||
bool m_autoSave;
|
||||
|
|
|
@ -99,22 +99,9 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
propsBoxLayout->addWidget(m_sortOrder, 2, 1);
|
||||
propsBoxLayout->addWidget(m_showHiddenFiles, 3, 0);
|
||||
|
||||
// create 'Apply view properties to:' group
|
||||
QGroupBox* buttonBox = new QGroupBox(i18n("Apply view properties to:"), main);
|
||||
m_applyToCurrentFolder = new QRadioButton(i18n("Current folder"), buttonBox);
|
||||
m_applyToSubFolders = new QRadioButton(i18n("Current folder including all sub folders"), buttonBox);
|
||||
m_applyToAllFolders = new QRadioButton(i18n("All folders"), buttonBox);
|
||||
|
||||
QVBoxLayout* buttonBoxLayout = new QVBoxLayout();
|
||||
buttonBoxLayout->addWidget(m_applyToCurrentFolder);
|
||||
buttonBoxLayout->addWidget(m_applyToSubFolders);
|
||||
buttonBoxLayout->addWidget(m_applyToAllFolders);
|
||||
buttonBox->setLayout(buttonBoxLayout);
|
||||
|
||||
m_applyToCurrentFolder->setChecked(true);
|
||||
|
||||
m_applyToSubFolders = new QCheckBox(i18n("Apply changes to all sub folders"), main);
|
||||
topLayout->addWidget(propsBox);
|
||||
topLayout->addWidget(buttonBox);
|
||||
topLayout->addWidget(m_applyToSubFolders);
|
||||
|
||||
connect(m_viewMode, SIGNAL(activated(int)),
|
||||
this, SLOT(slotViewModeChanged(int)));
|
||||
|
@ -124,12 +111,9 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
this, SLOT(slotSortOrderChanged(int)));
|
||||
connect(m_showHiddenFiles, SIGNAL(clicked()),
|
||||
this, SLOT(slotShowHiddenFilesChanged()));
|
||||
connect(m_applyToCurrentFolder, SIGNAL(clicked()),
|
||||
this, SLOT(markAsDirty()));
|
||||
|
||||
connect(m_applyToSubFolders, SIGNAL(clicked()),
|
||||
this, SLOT(markAsDirty()));
|
||||
connect(m_applyToAllFolders, SIGNAL(clicked()),
|
||||
this, SLOT(markAsDirty()));
|
||||
|
||||
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
|
||||
connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
|
||||
|
@ -196,29 +180,17 @@ void ViewPropertiesDialog::markAsDirty()
|
|||
|
||||
void ViewPropertiesDialog::applyViewProperties()
|
||||
{
|
||||
if (m_applyToAllFolders->isChecked()) {
|
||||
if (m_isDirty) {
|
||||
const QString text(i18n("The view properties of all folders will be replaced. Do you want to continue?"));
|
||||
if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//ViewProperties props(QDir::homePath());
|
||||
//props.setViewMode(m_viewProps->viewMode());
|
||||
//props.setSorting(m_viewProps->sorting());
|
||||
//props.setSortOrder(m_viewProps->sortOrder());
|
||||
//props.setShowHiddenFilesEnabled(m_viewProps->isShowHiddenFilesEnabled());
|
||||
//props.setValidForSubDirs(true);
|
||||
}
|
||||
else if (m_applyToSubFolders->isChecked() && m_isDirty) {
|
||||
const QString text(i18n("The view properties of all sub folders will be replaced. Do you want to continue?"));
|
||||
if (m_applyToSubFolders->isChecked() && m_isDirty) {
|
||||
const QString text(i18n("The view properties of all sub folders will be changed. Do you want to continue?"));
|
||||
if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) {
|
||||
return;
|
||||
}
|
||||
|
||||
ViewPropsProgressInfo dlg(this, m_dolphinView->url(), m_viewProps);
|
||||
dlg.exec();
|
||||
ViewPropsProgressInfo* info = new ViewPropsProgressInfo(m_dolphinView,
|
||||
m_dolphinView->url(),
|
||||
*m_viewProps);
|
||||
info->setWindowModality(Qt::NonModal);
|
||||
info->show();
|
||||
}
|
||||
|
||||
m_viewProps->save();
|
||||
|
|
|
@ -34,8 +34,6 @@ class DolphinView;
|
|||
* It is possible to specify the view mode and whether hidden files
|
||||
* should be shown. The properties can be assigned to the current folder,
|
||||
* recursively to all sub folders or to all folders.
|
||||
*
|
||||
* @author Peter Penz
|
||||
*/
|
||||
class ViewPropertiesDialog : public KDialog
|
||||
{
|
||||
|
@ -63,9 +61,7 @@ private:
|
|||
QComboBox* m_sorting;
|
||||
QComboBox* m_sortOrder;
|
||||
QCheckBox* m_showHiddenFiles;
|
||||
QRadioButton* m_applyToCurrentFolder;
|
||||
QRadioButton* m_applyToSubFolders;
|
||||
QRadioButton* m_applyToAllFolders;
|
||||
QCheckBox* m_applyToSubFolders;
|
||||
|
||||
void applyViewProperties();
|
||||
};
|
||||
|
|
|
@ -34,10 +34,10 @@
|
|||
|
||||
ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
|
||||
const KUrl& dir,
|
||||
const ViewProperties* viewProps) :
|
||||
const ViewProperties& viewProps) :
|
||||
KDialog(parent),
|
||||
m_dir(dir),
|
||||
m_viewProps(viewProps),
|
||||
m_viewProps(0),
|
||||
m_label(0),
|
||||
m_progressBar(0),
|
||||
m_dirSizeJob(0),
|
||||
|
@ -47,6 +47,16 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
|
|||
setCaption(i18n("Applying view properties"));
|
||||
setButtons(KDialog::Cancel);
|
||||
|
||||
m_viewProps = new ViewProperties(dir);
|
||||
m_viewProps->setViewMode(viewProps.viewMode());
|
||||
m_viewProps->setShowHiddenFilesEnabled(viewProps.isShowHiddenFilesEnabled());
|
||||
m_viewProps->setSorting(viewProps.sorting());
|
||||
m_viewProps->setSortOrder(viewProps.sortOrder());
|
||||
|
||||
// the view properties are stored by the ViewPropsApplierJob, so prevent
|
||||
// that the view properties are saved twice:
|
||||
m_viewProps->setAutoSaveEnabled(false);
|
||||
|
||||
QWidget* main = new QWidget();
|
||||
QVBoxLayout* topLayout = new QVBoxLayout();
|
||||
|
||||
|
@ -78,8 +88,16 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
|
|||
}
|
||||
|
||||
ViewPropsProgressInfo::~ViewPropsProgressInfo()
|
||||
{
|
||||
delete m_viewProps;
|
||||
m_viewProps = 0;
|
||||
}
|
||||
|
||||
void ViewPropsProgressInfo::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
m_timer->stop();
|
||||
m_applyViewPropsJob = 0;
|
||||
KDialog::closeEvent(event);
|
||||
}
|
||||
|
||||
void ViewPropsProgressInfo::updateProgress()
|
||||
|
@ -88,8 +106,8 @@ void ViewPropsProgressInfo::updateProgress()
|
|||
const int subdirs = m_dirSizeJob->totalSubdirs();
|
||||
m_label->setText(i18n("Counting folders: %1", subdirs));
|
||||
}
|
||||
else {
|
||||
assert(m_applyViewPropsJob != 0);
|
||||
|
||||
if (m_applyViewPropsJob != 0) {
|
||||
const int progress = m_applyViewPropsJob->progress();
|
||||
m_progressBar->setValue(progress);
|
||||
}
|
||||
|
@ -117,8 +135,8 @@ void ViewPropsProgressInfo::cancelApplying()
|
|||
if (m_dirSizeJob != 0) {
|
||||
m_dirSizeJob->doKill();
|
||||
}
|
||||
else {
|
||||
assert(m_applyViewPropsJob != 0);
|
||||
|
||||
if (m_applyViewPropsJob != 0) {
|
||||
m_applyViewPropsJob->doKill();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,10 +52,13 @@ public:
|
|||
*/
|
||||
ViewPropsProgressInfo(QWidget* parent,
|
||||
const KUrl& dir,
|
||||
const ViewProperties* viewProps);
|
||||
const ViewProperties& viewProps);
|
||||
|
||||
virtual ~ViewPropsProgressInfo();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
|
||||
private slots:
|
||||
void updateProgress();
|
||||
void applyViewProperties();
|
||||
|
@ -63,7 +66,7 @@ private slots:
|
|||
|
||||
private:
|
||||
const KUrl& m_dir;
|
||||
const ViewProperties* m_viewProps;
|
||||
ViewProperties* m_viewProps;
|
||||
|
||||
QLabel* m_label;
|
||||
QProgressBar* m_progressBar;
|
||||
|
|
Loading…
Reference in New Issue
Block a user