project name and cleaner toolbar code
This commit is contained in:
@@ -21,6 +21,7 @@ set(OLIVE_SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
#add_subdirectory(decoder)
|
||||
add_subdirectory(panel)
|
||||
add_subdirectory(project)
|
||||
add_subdirectory(render)
|
||||
|
||||
@@ -34,6 +34,8 @@ Project *ProjectPanel::project()
|
||||
void ProjectPanel::set_project(Project *p)
|
||||
{
|
||||
explorer_->set_project(p);
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
void ProjectPanel::changeEvent(QEvent *e)
|
||||
@@ -47,5 +49,10 @@ void ProjectPanel::changeEvent(QEvent *e)
|
||||
void ProjectPanel::Retranslate()
|
||||
{
|
||||
SetTitle(tr("Project"));
|
||||
SetSubtitle(tr("(untitled)"));
|
||||
|
||||
if (project() == nullptr) {
|
||||
SetSubtitle(tr("(none)"));
|
||||
} else {
|
||||
SetSubtitle(project()->name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,20 @@
|
||||
|
||||
Project::Project()
|
||||
{
|
||||
name_ = tr("(untitled)");
|
||||
}
|
||||
|
||||
Folder *Project::root()
|
||||
{
|
||||
return &root_;
|
||||
}
|
||||
|
||||
const QString &Project::name()
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
void Project::set_name(const QString &s)
|
||||
{
|
||||
name_ = s;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
#ifndef PROJECT_H
|
||||
#define PROJECT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
#include "folder.h"
|
||||
|
||||
class Project
|
||||
class Project : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Project();
|
||||
|
||||
Folder* root();
|
||||
|
||||
const QString& name();
|
||||
void set_name(const QString& s);
|
||||
|
||||
private:
|
||||
Folder root_;
|
||||
|
||||
QString name_;
|
||||
};
|
||||
|
||||
using ProjectPtr = std::shared_ptr<Project>;
|
||||
|
||||
@@ -1,68 +1,29 @@
|
||||
#include "toolbar.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QEvent>
|
||||
|
||||
#include "widget/flowlayout/flowlayout.h"
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
Toolbar::Toolbar(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
FlowLayout* layout = new FlowLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout_ = new FlowLayout(this);
|
||||
layout_->setMargin(0);
|
||||
|
||||
btn_pointer_tool = new QPushButton();
|
||||
btn_pointer_tool->setIcon(olive::icon::ToolPointer);
|
||||
layout->addWidget(btn_pointer_tool);
|
||||
|
||||
btn_edit_tool = new QPushButton();
|
||||
btn_edit_tool->setIcon(olive::icon::ToolEdit);
|
||||
layout->addWidget(btn_edit_tool);
|
||||
|
||||
btn_ripple_tool = new QPushButton();
|
||||
btn_ripple_tool->setIcon(olive::icon::ToolRipple);
|
||||
layout->addWidget(btn_ripple_tool);
|
||||
|
||||
btn_razor_tool = new QPushButton();
|
||||
btn_razor_tool->setIcon(olive::icon::ToolRazor);
|
||||
layout->addWidget(btn_razor_tool);
|
||||
|
||||
btn_slip_tool = new QPushButton();
|
||||
btn_slip_tool->setIcon(olive::icon::ToolSlip);
|
||||
layout->addWidget(btn_slip_tool);
|
||||
|
||||
btn_slide_tool = new QPushButton();
|
||||
btn_slide_tool->setIcon(olive::icon::ToolSlide);
|
||||
layout->addWidget(btn_slide_tool);
|
||||
|
||||
btn_hand_tool = new QPushButton();
|
||||
btn_hand_tool->setIcon(olive::icon::ToolHand);
|
||||
layout->addWidget(btn_hand_tool);
|
||||
|
||||
btn_transition_tool = new QPushButton();
|
||||
btn_transition_tool->setIcon(olive::icon::ToolTransition);
|
||||
layout->addWidget(btn_transition_tool);
|
||||
|
||||
btn_snapping_toggle = new QPushButton();
|
||||
btn_snapping_toggle->setIcon(olive::icon::Snapping);
|
||||
layout->addWidget(btn_snapping_toggle);
|
||||
|
||||
btn_zoom_in = new QPushButton();
|
||||
btn_zoom_in->setIcon(olive::icon::ZoomIn);
|
||||
layout->addWidget(btn_zoom_in);
|
||||
|
||||
btn_zoom_out = new QPushButton();
|
||||
btn_zoom_out->setIcon(olive::icon::ZoomOut);
|
||||
layout->addWidget(btn_zoom_out);
|
||||
|
||||
btn_record = new QPushButton();
|
||||
btn_record->setIcon(olive::icon::Record);
|
||||
layout->addWidget(btn_record);
|
||||
|
||||
btn_add = new QPushButton();
|
||||
btn_add->setIcon(olive::icon::Add);
|
||||
layout->addWidget(btn_add);
|
||||
btn_pointer_tool_ = CreateToolButton(olive::icon::ToolPointer);
|
||||
btn_edit_tool_ = CreateToolButton(olive::icon::ToolEdit);
|
||||
btn_ripple_tool_ = CreateToolButton(olive::icon::ToolRipple);
|
||||
btn_razor_tool_ = CreateToolButton(olive::icon::ToolRazor);
|
||||
btn_slip_tool_ = CreateToolButton(olive::icon::ToolSlip);
|
||||
btn_slide_tool_ = CreateToolButton(olive::icon::ToolSlide);
|
||||
btn_hand_tool_ = CreateToolButton(olive::icon::ToolHand);
|
||||
btn_zoom_tool_ = CreateToolButton(olive::icon::ZoomIn);
|
||||
btn_transition_tool_ = CreateToolButton(olive::icon::ToolTransition);
|
||||
btn_snapping_toggle_ = CreateToolButton(olive::icon::Snapping);
|
||||
btn_record_ = CreateToolButton(olive::icon::Record);
|
||||
btn_add_ = CreateToolButton(olive::icon::Add);
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
@@ -77,17 +38,25 @@ void Toolbar::changeEvent(QEvent *e)
|
||||
|
||||
void Toolbar::Retranslate()
|
||||
{
|
||||
btn_pointer_tool->setToolTip(tr("Pointer Tool"));
|
||||
btn_edit_tool->setToolTip(tr("Edit Tool"));
|
||||
btn_ripple_tool->setToolTip(tr("Ripple Tool"));
|
||||
btn_razor_tool->setToolTip(tr("Razor Tool"));
|
||||
btn_slip_tool->setToolTip(tr("Slip Tool"));
|
||||
btn_slide_tool->setToolTip(tr("Slide Tool"));
|
||||
btn_hand_tool->setToolTip(tr("Hand Tool"));
|
||||
btn_transition_tool->setToolTip(tr("Transition Tool"));
|
||||
btn_snapping_toggle->setToolTip(tr("Toggle Snapping"));
|
||||
btn_zoom_in->setToolTip(tr("Zoom In"));
|
||||
btn_zoom_out->setToolTip(tr("Zoom Out"));
|
||||
btn_record->setToolTip(tr("Record Audio"));
|
||||
btn_add->setToolTip(tr("Add Object"));
|
||||
btn_pointer_tool_->setToolTip(tr("Pointer Tool"));
|
||||
btn_edit_tool_->setToolTip(tr("Edit Tool"));
|
||||
btn_ripple_tool_->setToolTip(tr("Ripple Tool"));
|
||||
btn_razor_tool_->setToolTip(tr("Razor Tool"));
|
||||
btn_slip_tool_->setToolTip(tr("Slip Tool"));
|
||||
btn_slide_tool_->setToolTip(tr("Slide Tool"));
|
||||
btn_hand_tool_->setToolTip(tr("Hand Tool"));
|
||||
btn_zoom_tool_->setToolTip(tr("Zoom Tool"));
|
||||
btn_transition_tool_->setToolTip(tr("Transition Tool"));
|
||||
btn_snapping_toggle_->setToolTip(tr("Toggle Snapping"));
|
||||
btn_record_->setToolTip(tr("Record Audio"));
|
||||
btn_add_->setToolTip(tr("Add Object"));
|
||||
}
|
||||
|
||||
QPushButton* Toolbar::CreateToolButton(const QIcon &icon)
|
||||
{
|
||||
QPushButton* b = new QPushButton();
|
||||
b->setIcon(icon);
|
||||
b->setCheckable(true);
|
||||
layout_->addWidget(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include "widget/flowlayout/flowlayout.h"
|
||||
|
||||
class Toolbar : public QWidget
|
||||
{
|
||||
public:
|
||||
@@ -14,19 +16,22 @@ protected:
|
||||
private:
|
||||
void Retranslate();
|
||||
|
||||
QPushButton* btn_pointer_tool;
|
||||
QPushButton* btn_edit_tool;
|
||||
QPushButton* btn_ripple_tool;
|
||||
QPushButton* btn_razor_tool;
|
||||
QPushButton* btn_slip_tool;
|
||||
QPushButton* btn_slide_tool;
|
||||
QPushButton* btn_hand_tool;
|
||||
QPushButton* btn_transition_tool;
|
||||
QPushButton* btn_snapping_toggle;
|
||||
QPushButton* btn_zoom_in;
|
||||
QPushButton* btn_zoom_out;
|
||||
QPushButton* btn_record;
|
||||
QPushButton* btn_add;
|
||||
QPushButton *CreateToolButton(const QIcon& icon);
|
||||
|
||||
FlowLayout* layout_;
|
||||
|
||||
QPushButton* btn_pointer_tool_;
|
||||
QPushButton* btn_edit_tool_;
|
||||
QPushButton* btn_ripple_tool_;
|
||||
QPushButton* btn_razor_tool_;
|
||||
QPushButton* btn_slip_tool_;
|
||||
QPushButton* btn_slide_tool_;
|
||||
QPushButton* btn_hand_tool_;
|
||||
QPushButton* btn_transition_tool_;
|
||||
QPushButton* btn_snapping_toggle_;
|
||||
QPushButton* btn_zoom_tool_;
|
||||
QPushButton* btn_record_;
|
||||
QPushButton* btn_add_;
|
||||
};
|
||||
|
||||
#endif // TOOLBAR_H
|
||||
|
||||
Reference in New Issue
Block a user