Skip to content

Commit

Permalink
refacotr: [extesion] Uss the string local path
Browse files Browse the repository at this point in the history
For third-party url's with scheme the path is difficult to handle, for extensionlib its path parameter uses the local path string

Log: refacotr extesionlib
  • Loading branch information
Johnson-zs authored and deepin-bot[bot] committed Jul 25, 2023
1 parent 9121a0d commit 2837851
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions include/dfm-extension/menu/dfmextmenuplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class DFMExtMenuPlugin

DFM_FAKE_VIRTUAL void initialize(DFMEXT::DFMExtMenuProxy *proxy);
DFM_FAKE_VIRTUAL bool buildNormalMenu(DFMEXT::DFMExtMenu *main,
const std::string &currentUrl,
const std::string &focusUrl,
const std::list<std::string> &urlList,
const std::string &currentPath,
const std::string &focusPath,
const std::list<std::string> &pathList,
bool onDesktop);
DFM_FAKE_VIRTUAL bool buildEmptyAreaMenu(DFMEXT::DFMExtMenu *main, const std::string &currentUrl, bool onDesktop);
DFM_FAKE_VIRTUAL bool buildEmptyAreaMenu(DFMEXT::DFMExtMenu *main, const std::string &currentPath, bool onDesktop);

public:
void registerInitialize(const InitializeFunc &func);
Expand Down
12 changes: 6 additions & 6 deletions src/dfm-extension/menu/dfmextmenuplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ void DFMExtMenuPlugin::registerInitialize(const DFMExtMenuPlugin::InitializeFunc
}

bool DFMExtMenuPlugin::buildNormalMenu(DFMExtMenu *main,
const std::string &currentUrl,
const std::string &focusUrl,
const std::list<std::string> &urlList,
const std::string &currentPath,
const std::string &focusPath,
const std::list<std::string> &pathList,
bool onDesktop)
{
if (d->buildNormalMeunFunc)
return d->buildNormalMeunFunc(main, currentUrl, focusUrl, urlList, onDesktop);
return d->buildNormalMeunFunc(main, currentPath, focusPath, pathList, onDesktop);

return false;
}
Expand All @@ -54,10 +54,10 @@ void DFMExtMenuPlugin::registerBuildNormalMenu(const DFMExtMenuPlugin::BuildNorm
d->buildNormalMeunFunc = func;
}

bool DFMExtMenuPlugin::buildEmptyAreaMenu(DFMExtMenu *main, const std::string &currentUrl, bool onDesktop)
bool DFMExtMenuPlugin::buildEmptyAreaMenu(DFMExtMenu *main, const std::string &currentPath, bool onDesktop)
{
if (d->buildEmptyAreaMenuFunc)
return d->buildEmptyAreaMenuFunc(main, currentUrl, onDesktop);
return d->buildEmptyAreaMenuFunc(main, currentPath, onDesktop);

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ bool ExtensionLibMenuScene::create(QMenu *parent)
}

DFMExtMenuImpl *extMenuImpl { new DFMExtMenuImpl(parent) };
const std::string &newCurrentUrl { d->transformedCurrentDir.toString().toStdString() };
const std::string &newFocusUrl { d->transformedFocusFile.toString().toStdString() };
const std::string &newCurrentPath { d->transformedCurrentDir.toLocalFile().toStdString() };
const std::string &newFocusPath { d->transformedFocusFile.toLocalFile().toStdString() };

for (auto menu : ExtensionPluginManager::instance().menuPlugins()) {
menu->initialize(ExtensionPluginManager::instance().pluginMenuProxy());
if (d->isEmptyArea) {
menu->buildEmptyAreaMenu(extMenuImpl, newCurrentUrl, d->onDesktop);
menu->buildEmptyAreaMenu(extMenuImpl, newCurrentPath, d->onDesktop);
} else {
std::list<std::string> newSelectedFiles;
std::for_each(d->transformedSelectFiles.cbegin(), d->transformedSelectFiles.cend(), [&newSelectedFiles](const QUrl &url) {
newSelectedFiles.push_back(url.toString().toStdString());
std::list<std::string> newSelectedPaths;
std::for_each(d->transformedSelectFiles.cbegin(), d->transformedSelectFiles.cend(), [&newSelectedPaths](const QUrl &url) {
newSelectedPaths.push_back(url.toLocalFile().toStdString());
});
menu->buildNormalMenu(extMenuImpl, newCurrentUrl, newFocusUrl, newSelectedFiles, d->onDesktop);
menu->buildNormalMenu(extMenuImpl, newCurrentPath, newFocusPath, newSelectedPaths, d->onDesktop);
}
}

Expand Down

0 comments on commit 2837851

Please sign in to comment.