From 9a9ab6e50cbfaee56a3d3b84ed7bea2f987985df Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Tue, 25 Feb 2014 19:38:57 +0100 Subject: [PATCH 1/2] Fix Bug 330605 - Dropbox plugin prevents git plugin from working Use scoring to find the best matching plugin for the given directory. Thanks to Phil Schaf for testing this patch! BUG: 330605 FIXED-IN: 4.12.3 REVIEW: 116019 --- .../versioncontrol/versioncontrolobserver.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp index 4d939ee0df..769c290f91 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -322,11 +322,18 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director } } + // We use the number of upUrl() calls to find the best matching plugin + // for the given directory. The smaller value, the better it is (0 is best). + KVersionControlPlugin* bestPlugin = 0; + int bestScore = INT_MAX; + // Verify whether the current directory contains revision information // like .svn, .git, ... foreach (KVersionControlPlugin* plugin, plugins) { const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName(); if (QFile::exists(fileName)) { + // The score of this plugin is 0 (best), so we can just return this plugin, + // instead of going through the plugin scoring procedure, we can't find a better one ;) return plugin; } @@ -339,18 +346,24 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director if (m_versionedDirectory) { KUrl dirUrl(directory); KUrl upUrl = dirUrl.upUrl(); - while (upUrl != dirUrl) { + int upUrlCounter = 1; + while ((upUrlCounter < bestScore) && (upUrl != dirUrl)) { const QString fileName = dirUrl.path(KUrl::AddTrailingSlash) + plugin->fileName(); if (QFile::exists(fileName)) { - return plugin; + if (upUrlCounter < bestScore) { + bestPlugin = plugin; + bestScore = upUrlCounter; + } + break; } dirUrl = upUrl; upUrl = dirUrl.upUrl(); + ++upUrlCounter; } } } - return 0; + return bestPlugin; } bool VersionControlObserver::isVersioned() const From c5d9791ad392efffa19108c3ce7a4e6a67453a09 Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Tue, 25 Feb 2014 19:41:45 +0100 Subject: [PATCH 2/2] Show the correct icon size in the zoom slider tooltip. BUG: 305694 FIXED-IN: 4.12.3 REVIEW: 111197 --- src/statusbar/dolphinstatusbar.cpp | 14 +++++++------- src/statusbar/dolphinstatusbar.h | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/statusbar/dolphinstatusbar.cpp b/src/statusbar/dolphinstatusbar.cpp index 671ef4f961..169395e633 100644 --- a/src/statusbar/dolphinstatusbar.cpp +++ b/src/statusbar/dolphinstatusbar.cpp @@ -73,6 +73,7 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) : m_zoomSlider->setRange(ZoomLevelInfo::minimumLevel(), ZoomLevelInfo::maximumLevel()); connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SIGNAL(zoomLevelChanged(int))); + connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(updateZoomSliderToolTip(int))); connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(showZoomSliderToolTip(int))); // Initialize space information @@ -240,7 +241,6 @@ void DolphinStatusBar::setZoomLevel(int zoomLevel) { if (zoomLevel != m_zoomSlider->value()) { m_zoomSlider->setValue(zoomLevel); - updateZoomSliderToolTip(zoomLevel); } } @@ -338,6 +338,12 @@ void DolphinStatusBar::slotResetToDefaultText() updateLabelText(); } +void DolphinStatusBar::updateZoomSliderToolTip(int zoomLevel) +{ + const int size = ZoomLevelInfo::iconSizeForZoomLevel(zoomLevel); + m_zoomSlider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size)); +} + void DolphinStatusBar::setExtensionsVisible(bool visible) { bool showSpaceInfo = visible; @@ -350,10 +356,4 @@ void DolphinStatusBar::setExtensionsVisible(bool visible) m_zoomSlider->setVisible(showZoomSlider); } -void DolphinStatusBar::updateZoomSliderToolTip(int zoomLevel) -{ - const int size = ZoomLevelInfo::iconSizeForZoomLevel(zoomLevel); - m_zoomSlider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size)); -} - #include "dolphinstatusbar.moc" diff --git a/src/statusbar/dolphinstatusbar.h b/src/statusbar/dolphinstatusbar.h index b2afe2eb9f..4d6dbb20fb 100644 --- a/src/statusbar/dolphinstatusbar.h +++ b/src/statusbar/dolphinstatusbar.h @@ -122,6 +122,12 @@ private slots: */ void slotResetToDefaultText(); + /** + * Updates the text of the zoom slider tooltip to show + * the currently used size. + */ + void updateZoomSliderToolTip(int zoomLevel); + private: /** * Makes the space information widget and zoom slider widget @@ -131,12 +137,6 @@ private: */ void setExtensionsVisible(bool visible); - /** - * Updates the text of the zoom slider tooltip to show - * the currently used size. - */ - void updateZoomSliderToolTip(int zoomLevel); - private: QString m_text; QString m_defaultText;