[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/apps
From: David Faure <faure () kde ! org>
Date: 2009-11-18 22:27:32
Message-ID: 1258583252.267770.18300.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1051124 by dfaure:
Warn when the unsuspecting user is about to create a directory that starts with a \
dot, like Sabine's ".csv test files" folder, which did not appear in the directory \
view after being created.
M +4 -0 dolphin/src/dolphincontextmenu.cpp
M +3 -1 dolphin/src/dolphinmainwindow.cpp
M +2 -0 dolphin/src/dolphinpart.cpp
M +12 -2 lib/konq/knewmenu.cpp
M +7 -0 lib/konq/knewmenu.h
M +47 -18 lib/konq/konq_operations.cpp
M +12 -0 lib/konq/konq_operations.h
--- trunk/KDE/kdebase/apps/dolphin/src/dolphincontextmenu.cpp #1051123:1051124
@@ -189,6 +189,8 @@
if (m_fileInfo.isDir() && (m_selectedUrls.count() == 1)) {
// setup 'Create New' menu
DolphinNewMenu* newMenu = new DolphinNewMenu(popup, m_mainWindow);
+ const DolphinView* view = m_mainWindow->activeViewContainer()->view();
+ newMenu->setViewShowsHiddenFiles(view->showHiddenFiles());
newMenu->slotCheckUpToDate();
newMenu->setPopupFiles(m_fileInfo.url());
newMenu->setEnabled(capabilities().supportsWriting());
@@ -268,6 +270,8 @@
// setup 'Create New' menu
KNewMenu* newMenu = m_mainWindow->newMenu();
+ const DolphinView* view = m_mainWindow->activeViewContainer()->view();
+ newMenu->setViewShowsHiddenFiles(view->showHiddenFiles());
newMenu->slotCheckUpToDate();
newMenu->setPopupFiles(m_baseUrl);
popup->addMenu(newMenu->menu());
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinmainwindow.cpp #1051123:1051124
@@ -552,12 +552,14 @@
void DolphinMainWindow::updateNewMenu()
{
+ m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
m_newMenu->slotCheckUpToDate();
m_newMenu->setPopupFiles(activeViewContainer()->url());
}
void DolphinMainWindow::createDirectory()
{
+ m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
m_newMenu->setPopupFiles(activeViewContainer()->url());
m_newMenu->createDirectory();
}
@@ -1658,7 +1660,7 @@
caption = url.protocol();
}
}
-
+
setCaption(caption);
}
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinpart.cpp #1051123:1051124
@@ -535,6 +535,7 @@
{
// As requested by KNewMenu :
m_newMenu->slotCheckUpToDate();
+ m_newMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
// And set the files that the menu apply on :
m_newMenu->setPopupFiles(url());
}
@@ -551,6 +552,7 @@
void DolphinPart::createDirectory()
{
+ m_newMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
m_newMenu->setPopupFiles(url());
m_newMenu->createDirectory();
}
--- trunk/KDE/kdebase/apps/lib/konq/knewmenu.cpp #1051123:1051124
@@ -112,7 +112,8 @@
{
public:
KNewMenuPrivate()
- : menuItemsVersion(0)
+ : menuItemsVersion(0),
+ viewShowsHiddenFiles(false)
{}
KActionCollection * m_actionCollection;
QWidget *m_parentWidget;
@@ -120,6 +121,7 @@
QAction* m_newDirAction;
int menuItemsVersion;
+ bool viewShowsHiddenFiles;
/**
* When the user pressed the right mouse button over an URL a popup menu
@@ -421,7 +423,10 @@
if (d->popupFiles.isEmpty())
return;
- KIO::SimpleJob* job = KonqOperations::newDir(d->m_parentWidget, \
d->popupFiles.first()); + KonqOperations::NewDirFlags newDirFlags;
+ if (d->viewShowsHiddenFiles)
+ newDirFlags |= KonqOperations::ViewShowsHiddenFile;
+ KIO::SimpleJob* job = KonqOperations::newDir(d->m_parentWidget, \
d->popupFiles.first(), newDirFlags); if (job) {
// We want the error handling to be done by slotResult so that subclasses \
can reimplement it job->ui()->setAutoErrorHandlingEnabled(false);
@@ -731,4 +736,9 @@
}
}
+void KNewMenu::setViewShowsHiddenFiles(bool b)
+{
+ d->viewShowsHiddenFiles = b;
+}
+
#include "knewmenu.moc"
--- trunk/KDE/kdebase/apps/lib/konq/knewmenu.h #1051123:1051124
@@ -64,6 +64,12 @@
virtual ~KNewMenu();
/**
+ * Set if the directory view currently shows dot files.
+ * @since 4.4
+ */
+ void setViewShowsHiddenFiles(bool b);
+
+ /**
* Set the files the popup is shown for
* Call this before showing up the menu
*/
@@ -73,6 +79,7 @@
/**
* Checks if updating the list is necessary
* IMPORTANT : Call this in the slot for aboutToShow.
+ * And while you're there, you probably want to call setViewShowsHiddenFiles ;)
*/
void slotCheckUpToDate();
--- trunk/KDE/kdebase/apps/lib/konq/konq_operations.cpp #1051123:1051124
@@ -807,30 +807,59 @@
rename( parent, oldurl, newurl );
}
-KIO::SimpleJob* KonqOperations::newDir( QWidget * parent, const KUrl & baseUrl )
+// Duplicated in libkfile's KDirOperator
+static bool confirmCreatingHiddenDir(const QString& name, QWidget* parent)
{
+ KGuiItem continueGuiItem(KStandardGuiItem::cont());
+ continueGuiItem.setText(i18nc("@action:button", "Create directory"));
+ KGuiItem cancelGuiItem(KStandardGuiItem::cancel());
+ cancelGuiItem.setText(i18nc("@action:button", "Enter a different name"));
+ return KMessageBox::warningContinueCancel(
+ parent,
+ i18n("The name \"%1\" starts with a dot and will therefore the directory \
will be hidden by default.", name), + i18n("Create hidden directory?"),
+ continueGuiItem,
+ cancelGuiItem,
+ "confirm_create_hidden_dir") == KMessageBox::Continue;
+}
+
+KIO::SimpleJob* KonqOperations::newDir(QWidget * parent, const KUrl & baseUrl)
+{
+ return newDir(parent, baseUrl, NewDirFlags());
+}
+
+KIO::SimpleJob* KonqOperations::newDir(QWidget * parent, const KUrl & baseUrl, \
NewDirFlags flags) +{
+ // Notice that kfile's KDirOperator::mkdir() is somewhat similar
bool ok;
QString name = i18n( "New Folder" );
if ( baseUrl.isLocalFile() && QFileInfo( baseUrl.toLocalFile( \
KUrl::AddTrailingSlash ) + name ).exists() )
- name = KIO::RenameDialog::suggestName( baseUrl, i18n( "New Folder" ) );
+ name = KIO::RenameDialog::suggestName(baseUrl, name);
- name = KInputDialog::getText ( i18n( "New Folder" ),
- i18n( "Enter folder name:" ), name, &ok, parent );
- if ( ok && !name.isEmpty() )
- {
- KUrl url;
- if ((name[0] == '/') || (name[0] == '~'))
- {
- url.setPath(KShell::tildeExpand(name));
+ bool askAgain;
+ do {
+ askAgain = false;
+ name = KInputDialog::getText ( i18n( "New Folder" ),
+ i18n( "Enter folder name:" ), name, &ok, \
parent ); + if ( ok && !name.isEmpty() ) {
+ KUrl url;
+ if ((name[0] == '/') || (name[0] == '~')) {
+ url.setPath(KShell::tildeExpand(name));
+ } else {
+ const bool viewShowsHiddenFiles = (flags & ViewShowsHiddenFile);
+ if (!viewShowsHiddenFiles && name.startsWith('.')) {
+ if (!confirmCreatingHiddenDir(name, parent)) {
+ askAgain = true;
+ continue;
+ }
+ }
+ name = KIO::encodeFileName( name );
+ url = baseUrl;
+ url.addPath( name );
+ }
+ return KonqOperations::mkdir( parent, url );
}
- else
- {
- name = KIO::encodeFileName( name );
- url = baseUrl;
- url.addPath( name );
- }
- return KonqOperations::mkdir( parent, url );
- }
+ } while (askAgain);
return 0;
}
--- trunk/KDE/kdebase/apps/lib/konq/konq_operations.h #1051123:1051124
@@ -149,6 +149,18 @@
* @return the job used to create the directory or 0 if the creation was \
cancelled by the user
*/
static KIO::SimpleJob* newDir( QWidget * parent, const KUrl & baseUrl );
+ enum NewDirFlag { ViewShowsHiddenFile = 1 };
+ Q_DECLARE_FLAGS(NewDirFlags, NewDirFlag)
+ /**
+ * Ask for the name of a new directory and create it.
+ * Calls KonqOperations::mkdir.
+ *
+ * @param parent the parent widget
+ * @param baseUrl the directory to create the new directory in
+ * @param flags see NewDirFlags
+ * @return the job used to create the directory or 0 if the creation was \
cancelled by the user + */
+ static KIO::SimpleJob* newDir( QWidget * parent, const KUrl & baseUrl, \
NewDirFlags flags );
/**
* Get info about a given URL, and when that's done (it's asynchronous!),
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic