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
void DolphinMainWindow::openNewMainWindow()
{
- KRun::run("dolphin", KUrl::List(), this);
+ KRun::run("dolphin %u", KUrl::List(), this);
}
void DolphinMainWindow::openNewTab()
}
if (!newWindowUrl.isEmpty()) {
- KRun::run("dolphin", KUrl::List() << newWindowUrl, this);
+ KRun::run("dolphin %u", KUrl::List() << newWindowUrl, this);
}
}
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;
}
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
#include "kfileitemlistwidget.h"
+#include <kmimetype.h>
#include <KDebug>
#include <KGlobal>
#include <KLocale>
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"
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
return baseFont;
}
+QPalette::ColorRole KStandardItemListWidget::normalTextColorPalette() const
+{
+ return QPalette::Text;
+}
+
void KStandardItemListWidget::setTextColor(const QColor& color)
{
if (color != m_customTextColor) {
}
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();
}
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);
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);
}
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();
}
*/
virtual QFont customizedFont(const QFont& baseFont) const;
+ virtual QPalette::ColorRole normalTextColorPalette() const;
+
void setTextColor(const QColor& color);
QColor textColor() const;
*/
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);
--- /dev/null
+/***************************************************************************
+ * 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"
--- /dev/null
+/***************************************************************************
+ * 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
+
+
#include "dolphin_folderspanelsettings.h"
#include "dolphin_generalsettings.h"
#include "treeviewcontextmenu.h"
+#include "foldersitemlistwidget.h"
#include <kitemviews/kitemlistselectionmanager.h>
#include <kitemviews/kfileitemlistview.h>
// 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
return data().value("isHidden").toBool();
}
+QPalette::ColorRole PlacesItemListWidget::normalTextColorPalette() const
+{
+ return QPalette::WindowText;
+}
+
#include "placesitemlistwidget.moc"
/**
* @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
{
protected:
virtual bool isHidden() const;
+ virtual QPalette::ColorRole normalTextColorPalette() const;
};
#endif
#include <QLabel>
#include <QSlider>
#include <QVBoxLayout>
+#include <QHelpEvent>
+#include <QApplication>
#include <views/zoomlevelinfo.h>
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);
}
+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"
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;
setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
- const bool expandableFolders = (itemLayout() && KFileItemListView::DetailsLayout) &&
+ const bool expandableFolders = (itemLayout() == KFileItemListView::DetailsLayout) &&
DetailsModeSettings::expandableFolders();
setSupportsItemExpanding(expandableFolders);
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;
}