|
|
@@ -1,5 +1,7 @@
|
|
|
#include <QMessageBox>
|
|
|
#include <QDesktopServices>
|
|
|
+#include <QFile>
|
|
|
+#include <QDir>
|
|
|
#include "ui_MainWindow.h"
|
|
|
#include "mainWindow.h"
|
|
|
#include "conflictModal.h"
|
|
|
@@ -18,19 +20,16 @@ MainWindow::MainWindow(const std::vector<std::string>& dirList)
|
|
|
ui->setupUi(window.get());
|
|
|
ui->listView->setModel(fileListItemModel.get());
|
|
|
ui->listView->setItemDelegate(new FileItemDelegate(this));
|
|
|
+ ui->listView->setContextMenuPolicy(Qt::ContextMenuPolicy::ActionsContextMenu);
|
|
|
ui->breadcrumb->setFixedHeight(36);
|
|
|
|
|
|
connect(ui->actionOuvrir, &QAction::triggered, this, &MainWindow::MenuBarActionTrigerred);
|
|
|
- connect(ui->listView, &QListView::doubleClicked, this, [this](const QModelIndex& index)
|
|
|
- {
|
|
|
- if (index.isValid() && currentDiffResult)
|
|
|
- {
|
|
|
- const auto& fileIter = currentDiffResult->FileList.find(qvariant_cast<QString>(index.data(Qt::DisplayRole)).toStdString());
|
|
|
- if (fileIter != currentDiffResult->FileList.end())
|
|
|
- OnListViewDoubleClick(fileIter->second);
|
|
|
- }
|
|
|
- });
|
|
|
+ connect(ui->listView, &QListView::doubleClicked, this, &MainWindow::FileListItemEntered);
|
|
|
connect(ui->breadcrumb, &craftlab::ui::Breadcrumb::SelectionChanged, this, &MainWindow::OnBreadcrumbSelection);
|
|
|
+ ui->listView->addAction("Open", [this]() { FileListItemEntered(ui->listView->currentIndex()); });
|
|
|
+#ifdef _WIN32
|
|
|
+ ui->listView->addAction("Open Containing Folders", [this]() { OpenContainingFolders(ui->listView->currentIndex()); });
|
|
|
+#endif
|
|
|
window->show();
|
|
|
|
|
|
if (dirList.empty() || !TryOpenningDir(dirList))
|
|
|
@@ -41,6 +40,40 @@ MainWindow::~MainWindow()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+void MainWindow::FileListItemEntered(const QModelIndex& index)
|
|
|
+{
|
|
|
+ if (index.isValid() && currentDiffResult)
|
|
|
+ {
|
|
|
+ const auto& fileIter = currentDiffResult->FileList.find(qvariant_cast<QString>(index.data(Qt::DisplayRole)).toStdString());
|
|
|
+ if (fileIter != currentDiffResult->FileList.end())
|
|
|
+ OnListViewDoubleClick(fileIter->second);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::OpenContainingFolders(const QModelIndex& index)
|
|
|
+{
|
|
|
+#ifdef _WIN32
|
|
|
+ if (index.isValid() && currentDiffResult)
|
|
|
+ {
|
|
|
+ const auto& fileIter = currentDiffResult->FileList.find(qvariant_cast<QString>(index.data(Qt::DisplayRole)).toStdString());
|
|
|
+ if (fileIter != currentDiffResult->FileList.end())
|
|
|
+ OpenContainingFolders(fileIter->second);
|
|
|
+ }
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::OpenContainingFolders(const File& file)
|
|
|
+{
|
|
|
+ assert(nullptr != engine);
|
|
|
+
|
|
|
+ for (const std::string& path : engine->GetPaths())
|
|
|
+ {
|
|
|
+ QFile f = QDir(path.c_str()).filePath(file.fileName.c_str());
|
|
|
+ if (f.exists())
|
|
|
+ system(("explorer /select," + f.filesystemFileName().make_preferred().string()).c_str());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
bool MainWindow::PathExists(const IEngine& engine) const
|
|
|
{
|
|
|
try
|