work towards project explorer navigation bar

This commit is contained in:
itsmattkc
2019-07-02 16:46:09 -07:00
parent 85b5bbd5d6
commit 0f7192fc33
16 changed files with 274 additions and 32 deletions
@@ -18,6 +18,7 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/projectexplorer/projectexplorer.h
widget/projectexplorer/projectexplorer.cpp
widget/projectexplorer/projectexplorerdefines.h
widget/projectexplorer/projectexplorertreeview.h
widget/projectexplorer/projectexplorertreeview.cpp
widget/projectexplorer/projectexplorerlistview.h
+44 -8
View File
@@ -21,20 +21,46 @@
#include "projectexplorer.h"
#include <QDebug>
#include <QVBoxLayout>
#include "projectexplorerdefines.h"
ProjectExplorer::ProjectExplorer(QWidget *parent) :
QStackedWidget(parent),
QWidget(parent),
view_type_(olive::TreeView),
model_(this)
{
tree_view_ = new ProjectExplorerTreeView(this);
// Create layout
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setSpacing(0);
layout->setMargin(0);
// Set up navigation bar
nav_bar_ = new ProjectExplorerNavigation(this);
connect(nav_bar_, SIGNAL(SizeChanged(int)), this, SLOT(SizeChangedSlot(int)));
layout->addWidget(nav_bar_);
// Set up stacked widget
stacked_widget_ = new QStackedWidget(this);
layout->addWidget(stacked_widget_);
// Add tree view to stacked widget
tree_view_ = new ProjectExplorerTreeView(stacked_widget_);
AddView(tree_view_);
list_view_ = new ProjectExplorerListView(this);
// Add list view to stacked widget
list_view_ = new ProjectExplorerListView(stacked_widget_);
AddView(list_view_);
icon_view_ = new ProjectExplorerIconView(this);
// Add icon view to stacked widget
icon_view_ = new ProjectExplorerIconView(stacked_widget_);
AddView(icon_view_);
// Set default view to tree view
set_view_type(olive::TreeView);
// Set default icon size
SizeChangedSlot(olive::kProjectIconSizeDefault);
}
const olive::ProjectViewType &ProjectExplorer::view_type()
@@ -49,13 +75,16 @@ void ProjectExplorer::set_view_type(olive::ProjectViewType type)
// Set widget based on view type
switch (view_type_) {
case olive::TreeView:
setCurrentWidget(tree_view_);
stacked_widget_->setCurrentWidget(tree_view_);
nav_bar_->setVisible(false);
break;
case olive::ListView:
setCurrentWidget(list_view_);
stacked_widget_->setCurrentWidget(list_view_);
nav_bar_->setVisible(true);
break;
case olive::IconView:
setCurrentWidget(icon_view_);
stacked_widget_->setCurrentWidget(icon_view_);
nav_bar_->setVisible(true);
break;
}
}
@@ -64,7 +93,7 @@ void ProjectExplorer::AddView(QAbstractItemView *view)
{
view->setModel(&model_);
connect(view, SIGNAL(DoubleClickedView(const QModelIndex&)), this, SLOT(DoubleClickViewSlot(const QModelIndex&)));
addWidget(view);
stacked_widget_->addWidget(view);
}
void ProjectExplorer::DoubleClickViewSlot(const QModelIndex &index)
@@ -85,6 +114,13 @@ void ProjectExplorer::DoubleClickViewSlot(const QModelIndex &index)
}
}
void ProjectExplorer::SizeChangedSlot(int s)
{
icon_view_->setGridSize(QSize(s, s));
list_view_->setIconSize(QSize(s, s));
}
Project *ProjectExplorer::project()
{
return model_.project();
+8 -1
View File
@@ -30,6 +30,7 @@
#include "widget/projectexplorer/projectexplorericonview.h"
#include "widget/projectexplorer/projectexplorerlistview.h"
#include "widget/projectexplorer/projectexplorertreeview.h"
#include "widget/projectexplorer/projectexplorernavigation.h"
/**
* @brief The ProjectExplorer class
@@ -41,7 +42,7 @@
*
* This widget contains three views, tree view, list view, and icon view. These can be switched at any time.
*/
class ProjectExplorer : public QStackedWidget
class ProjectExplorer : public QWidget
{
Q_OBJECT
public:
@@ -77,6 +78,10 @@ private:
*/
void AddView(QAbstractItemView* view);
QStackedWidget* stacked_widget_;
ProjectExplorerNavigation* nav_bar_;
ProjectExplorerIconView* icon_view_;
ProjectExplorerListView* list_view_;
ProjectExplorerTreeView* tree_view_;
@@ -87,6 +92,8 @@ private:
private slots:
void DoubleClickViewSlot(const QModelIndex& index);
void SizeChangedSlot(int s);
};
#endif // PROJECTEXPLORER_H
@@ -0,0 +1,13 @@
#ifndef PROJECTEXPLORERDEFINES_H
#define PROJECTEXPLORERDEFINES_H
namespace olive {
const int kProjectIconSizeMinimum = 16;
const int kProjectIconSizeMaximum = 256;
const int kProjectIconSizeDefault = 64;
}
#endif // PROJECTEXPLORERDEFINES_H
@@ -1,3 +1,23 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "projectexplorericonviewitemdelegate.h"
#include <QPainter>
@@ -1,3 +1,23 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef PROJECTEXPLORERICONVIEWITEMDELEGATE_H
#define PROJECTEXPLORERICONVIEWITEMDELEGATE_H
@@ -1,3 +1,23 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "projectexplorerlistviewitemdelegate.h"
#include <QPainter>
@@ -1,3 +1,23 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
#define PROJECTEXPLORERLISTVIEWITEMDELEGATE_H
@@ -1,15 +1,77 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "projectexplorernavigation.h"
#include <QEvent>
#include <QHBoxLayout>
#include "ui/icons/icons.h"
#include "widget/projectexplorer/projectexplorerdefines.h"
ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) :
QWidget(parent)
{
// Create widget layout
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setMargin(0);
// Create "directory up" button
dir_up_btn_ = new QPushButton(this);
dir_up_btn_->setIcon(olive::icon::DirUp);
dir_up_btn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
layout->addWidget(dir_up_btn_);
connect(dir_up_btn_, SIGNAL(clicked(bool)), this, SIGNAL(DirectoryUpClicked()));
// Create directory tree label
dir_lbl_ = new QLabel(this);
dir_lbl_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
layout->addWidget(dir_lbl_);
// Create size slider
size_slider_ = new QSlider(this);
size_slider_->setOrientation(Qt::Horizontal);
size_slider_->setMinimum(olive::kProjectIconSizeMinimum);
size_slider_->setMaximum(olive::kProjectIconSizeMaximum);
size_slider_->setValue(olive::kProjectIconSizeDefault);
size_slider_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
layout->addWidget(size_slider_);
connect(size_slider_, SIGNAL(valueChanged(int)), this, SIGNAL(SizeChanged(int)));
Retranslate();
}
void ProjectExplorerNavigation::set_text(const QString &s)
{
dir_lbl_->setText(s);
}
void ProjectExplorerNavigation::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
Retranslate();
}
QWidget::changeEvent(e);
}
void ProjectExplorerNavigation::Retranslate()
{
dir_up_btn_->setToolTip(tr("Go to parent folder"));
}
@@ -1,16 +1,54 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef PROJECTEXPLORERLISTVIEWTOOLBAR_H
#define PROJECTEXPLORERLISTVIEWTOOLBAR_H
#include <QLabel>
#include <QPushButton>
#include <QSlider>
#include <QWidget>
class ProjectExplorerNavigation : public QWidget
{
Q_OBJECT
public:
ProjectExplorerNavigation(QWidget* parent);
void set_text(const QString& s);
signals:
void DirectoryUpClicked();
void SizeChanged(int size);
protected:
virtual void changeEvent(QEvent *) override;
private:
void Retranslate();
QPushButton* dir_up_btn_;
QLabel* dir_lbl_;
QSlider* size_slider_;
};
#endif // PROJECTEXPLORERLISTVIEWTOOLBAR_H