diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/dolphinmainwindow.cpp | 10 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.cpp | 31 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.h | 5 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.cpp | 33 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.h | 15 | ||||
| -rw-r--r-- | src/panels/folders/foldersitemlistwidget.cpp | 36 | ||||
| -rw-r--r-- | src/panels/folders/foldersitemlistwidget.h | 42 | ||||
| -rw-r--r-- | src/panels/folders/folderspanel.cpp | 2 | ||||
| -rw-r--r-- | src/panels/places/placesitemlistwidget.cpp | 5 | ||||
| -rw-r--r-- | src/panels/places/placesitemlistwidget.h | 3 | ||||
| -rw-r--r-- | src/settings/viewmodes/viewsettingstab.cpp | 28 | ||||
| -rw-r--r-- | src/settings/viewmodes/viewsettingstab.h | 5 | ||||
| -rw-r--r-- | src/views/dolphinitemlistview.cpp | 2 | ||||
| -rw-r--r-- | src/views/renamedialog.cpp | 4 |
15 files changed, 196 insertions, 26 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ab6e5e33..8ade48777 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 1ce51935f..f3d23d686 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -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 diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index c99da383f..3a7724134 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -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" diff --git a/src/kitemviews/kfileitemlistwidget.h b/src/kitemviews/kfileitemlistwidget.h index b0d8e1cd7..24c677828 100644 --- a/src/kitemviews/kfileitemlistwidget.h +++ b/src/kitemviews/kfileitemlistwidget.h @@ -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 diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 5b0a0b741..69c5602c7 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -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(); } diff --git a/src/kitemviews/kstandarditemlistwidget.h b/src/kitemviews/kstandarditemlistwidget.h index 222d7b5f4..462d83d0f 100644 --- a/src/kitemviews/kstandarditemlistwidget.h +++ b/src/kitemviews/kstandarditemlistwidget.h @@ -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 index 000000000..513059204 --- /dev/null +++ b/src/panels/folders/foldersitemlistwidget.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * Copyright (C) 2012 by Emmanuel Pescosta <[email protected]>* + * * + * 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 index 000000000..fa7b143ae --- /dev/null +++ b/src/panels/folders/foldersitemlistwidget.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2012 by Emmanuel Pescosta <[email protected]>* + * * + * 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 + + diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 78e437a41..0760200b6 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -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 diff --git a/src/panels/places/placesitemlistwidget.cpp b/src/panels/places/placesitemlistwidget.cpp index 24c2b3f11..00f0fdab0 100644 --- a/src/panels/places/placesitemlistwidget.cpp +++ b/src/panels/places/placesitemlistwidget.cpp @@ -35,4 +35,9 @@ bool PlacesItemListWidget::isHidden() const return data().value("isHidden").toBool(); } +QPalette::ColorRole PlacesItemListWidget::normalTextColorPalette() const +{ + return QPalette::WindowText; +} + #include "placesitemlistwidget.moc" diff --git a/src/panels/places/placesitemlistwidget.h b/src/panels/places/placesitemlistwidget.h index d7a4f3ddd..93cd8f468 100644 --- a/src/panels/places/placesitemlistwidget.h +++ b/src/panels/places/placesitemlistwidget.h @@ -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 diff --git a/src/settings/viewmodes/viewsettingstab.cpp b/src/settings/viewmodes/viewsettingstab.cpp index fe043a788..bc124516d 100644 --- a/src/settings/viewmodes/viewsettingstab.cpp +++ b/src/settings/viewmodes/viewsettingstab.cpp @@ -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" diff --git a/src/settings/viewmodes/viewsettingstab.h b/src/settings/viewmodes/viewsettingstab.h index 2115da1bc..6bea95b90 100644 --- a/src/settings/viewmodes/viewsettingstab.h +++ b/src/settings/viewmodes/viewsettingstab.h @@ -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; diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index a031b1699..039b5f230 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -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); diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp index e232b9614..a91f91b1b 100644 --- a/src/views/renamedialog.cpp +++ b/src/views/renamedialog.cpp @@ -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; } |
