added context menu actions to open client and project folder for project selection.
This commit is contained in:
@@ -211,7 +211,7 @@ void NoggitProjectSelectionWindow::handleContextMenuProjectListItemForget(std::s
|
|||||||
prompt.setWindowTitle("Forget Project");
|
prompt.setWindowTitle("Forget Project");
|
||||||
prompt.setIcon(QMessageBox::Warning);
|
prompt.setIcon(QMessageBox::Warning);
|
||||||
prompt.setWindowFlags(Qt::WindowStaysOnTopHint);
|
prompt.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
prompt.setText("Data on the disk will not be removed. Continue?.");
|
prompt.setText("Data on the disk will not be removed, this action will only hide the project. Continue?.");
|
||||||
prompt.addButton("Accept", QMessageBox::AcceptRole);
|
prompt.addButton("Accept", QMessageBox::AcceptRole);
|
||||||
prompt.setDefaultButton(prompt.addButton("Cancel", QMessageBox::RejectRole));
|
prompt.setDefaultButton(prompt.addButton("Cancel", QMessageBox::RejectRole));
|
||||||
prompt.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
prompt.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
using namespace Noggit::Ui::Component;
|
using namespace Noggit::Ui::Component;
|
||||||
|
|
||||||
@@ -72,7 +73,27 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi
|
|||||||
});
|
});
|
||||||
|
|
||||||
context_menu.addAction(&action_2);
|
context_menu.addAction(&action_2);
|
||||||
|
/////
|
||||||
|
QAction action_3("Open Project Directory", project_list_item);
|
||||||
|
action_3.setIcon(FontAwesomeIcon(FontAwesome::folderopen).pixmap(QSize(16, 16)));
|
||||||
|
|
||||||
|
QObject::connect(&action_3, &QAction::triggered, [=]()
|
||||||
|
{
|
||||||
|
openDirectory(project_data.project_directory.toStdString());
|
||||||
|
});
|
||||||
|
|
||||||
|
context_menu.addAction(&action_3);
|
||||||
|
/////
|
||||||
|
QAction action_4("Open WoW Client Directory", project_list_item);
|
||||||
|
action_4.setIcon(FontAwesomeIcon(FontAwesome::gamepad).pixmap(QSize(16, 16)));
|
||||||
|
|
||||||
|
QObject::connect(&action_4, &QAction::triggered, [=]()
|
||||||
|
{
|
||||||
|
openDirectory(project->ClientPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
context_menu.addAction(&action_4);
|
||||||
|
/////
|
||||||
context_menu.exec(project_list_item->mapToGlobal(pos));
|
context_menu.exec(project_list_item->mapToGlobal(pos));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -84,6 +105,38 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi
|
|||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecentProjectsComponent::openDirectory(std::string const& directory_path)
|
||||||
|
{
|
||||||
|
if (!std::filesystem::exists(directory_path) || !std::filesystem::is_directory(directory_path))
|
||||||
|
return;
|
||||||
|
auto path = QString(directory_path.c_str());
|
||||||
|
QFileInfo info(path);
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
QStringList args;
|
||||||
|
if (!info.isDir())
|
||||||
|
args << "/select,";
|
||||||
|
args << QDir::toNativeSeparators(path);
|
||||||
|
if (QProcess::startDetached("explorer", args))
|
||||||
|
return;
|
||||||
|
#elif defined(Q_OS_MAC)
|
||||||
|
QStringList args;
|
||||||
|
args << "-e";
|
||||||
|
args << "tell application \"Finder\"";
|
||||||
|
args << "-e";
|
||||||
|
args << "activate";
|
||||||
|
args << "-e";
|
||||||
|
args << "select POSIX file \"" + path + "\"";
|
||||||
|
args << "-e";
|
||||||
|
args << "end tell";
|
||||||
|
args << "-e";
|
||||||
|
args << "return";
|
||||||
|
if (!QProcess::execute("/usr/bin/osascript", args))
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void RecentProjectsComponent::registerProjectChange(std::string const& project_path)
|
void RecentProjectsComponent::registerProjectChange(std::string const& project_path)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ namespace Noggit::Ui::Component
|
|||||||
static void buildRecentProjectsList(Noggit::Ui::Windows::NoggitProjectSelectionWindow* parent);
|
static void buildRecentProjectsList(Noggit::Ui::Windows::NoggitProjectSelectionWindow* parent);
|
||||||
static void registerProjectChange(std::string const& project_path);
|
static void registerProjectChange(std::string const& project_path);
|
||||||
static void registerProjectRemove(std::string const& project_path);
|
static void registerProjectRemove(std::string const& project_path);
|
||||||
|
private:
|
||||||
|
static void openDirectory(std::string const& directory_path);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user