diff --git a/io/config.cpp b/io/config.cpp index 0e1c14028..e36e7b763 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -4,6 +4,9 @@ #include #include +#include "panels/project.h" +#include "panels/panels.h" + #include "debug.h" Config config; @@ -34,7 +37,8 @@ Config::Config() fast_seeking(false), hover_focus(false), project_view_type(PROJECT_VIEW_TREE), - set_name_with_marker(true) + set_name_with_marker(true), + show_project_toolbar(false) {} void Config::load(QString path) { @@ -123,6 +127,9 @@ void Config::load(QString path) { } else if (stream.name() == "SetNameWithMarker") { stream.readNext(); set_name_with_marker = (stream.text() == "1"); + } else if (stream.name() == "ShowProjectToolbar") { + stream.readNext(); + show_project_toolbar = (stream.text() == "1"); } } } @@ -173,6 +180,7 @@ void Config::save(QString path) { stream.writeTextElement("HoverFocus", QString::number(hover_focus)); stream.writeTextElement("ProjectViewType", QString::number(project_view_type)); stream.writeTextElement("SetNameWithMarker", QString::number(set_name_with_marker)); + stream.writeTextElement("ShowProjectToolbar", QString::number(panel_project->toolbar_widget->isVisible())); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index 394710270..312ba5c84 100644 --- a/io/config.h +++ b/io/config.h @@ -49,6 +49,7 @@ struct Config { bool hover_focus; int project_view_type; bool set_name_with_marker; + bool show_project_toolbar; void load(QString path); void save(QString path); diff --git a/panels/project.cpp b/panels/project.cpp index b2ee221b2..0c245f316 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -42,6 +42,7 @@ #include #include #include +#include extern "C" { #include @@ -74,11 +75,62 @@ Project::Project(QWidget *parent) : sorter = new QSortFilterProxyModel(this); sorter->setSourceModel(&project_model); + // optional toolbar + toolbar_widget = new QWidget(); + toolbar_widget->setVisible(config.show_project_toolbar); + QHBoxLayout* toolbar = new QHBoxLayout(); + toolbar->setMargin(0); + toolbar->setSpacing(0); + toolbar_widget->setLayout(toolbar); + + QPushButton* toolbar_new = new QPushButton("New"); + toolbar_new->setIcon(QIcon(":/icons/tri-down.png")); + toolbar_new->setIconSize(QSize(8, 8)); + toolbar_new->setToolTip("New"); + connect(toolbar_new, SIGNAL(clicked(bool)), this, SLOT(make_new_menu())); + toolbar->addWidget(toolbar_new); + + QPushButton* toolbar_open = new QPushButton("Open"); + toolbar_open->setToolTip("Open Project"); + connect(toolbar_open, SIGNAL(clicked(bool)), mainWindow, SLOT(open_project())); + toolbar->addWidget(toolbar_open); + + QPushButton* toolbar_save = new QPushButton("Save"); + toolbar_save->setToolTip("Save Project"); + connect(toolbar_save, SIGNAL(clicked(bool)), mainWindow, SLOT(save_project())); + toolbar->addWidget(toolbar_save); + + QPushButton* toolbar_undo = new QPushButton("Undo"); + toolbar_undo->setToolTip("Undo"); + connect(toolbar_undo, SIGNAL(clicked(bool)), mainWindow, SLOT(undo())); + toolbar->addWidget(toolbar_undo); + + QPushButton* toolbar_redo = new QPushButton("Redo"); + toolbar_redo->setToolTip("Redo"); + connect(toolbar_redo, SIGNAL(clicked(bool)), mainWindow, SLOT(redo())); + toolbar->addWidget(toolbar_redo); + + toolbar->addStretch(); + + QPushButton* toolbar_tree_view = new QPushButton("Tree View"); + toolbar_tree_view->setToolTip("Tree View"); + connect(toolbar_tree_view, SIGNAL(clicked(bool)), this, SLOT(set_tree_view())); + toolbar->addWidget(toolbar_tree_view); + + QPushButton* toolbar_icon_view = new QPushButton("Icon View"); + toolbar_icon_view->setToolTip("Icon View"); + connect(toolbar_icon_view, SIGNAL(clicked(bool)), this, SLOT(set_icon_view())); + toolbar->addWidget(toolbar_icon_view); + + verticalLayout->addWidget(toolbar_widget); + + // tree view tree_view = new SourceTable(dockWidgetContents); tree_view->project_parent = this; tree_view->setModel(sorter); verticalLayout->addWidget(tree_view); + // icon view icon_view_container = new QWidget(); QVBoxLayout* icon_view_container_layout = new QVBoxLayout(); @@ -1087,6 +1139,12 @@ void Project::go_up_dir() { set_up_dir_enabled(); } +void Project::make_new_menu() { + QMenu new_menu(this); + mainWindow->make_new_menu(&new_menu); + new_menu.exec(QCursor::pos()); +} + void Project::add_recent_project(QString url) { bool found = false; for (int i=0;i &items, QList &list, int type = -1); + + QWidget* toolbar_widget; public slots: void import_dialog(); void delete_selected_media(); @@ -103,6 +105,7 @@ private slots: void set_icon_view_size(int); void set_up_dir_enabled(); void go_up_dir(); + void make_new_menu(); }; class MediaThrobber : public QObject { diff --git a/project/sourcescommon.cpp b/project/sourcescommon.cpp index b5272c8cd..0dd870944 100644 --- a/project/sourcescommon.cpp +++ b/project/sourcescommon.cpp @@ -127,6 +127,11 @@ void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& it QAction* icon_view_action = menu.addAction("Icon View"); connect(icon_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_icon_view())); + QAction* toolbar_action = menu.addAction("Show Toolbar"); + toolbar_action->setCheckable(true); + toolbar_action->setChecked(project_parent->toolbar_widget->isVisible()); + connect(toolbar_action, SIGNAL(triggered(bool)), project_parent->toolbar_widget, SLOT(setVisible(bool))); + menu.exec(QCursor::pos()); }