]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'ivan/dolphin-activities'
authorIvan Čukić <ivan.cukic@kde.org>
Wed, 15 Aug 2012 06:24:17 +0000 (08:24 +0200)
committerIvan Čukić <ivan.cukic@kde.org>
Wed, 15 Aug 2012 06:25:24 +0000 (08:25 +0200)
REVIEW:105973

15 files changed:
src/CMakeLists.txt
src/dolphinmainwindow.cpp
src/kitemviews/kfileitemlistwidget.cpp
src/kitemviews/kfileitemlistwidget.h
src/kitemviews/kstandarditemlistwidget.cpp
src/kitemviews/kstandarditemlistwidget.h
src/panels/folders/foldersitemlistwidget.cpp [new file with mode: 0644]
src/panels/folders/foldersitemlistwidget.h [new file with mode: 0644]
src/panels/folders/folderspanel.cpp
src/panels/places/placesitemlistwidget.cpp
src/panels/places/placesitemlistwidget.h
src/settings/viewmodes/viewsettingstab.cpp
src/settings/viewmodes/viewsettingstab.h
src/views/dolphinitemlistview.cpp
src/views/renamedialog.cpp

index 2ab6e5e33c375e7f2c0ce77c2e586ac01d9c5d86..8ade48777b1eec43d983fbe6d665c06d968ed777 100644 (file)
@@ -165,6 +165,7 @@ set(dolphin_SRCS
     panels/places/placesitemmodel.cpp
     panels/places/placesitemsignalhandler.cpp
     panels/panel.cpp
+    panels/folders/foldersitemlistwidget.cpp
     panels/folders/treeviewcontextmenu.cpp
     panels/folders/folderspanel.cpp
     search/dolphinfacetswidget.cpp
index 1ce51935f7b638cfeabec8b2565b58d5367f90c4..f3d23d6862236c6726587f96a98508ba981ee751 100644 (file)
@@ -434,7 +434,7 @@ void DolphinMainWindow::updateFilterBarAction(bool show)
 
 void DolphinMainWindow::openNewMainWindow()
 {
-    KRun::run("dolphin", KUrl::List(), this);
+    KRun::run("dolphin %u", KUrl::List(), this);
 }
 
 void DolphinMainWindow::openNewTab()
@@ -545,7 +545,7 @@ void DolphinMainWindow::openInNewWindow()
     }
 
     if (!newWindowUrl.isEmpty()) {
-        KRun::run("dolphin", KUrl::List() << newWindowUrl, this);
+        KRun::run("dolphin %u", KUrl::List() << newWindowUrl, this);
     }
 }
 
@@ -1299,7 +1299,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
 
     switch (command) {
     case DolphinContextMenu::OpenParentFolderInNewWindow: {
-        KRun::run("dolphin", KUrl::List() << item.url().upUrl(), this);
+        KRun::run("dolphin %u", KUrl::List() << item.url().upUrl(), this);
         break;
     }
 
@@ -1560,12 +1560,12 @@ void DolphinMainWindow::setupActions()
 
     KToggleAction* editableLocation = actionCollection()->add<KToggleAction>("editable_location");
     editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
-    editableLocation->setShortcut(Qt::CTRL | Qt::Key_L);
+    editableLocation->setShortcut(Qt::Key_F6);
     connect(editableLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
 
     KAction* replaceLocation = actionCollection()->addAction("replace_location");
     replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
-    replaceLocation->setShortcut(Qt::Key_F6);
+    replaceLocation->setShortcut(Qt::CTRL | Qt::Key_L);
     connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation()));
 
     // setup 'Go' menu
index c99da383fcc13298e3240a6eb3dba6aab34343fa..3a7724134373a9e21c935d996515cd6b3aea8a33 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "kfileitemlistwidget.h"
 
+#include <kmimetype.h>
 #include <KDebug>
 #include <KGlobal>
 #include <KLocale>
@@ -101,4 +102,34 @@ QFont KFileItemListWidget::customizedFont(const QFont& baseFont) const
     return font;
 }
 
+int KFileItemListWidget::selectionLength(const QString& text) const
+{
+    // Select the text without MIME-type extension
+    int selectionLength = text.length();
+
+    // If item is a directory, use the whole text length for
+    // selection (ignore all points)
+    if(data().value("isDir").toBool()) {
+        return selectionLength;
+    }
+
+    const QString extension = KMimeType::extractKnownExtension(text);
+    if (extension.isEmpty()) {
+        // For an unknown extension just exclude the extension after
+        // the last point. This does not work for multiple extensions like
+        // *.tar.gz but usually this is anyhow a known extension.
+        selectionLength = text.lastIndexOf(QLatin1Char('.'));
+
+        // If no point could be found, use whole text length for selection.
+        if (selectionLength < 1) {
+            selectionLength = text.length();
+        }
+
+    } else {
+        selectionLength -= extension.length() + 1;
+    }
+
+    return selectionLength;
+}
+
 #include "kfileitemlistwidget.moc"
index b0d8e1cd7e4f94bc674bd3de772357d4b8afe988..24c6778281773823122836a16830a1153bc2f7af 100644 (file)
@@ -48,6 +48,11 @@ protected:
     virtual bool isRoleRightAligned(const QByteArray& role) const;
     virtual bool isHidden() const;
     virtual QFont customizedFont(const QFont& baseFont) const;
+
+    /**
+     * @return Selection length without MIME-type extension
+     */
+    virtual int selectionLength(const QString& text) const;
 };
 
 #endif
index 5b0a0b7412314f164207c98713153df86009c03d..69c5602c77378601cba2516f659f51122d33c1ca 100644 (file)
@@ -464,6 +464,11 @@ QFont KStandardItemListWidget::customizedFont(const QFont& baseFont) const
     return baseFont;
 }
 
+QPalette::ColorRole KStandardItemListWidget::normalTextColorPalette() const
+{
+    return QPalette::Text;
+}
+
 void KStandardItemListWidget::setTextColor(const QColor& color)
 {
     if (color != m_customTextColor) {
@@ -480,7 +485,7 @@ QColor KStandardItemListWidget::textColor() const
     }
 
     const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
-    const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : QPalette::Text;
+    const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : normalTextColorPalette();
     return styleOption().palette.brush(group, role).color();
 }
 
@@ -576,6 +581,11 @@ void KStandardItemListWidget::siblingsInformationChanged(const QBitArray& curren
     m_dirtyLayout = true;
 }
 
+int KStandardItemListWidget::selectionLength(const QString& text) const
+{
+    return text.length();
+}
+
 void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const QByteArray& previous)
 {
     Q_UNUSED(previous);
@@ -605,25 +615,12 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
     QTextOption textOption = textInfo->staticText.textOption();
     m_roleEditor->document()->setDefaultTextOption(textOption);
 
-    // Select the text without MIME-type extension
-    // TODO: This is file-item-specific and should be moved
-    // into KFileItemListWidget.
-    int selectionLength = text.length();
-
-    const QString extension = KMimeType::extractKnownExtension(text);
-    if (extension.isEmpty()) {
-        // For an unknown extension just exclude the extension after
-        // the last point. This does not work for multiple extensions like
-        // *.tar.gz but usually this is anyhow a known extension.
-        selectionLength = text.lastIndexOf(QLatin1Char('.'));
-    } else {
-        selectionLength -= extension.length() + 1;
-    }
+    const int textSelectionLength = selectionLength(text);
 
-    if (selectionLength > 0) {
+    if (textSelectionLength > 0) {
         QTextCursor cursor = m_roleEditor->textCursor();
         cursor.movePosition(QTextCursor::StartOfBlock);
-        cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, selectionLength);
+        cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, textSelectionLength);
         m_roleEditor->setTextCursor(cursor);
     }
 
@@ -1037,7 +1034,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
                 const QString elidedText = m_customizedFontMetrics.elidedText(text, Qt::ElideRight, maxWidth);
                 textInfo->staticText.setText(elidedText);
                 requiredWidth = m_customizedFontMetrics.width(elidedText);
-            } else if (role == "rating") { 
+            } else if (role == "rating") {
                // Use the width of the rating pixmap, because the rating text is empty.
                 requiredWidth = m_rating.width();
             }
index 222d7b5f491b271482281fd1d01a25d45532aab7..462d83d0fad1b8b8785ffff9aa0f7971164582c7 100644 (file)
@@ -120,6 +120,8 @@ protected:
      */
     virtual QFont customizedFont(const QFont& baseFont) const;
 
+    virtual QPalette::ColorRole normalTextColorPalette() const;
+
     void setTextColor(const QColor& color);
     QColor textColor() const;
 
@@ -131,6 +133,19 @@ protected:
      */
     QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const;
 
+    /**
+     * Fixes:
+     * Select the text without MIME-type extension
+     * This is file-item-specific and should be moved
+     * into KFileItemListWidget.
+     *
+     * Inherited classes can define, if the MIME-type extension
+     * should be selected or not.
+     *
+     * @return Selection length (with or without MIME-type extension)
+     */
+    virtual int selectionLength(const QString& text) const;
+
     virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>());
     virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
     virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
diff --git a/src/panels/folders/foldersitemlistwidget.cpp b/src/panels/folders/foldersitemlistwidget.cpp
new file mode 100644 (file)
index 0000000..5130592
--- /dev/null
@@ -0,0 +1,36 @@
+/***************************************************************************
+ *  Copyright (C) 2012 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com>*
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "foldersitemlistwidget.h"
+
+FoldersItemListWidget::FoldersItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
+    KFileItemListWidget(informant, parent)
+{
+}
+
+FoldersItemListWidget::~FoldersItemListWidget()
+{
+}
+
+QPalette::ColorRole FoldersItemListWidget::normalTextColorPalette() const
+{
+    return QPalette::WindowText;
+}
+
+#include "foldersitemlistwidget.moc"
diff --git a/src/panels/folders/foldersitemlistwidget.h b/src/panels/folders/foldersitemlistwidget.h
new file mode 100644 (file)
index 0000000..fa7b143
--- /dev/null
@@ -0,0 +1,42 @@
+/***************************************************************************
+ *  Copyright (C) 2012 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com>*
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef FOLDERSITEMLISTWIDGET_H
+#define FOLDERSITEMLISTWIDGET_H
+
+#include <kitemviews/kfileitemlistwidget.h>
+
+/**
+ * @brief Extends KFileItemListWidget to use the right text color.
+*/
+class FoldersItemListWidget : public KFileItemListWidget
+{
+    Q_OBJECT
+
+public:
+    FoldersItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent);
+    virtual ~FoldersItemListWidget();
+
+protected:
+    virtual QPalette::ColorRole normalTextColorPalette() const;
+};
+
+#endif
+
+
index 78e437a418f32f3dfb9fd572f0e0f2736195bd87..0760200b63098ebad8be35d39dc657bf7e1bf9f2 100644 (file)
@@ -22,6 +22,7 @@
 #include "dolphin_folderspanelsettings.h"
 #include "dolphin_generalsettings.h"
 #include "treeviewcontextmenu.h"
+#include "foldersitemlistwidget.h"
 
 #include <kitemviews/kitemlistselectionmanager.h>
 #include <kitemviews/kfileitemlistview.h>
@@ -120,6 +121,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
         // This assures that no performance and memory overhead is given when the folders panel is not
         // used at all and stays invisible.
         KFileItemListView* view  = new KFileItemListView();
+        view->setWidgetCreator(new KItemListWidgetCreator<FoldersItemListWidget>());
         view->setSupportsItemExpanding(true);
         // Set the opacity to 0 initially. The opacity will be increased after the loading of the initial tree
         // has been finished in slotLoadingCompleted(). This prevents an unnecessary animation-mess when
index 24c2b3f11ff924ccc23d41933782529f1047c193..00f0fdab060a7c3b60855b0df8f77a83855ccdaa 100644 (file)
@@ -35,4 +35,9 @@ bool PlacesItemListWidget::isHidden() const
     return data().value("isHidden").toBool();
 }
 
+QPalette::ColorRole PlacesItemListWidget::normalTextColorPalette() const
+{
+    return QPalette::WindowText;
+}
+
 #include "placesitemlistwidget.moc"
index d7a4f3dddde42a8c8f7706937cc05f5402b2436d..93cd8f468c19ef30285da4950604e267ab814b81 100644 (file)
@@ -24,7 +24,7 @@
 
 /**
  * @brief Extends KStandardItemListWidget to interpret the hidden
- *        property of the PlacesModel.
+ *        property of the PlacesModel and use the right text color.
 */
 class PlacesItemListWidget : public KStandardItemListWidget
 {
@@ -36,6 +36,7 @@ public:
 
 protected:
     virtual bool isHidden() const;
+    virtual QPalette::ColorRole normalTextColorPalette() const;
 };
 
 #endif
index fe043a7884745db97b5f257c7a077f9ccc57508f..bc124516de5185ed807d07776a7edcb6bc760a0c 100644 (file)
@@ -32,6 +32,8 @@
 #include <QLabel>
 #include <QSlider>
 #include <QVBoxLayout>
+#include <QHelpEvent>
+#include <QApplication>
 
 #include <views/zoomlevelinfo.h>
 
@@ -59,12 +61,16 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
     m_defaultSizeSlider->setPageStep(1);
     m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow);
     m_defaultSizeSlider->setRange(minRange, maxRange);
+    connect(m_defaultSizeSlider, SIGNAL(valueChanged(int)),
+            this, SLOT(slotDefaultSliderMoved(int)));
 
     QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this);
     m_previewSizeSlider = new QSlider(Qt::Horizontal, this);
     m_previewSizeSlider->setPageStep(1);
     m_previewSizeSlider->setTickPosition(QSlider::TicksBelow);
     m_previewSizeSlider->setRange(minRange, maxRange);
+    connect(m_previewSizeSlider, SIGNAL(valueChanged(int)),
+            this, SLOT(slotPreviewSliderMoved(int)));
 
     QGridLayout* layout = new QGridLayout(iconSizeGroup);
     layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight);
@@ -261,4 +267,26 @@ ViewModeSettings::ViewMode ViewSettingsTab::viewMode() const
 }
 
 
+void ViewSettingsTab::slotDefaultSliderMoved(int value)
+{
+    showToolTip(m_defaultSizeSlider, value);
+}
+
+void ViewSettingsTab::slotPreviewSliderMoved(int value)
+{
+    showToolTip(m_previewSizeSlider, value);
+}
+
+void ViewSettingsTab::showToolTip(QSlider* slider, int value)
+{
+    const int size = ZoomLevelInfo::iconSizeForZoomLevel(value);
+    slider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size));
+    if (!slider->isVisible()) {
+        return;
+    }
+    QPoint global = slider->rect().topLeft();
+    global.ry() += slider->height() / 2;
+    QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), slider->mapToGlobal(global));
+    QApplication::sendEvent(slider, &toolTipEvent);
+}
 #include "viewsettingstab.moc"
index 2115da1bc52e1e5890c08cb58ffcfdd17c9a9968..6bea95b903c3a921b310e829ff7dab4ef9562357 100644 (file)
@@ -52,8 +52,13 @@ public:
 signals:
     void changed();
 
+private slots:
+
+    void slotDefaultSliderMoved(int value);
+    void slotPreviewSliderMoved(int value);
 private:
     void loadSettings();
+    void showToolTip(QSlider* slider, int value);
 
     ViewModeSettings::ViewMode viewMode() const;
 
index a031b1699f9e4bee94eea38b308cc113dca16c54..039b5f230ba7acc95d31f5d7072cefc6dc7a12ad 100644 (file)
@@ -90,7 +90,7 @@ void DolphinItemListView::readSettings()
 
     setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
 
-    const bool expandableFolders = (itemLayout() && KFileItemListView::DetailsLayout) &&
+    const bool expandableFolders = (itemLayout() == KFileItemListView::DetailsLayout) &&
                                    DetailsModeSettings::expandableFolders();
     setSupportsItemExpanding(expandableFolders);
 
index e232b9614a075c0a10c868aaf82919d77f2e4a19..a91f91b1b431246ad6e04cfc28c59d6f615bdf82 100644 (file)
@@ -87,7 +87,9 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
     if (m_renameOneItem) {
         const QString fileName = items.first().url().prettyUrl();
         const QString extension = KMimeType::extractKnownExtension(fileName.toLower());
-        if (extension.length() > 0) {
+
+        // If the current item is a directory, select the whole file name.
+        if ((extension.length() > 0) && !items.first().isDir()) {
             // Don't select the extension
             selectionLength -= extension.length() + 1;
         }