added optional toolbar

This commit is contained in:
itsmattkc
2019-01-06 21:06:31 +11:00
parent 90ee9ecb4e
commit 1398a54cf4
5 changed files with 76 additions and 1 deletions
+9 -1
View File
@@ -4,6 +4,9 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#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
+1
View File
@@ -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);
+58
View File
@@ -42,6 +42,7 @@
#include <QXmlStreamWriter>
#include <QSizePolicy>
#include <QVBoxLayout>
#include <QMenu>
extern "C" {
#include <libavformat/avformat.h>
@@ -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<recent_projects.size();i++) {
+3
View File
@@ -77,6 +77,8 @@ public:
void start_preview_generator(Media* item, bool replacing);
void get_all_media_from_table(QList<Media *> &items, QList<Media *> &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 {
+5
View File
@@ -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());
}