Skip to content

Commit

Permalink
Project view: Removed tool bar
Browse files Browse the repository at this point in the history
It looks a little messy and adds no new functionality.

Also prevented global project actions from being visible in the context
menu for subdirectories and files.
  • Loading branch information
bjorn committed Dec 4, 2019
1 parent 50944aa commit 109a224
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/tiled/projectdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <QMouseEvent>
#include <QSettings>
#include <QStandardPaths>
#include <QToolBar>
#include <QTreeView>

static const char * const LAST_PROJECT_KEY = "Project/LastProject";
Expand Down Expand Up @@ -83,14 +82,6 @@ ProjectDock::ProjectDock(QWidget *parent)
layout->setMargin(0);
layout->setSpacing(0);

QToolBar *toolBar = new QToolBar;
toolBar->setFloatable(false);
toolBar->setMovable(false);
toolBar->setIconSize(Utils::smallIconSize());

toolBar->addAction(ActionManager::action("AddFolderToProject"));
toolBar->addAction(ActionManager::action("RefreshProjectFolders"));

// Reopen last used project
const auto prefs = Preferences::instance();
const auto settings = prefs->settings();
Expand All @@ -99,7 +90,6 @@ ProjectDock::ProjectDock(QWidget *parent)
openProjectFile(lastProjectFileName);

layout->addWidget(mProjectView);
layout->addWidget(toolBar);

setWidget(widget);
retranslateUi();
Expand Down Expand Up @@ -271,21 +261,24 @@ void ProjectView::contextMenuEvent(QContextMenuEvent *event)

QMenu menu;

if (index.isValid() && !index.parent().isValid()) {
auto removeFolder = menu.addAction(tr("Remove Folder from Project"), [=] {
model()->removeFolder(index.row());

auto &p = model()->project();
if (!p.fileName().isEmpty())
p.save(p.fileName());
});
Utils::setThemeIcon(removeFolder, "list-remove");
if (index.isValid()) {
if (!index.parent().isValid()) {
auto removeFolder = menu.addAction(tr("&Remove Folder from Project"), [=] {
model()->removeFolder(index.row());

auto &p = model()->project();
if (!p.fileName().isEmpty())
p.save(p.fileName());
});
Utils::setThemeIcon(removeFolder, "list-remove");
}
} else {
menu.addAction(ActionManager::action("AddFolderToProject"));
menu.addAction(ActionManager::action("RefreshProjectFolders"));
}

menu.exec(event->globalPos());
if (!menu.isEmpty())
menu.exec(event->globalPos());
}

void ProjectView::onActivated(const QModelIndex &index)
Expand Down

0 comments on commit 109a224

Please sign in to comment.