various UI reimplementations from 0.1.x
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
add_subdirectory(columnedgridlayout)
|
||||
add_subdirectory(flowlayout)
|
||||
add_subdirectory(footagecombobox)
|
||||
add_subdirectory(menu)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# 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/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/columnedgridlayout/columnedgridlayout.h
|
||||
widget/columnedgridlayout/columnedgridlayout.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "columnedgridlayout.h"
|
||||
|
||||
ColumnedGridLayout::ColumnedGridLayout(QWidget* parent,
|
||||
int maximum_columns) :
|
||||
QGridLayout (parent),
|
||||
maximum_columns_(maximum_columns)
|
||||
{
|
||||
}
|
||||
|
||||
void ColumnedGridLayout::Add(QWidget *widget)
|
||||
{
|
||||
if (maximum_columns_ > 0) {
|
||||
|
||||
int row = count() / maximum_columns_;
|
||||
int column = count() % maximum_columns_;
|
||||
|
||||
addWidget(widget, row, column);
|
||||
|
||||
} else {
|
||||
|
||||
addWidget(widget);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int ColumnedGridLayout::MaximumColumns() const
|
||||
{
|
||||
return maximum_columns_;
|
||||
}
|
||||
|
||||
void ColumnedGridLayout::SetMaximumColumns(int maximum_columns)
|
||||
{
|
||||
maximum_columns_ = maximum_columns;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef COLUMNEDGRIDLAYOUT_H
|
||||
#define COLUMNEDGRIDLAYOUT_H
|
||||
|
||||
#include <QGridLayout>
|
||||
|
||||
/**
|
||||
* @brief The ColumnedGridLayout class
|
||||
*
|
||||
* A simple derivative of QGridLayout that provides a automatic row/column layout based on a specified maximum
|
||||
* column count.
|
||||
*/
|
||||
class ColumnedGridLayout : public QGridLayout
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColumnedGridLayout(QWidget* parent = nullptr,
|
||||
int maximum_columns = 0);
|
||||
|
||||
void Add(QWidget* widget);
|
||||
int MaximumColumns() const;
|
||||
void SetMaximumColumns(int maximum_columns);
|
||||
|
||||
private:
|
||||
int maximum_columns_;
|
||||
};
|
||||
|
||||
#endif // COLUMNEDGRIDLAYOUT_H
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "playbackcontrols.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "common/timecodefunctions.h"
|
||||
@@ -63,28 +65,24 @@ PlaybackControls::PlaybackControls(QWidget *parent) :
|
||||
lower_middle_layout->addStretch();
|
||||
|
||||
// Go To Start Button
|
||||
QPushButton* go_to_start_btn = new QPushButton();
|
||||
go_to_start_btn->setIcon(olive::icon::GoToStart);
|
||||
lower_middle_layout->addWidget(go_to_start_btn);
|
||||
connect(go_to_start_btn, SIGNAL(clicked(bool)), this, SIGNAL(BeginClicked()));
|
||||
go_to_start_btn_ = new QPushButton();
|
||||
lower_middle_layout->addWidget(go_to_start_btn_);
|
||||
connect(go_to_start_btn_, SIGNAL(clicked(bool)), this, SIGNAL(BeginClicked()));
|
||||
|
||||
// Prev Frame Button
|
||||
QPushButton* prev_frame_btn = new QPushButton();
|
||||
prev_frame_btn->setIcon(olive::icon::PrevFrame);
|
||||
lower_middle_layout->addWidget(prev_frame_btn);
|
||||
connect(prev_frame_btn, SIGNAL(clicked(bool)), this, SIGNAL(PrevFrameClicked()));
|
||||
prev_frame_btn_ = new QPushButton();
|
||||
lower_middle_layout->addWidget(prev_frame_btn_);
|
||||
connect(prev_frame_btn_, SIGNAL(clicked(bool)), this, SIGNAL(PrevFrameClicked()));
|
||||
|
||||
// Play/Pause Button
|
||||
playpause_stack_ = new QStackedWidget();
|
||||
lower_middle_layout->addWidget(playpause_stack_);
|
||||
|
||||
play_btn_ = new QPushButton();
|
||||
play_btn_->setIcon(olive::icon::Play);
|
||||
playpause_stack_->addWidget(play_btn_);
|
||||
connect(play_btn_, SIGNAL(clicked(bool)), this, SIGNAL(PlayClicked()));
|
||||
|
||||
pause_btn_ = new QPushButton();
|
||||
pause_btn_->setIcon(olive::icon::Pause);
|
||||
playpause_stack_->addWidget(pause_btn_);
|
||||
connect(pause_btn_, SIGNAL(clicked(bool)), this, SIGNAL(PauseClicked()));
|
||||
|
||||
@@ -93,16 +91,14 @@ PlaybackControls::PlaybackControls(QWidget *parent) :
|
||||
playpause_stack_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
|
||||
// Next Frame Button
|
||||
QPushButton* next_frame_btn = new QPushButton();
|
||||
next_frame_btn->setIcon(olive::icon::NextFrame);
|
||||
lower_middle_layout->addWidget(next_frame_btn);
|
||||
connect(next_frame_btn, SIGNAL(clicked(bool)), this, SIGNAL(NextFrameClicked()));
|
||||
next_frame_btn_ = new QPushButton();
|
||||
lower_middle_layout->addWidget(next_frame_btn_);
|
||||
connect(next_frame_btn_, SIGNAL(clicked(bool)), this, SIGNAL(NextFrameClicked()));
|
||||
|
||||
// Go To End Button
|
||||
QPushButton* go_to_end_btn = new QPushButton();
|
||||
go_to_end_btn->setIcon(olive::icon::GoToEnd);
|
||||
lower_middle_layout->addWidget(go_to_end_btn);
|
||||
connect(go_to_end_btn, SIGNAL(clicked(bool)), this, SIGNAL(EndClicked()));
|
||||
go_to_end_btn_ = new QPushButton();
|
||||
lower_middle_layout->addWidget(go_to_end_btn_);
|
||||
connect(go_to_end_btn_, SIGNAL(clicked(bool)), this, SIGNAL(EndClicked()));
|
||||
|
||||
lower_middle_layout->addStretch();
|
||||
|
||||
@@ -119,6 +115,8 @@ PlaybackControls::PlaybackControls(QWidget *parent) :
|
||||
lower_right_layout->addStretch();
|
||||
end_tc_lbl_ = new QLabel("00:00:00;00");
|
||||
lower_right_layout->addWidget(end_tc_lbl_);
|
||||
|
||||
UpdateIcons();
|
||||
}
|
||||
|
||||
void PlaybackControls::SetTimecodeEnabled(bool enabled)
|
||||
@@ -136,7 +134,9 @@ void PlaybackControls::SetTime(const int64_t &r)
|
||||
{
|
||||
Q_ASSERT(time_base_.denominator() != 0);
|
||||
|
||||
cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, kTimecodeDisplay));
|
||||
cur_tc_lbl_->setText(olive::timestamp_to_timecode(r,
|
||||
time_base_,
|
||||
olive::CurrentTimecodeDisplay()));
|
||||
}
|
||||
|
||||
void PlaybackControls::ShowPauseButton()
|
||||
@@ -149,3 +149,22 @@ void PlaybackControls::ShowPlayButton()
|
||||
{
|
||||
playpause_stack_->setCurrentWidget(play_btn_);
|
||||
}
|
||||
|
||||
void PlaybackControls::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
|
||||
if (e->type() == QEvent::StyleChange) {
|
||||
UpdateIcons();
|
||||
}
|
||||
}
|
||||
|
||||
void PlaybackControls::UpdateIcons()
|
||||
{
|
||||
go_to_start_btn_->setIcon(olive::icon::GoToStart);
|
||||
prev_frame_btn_->setIcon(olive::icon::PrevFrame);
|
||||
play_btn_->setIcon(olive::icon::Play);
|
||||
pause_btn_->setIcon(olive::icon::Pause);
|
||||
next_frame_btn_->setIcon(olive::icon::NextFrame);
|
||||
go_to_end_btn_->setIcon(olive::icon::GoToEnd);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,12 @@ signals:
|
||||
*/
|
||||
void EndClicked();
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *) override;
|
||||
|
||||
private:
|
||||
void UpdateIcons();
|
||||
|
||||
QWidget* lower_left_container_;
|
||||
QWidget* lower_right_container_;
|
||||
|
||||
@@ -93,8 +98,12 @@ private:
|
||||
|
||||
rational time_base_;
|
||||
|
||||
QPushButton* go_to_start_btn_;
|
||||
QPushButton* prev_frame_btn_;
|
||||
QPushButton* play_btn_;
|
||||
QPushButton* pause_btn_;
|
||||
QPushButton* next_frame_btn_;
|
||||
QPushButton* go_to_end_btn_;
|
||||
|
||||
QStackedWidget* playpause_stack_;
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) :
|
||||
// Create "directory up" button
|
||||
dir_up_btn_ = new QPushButton(this);
|
||||
dir_up_btn_->setEnabled(false);
|
||||
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()));
|
||||
@@ -49,14 +48,12 @@ ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) :
|
||||
// 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();
|
||||
UpdateIcons();
|
||||
}
|
||||
|
||||
void ProjectExplorerNavigation::set_text(const QString &s)
|
||||
@@ -78,6 +75,8 @@ void ProjectExplorerNavigation::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
} else if (e->type() == QEvent::StyleChange) {
|
||||
UpdateIcons();
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
@@ -86,3 +85,11 @@ void ProjectExplorerNavigation::Retranslate()
|
||||
{
|
||||
dir_up_btn_->setToolTip(tr("Go to parent folder"));
|
||||
}
|
||||
|
||||
void ProjectExplorerNavigation::UpdateIcons()
|
||||
{
|
||||
dir_up_btn_->setIcon(olive::icon::DirUp);
|
||||
size_slider_->setMinimum(olive::kProjectIconSizeMinimum);
|
||||
size_slider_->setMaximum(olive::kProjectIconSizeMaximum);
|
||||
size_slider_->setValue(olive::kProjectIconSizeDefault);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,8 @@ protected:
|
||||
private:
|
||||
void Retranslate();
|
||||
|
||||
void UpdateIcons();
|
||||
|
||||
QPushButton* dir_up_btn_;
|
||||
|
||||
QLabel* dir_lbl_;
|
||||
|
||||
@@ -34,27 +34,22 @@ ProjectToolbar::ProjectToolbar(QWidget *parent) :
|
||||
layout->setMargin(0);
|
||||
|
||||
new_button_ = new QPushButton();
|
||||
new_button_->setIcon(olive::icon::New);
|
||||
connect(new_button_, SIGNAL(clicked(bool)), this, SIGNAL(NewClicked()));
|
||||
layout->addWidget(new_button_);
|
||||
|
||||
open_button_ = new QPushButton();
|
||||
open_button_->setIcon(olive::icon::Open);
|
||||
connect(open_button_, SIGNAL(clicked(bool)), this, SIGNAL(OpenClicked()));
|
||||
layout->addWidget(open_button_);
|
||||
|
||||
save_button_ = new QPushButton();
|
||||
save_button_->setIcon(olive::icon::Save);
|
||||
connect(save_button_, SIGNAL(clicked(bool)), this, SIGNAL(SaveClicked()));
|
||||
layout->addWidget(save_button_);
|
||||
|
||||
undo_button_ = new QPushButton();
|
||||
undo_button_->setIcon(olive::icon::Undo);
|
||||
connect(undo_button_, SIGNAL(clicked(bool)), this, SIGNAL(UndoClicked()));
|
||||
layout->addWidget(undo_button_);
|
||||
|
||||
redo_button_ = new QPushButton();
|
||||
redo_button_->setIcon(olive::icon::Redo);
|
||||
connect(redo_button_, SIGNAL(clicked(bool)), this, SIGNAL(RedoClicked()));
|
||||
layout->addWidget(redo_button_);
|
||||
|
||||
@@ -64,19 +59,16 @@ ProjectToolbar::ProjectToolbar(QWidget *parent) :
|
||||
layout->addWidget(search_field_);
|
||||
|
||||
tree_button_ = new QPushButton();
|
||||
tree_button_->setIcon(olive::icon::TreeView);
|
||||
tree_button_->setCheckable(true);
|
||||
connect(tree_button_, SIGNAL(clicked(bool)), this, SLOT(ViewButtonClicked()));
|
||||
layout->addWidget(tree_button_);
|
||||
|
||||
list_button_ = new QPushButton();
|
||||
list_button_->setIcon(olive::icon::ListView);
|
||||
list_button_->setCheckable(true);
|
||||
connect(list_button_, SIGNAL(clicked(bool)), this, SLOT(ViewButtonClicked()));
|
||||
layout->addWidget(list_button_);
|
||||
|
||||
icon_button_ = new QPushButton();
|
||||
icon_button_->setIcon(olive::icon::IconView);
|
||||
icon_button_->setCheckable(true);
|
||||
connect(icon_button_, SIGNAL(clicked(bool)), this, SLOT(ViewButtonClicked()));
|
||||
layout->addWidget(icon_button_);
|
||||
@@ -89,6 +81,7 @@ ProjectToolbar::ProjectToolbar(QWidget *parent) :
|
||||
view_button_group->addButton(icon_button_);
|
||||
|
||||
Retranslate();
|
||||
UpdateIcons();
|
||||
}
|
||||
|
||||
void ProjectToolbar::SetView(olive::ProjectViewType type)
|
||||
@@ -110,6 +103,8 @@ void ProjectToolbar::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
} else if (e->type() == QEvent::StyleChange) {
|
||||
UpdateIcons();
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
@@ -129,6 +124,18 @@ void ProjectToolbar::Retranslate()
|
||||
icon_button_->setToolTip(tr("Switch to Icon View"));
|
||||
}
|
||||
|
||||
void ProjectToolbar::UpdateIcons()
|
||||
{
|
||||
new_button_->setIcon(olive::icon::New);
|
||||
open_button_->setIcon(olive::icon::Open);
|
||||
save_button_->setIcon(olive::icon::Save);
|
||||
undo_button_->setIcon(olive::icon::Undo);
|
||||
redo_button_->setIcon(olive::icon::Redo);
|
||||
tree_button_->setIcon(olive::icon::TreeView);
|
||||
list_button_->setIcon(olive::icon::ListView);
|
||||
icon_button_->setIcon(olive::icon::IconView);
|
||||
}
|
||||
|
||||
void ProjectToolbar::ViewButtonClicked()
|
||||
{
|
||||
// Determine which view button triggered this slot and emit a signal accordingly
|
||||
|
||||
@@ -61,6 +61,7 @@ signals:
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
void UpdateIcons();
|
||||
|
||||
QPushButton* new_button_;
|
||||
QPushButton* open_button_;
|
||||
|
||||
@@ -51,6 +51,7 @@ TimelineView::TimelineView(QWidget *parent) :
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
setDragMode(RubberBandDrag);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
setBackgroundRole(QPalette::Window);
|
||||
|
||||
connect(&scene_, SIGNAL(changed(const QList<QRectF>&)), this, SLOT(UpdateSceneRect()));
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void TimelineView::ImportTool::DragEnter(QDragEnterEvent *event)
|
||||
|
||||
if (stream->type() == Stream::kImage) {
|
||||
// Stream is essentially length-less - use config's default image length
|
||||
footage_duration = kDefaultImageLength;
|
||||
footage_duration = Config::Current()["DefaultStillLength"].value<rational>();
|
||||
} else {
|
||||
// Use duration from file
|
||||
footage_duration = rational(stream->timebase().numerator() * stream->duration(),
|
||||
@@ -151,7 +151,7 @@ void TimelineView::ImportTool::DragMove(QDragMoveEvent *event)
|
||||
int64_t earliest_timestamp = olive::time_to_timestamp(earliest_ghost, parent()->timebase_);
|
||||
QString tooltip_text = olive::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase_,
|
||||
kTimecodeDisplay);
|
||||
olive::CurrentTimecodeDisplay());
|
||||
QToolTip::showText(QCursor::pos(),
|
||||
tooltip_text,
|
||||
parent());
|
||||
|
||||
@@ -279,7 +279,7 @@ void TimelineView::PointerTool::ProcessDrag(const QPoint &mouse_pos)
|
||||
int64_t earliest_timestamp = olive::time_to_timestamp(time_movement, parent()->timebase_);
|
||||
QString tooltip_text = olive::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase_,
|
||||
kTimecodeDisplay,
|
||||
olive::CurrentTimecodeDisplay(),
|
||||
true);
|
||||
QToolTip::showText(QCursor::pos(),
|
||||
tooltip_text,
|
||||
|
||||
@@ -58,7 +58,7 @@ void TimelineView::SlipTool::ProcessDrag(const QPoint &mouse_pos)
|
||||
int64_t earliest_timestamp = olive::time_to_timestamp(time_movement, parent()->timebase_);
|
||||
QString tooltip_text = olive::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase_,
|
||||
kTimecodeDisplay,
|
||||
olive::CurrentTimecodeDisplay(),
|
||||
true);
|
||||
QToolTip::showText(QCursor::pos(),
|
||||
tooltip_text,
|
||||
|
||||
@@ -156,7 +156,7 @@ void TimeRuler::paintEvent(QPaintEvent *)
|
||||
if (text_visible_) {
|
||||
QFontMetrics fm = p.fontMetrics();
|
||||
double width_of_second = scale_;
|
||||
int average_text_width = QFontMetricsWidth(&fm, olive::timestamp_to_timecode(0, timebase_, kTimecodeDisplay));
|
||||
int average_text_width = QFontMetricsWidth(&fm, olive::timestamp_to_timecode(0, timebase_, olive::CurrentTimecodeDisplay()));
|
||||
half_average_text_width = average_text_width/2;
|
||||
while (width_of_second * text_skip < average_text_width) {
|
||||
text_skip++;
|
||||
@@ -202,7 +202,7 @@ void TimeRuler::paintEvent(QPaintEvent *)
|
||||
|
||||
// Try to draw text here
|
||||
if (text_visible_ && sec%text_skip == 0) {
|
||||
QString timecode_string = olive::timestamp_to_timecode(sec, timebase_, kTimecodeDisplay);
|
||||
QString timecode_string = olive::timestamp_to_timecode(sec, timebase_, olive::CurrentTimecodeDisplay());
|
||||
|
||||
int text_x = i;
|
||||
|
||||
|
||||
@@ -34,24 +34,25 @@ Toolbar::Toolbar(QWidget *parent) :
|
||||
layout_->setMargin(0);
|
||||
|
||||
// Create standard tool buttons
|
||||
btn_pointer_tool_ = CreateToolButton(olive::icon::ToolPointer, olive::tool::kPointer);
|
||||
btn_edit_tool_ = CreateToolButton(olive::icon::ToolEdit, olive::tool::kEdit);
|
||||
btn_ripple_tool_ = CreateToolButton(olive::icon::ToolRipple, olive::tool::kRipple);
|
||||
btn_rolling_tool_ = CreateToolButton(olive::icon::ToolRolling, olive::tool::kRolling);
|
||||
btn_razor_tool_ = CreateToolButton(olive::icon::ToolRazor, olive::tool::kRazor);
|
||||
btn_slip_tool_ = CreateToolButton(olive::icon::ToolSlip, olive::tool::kSlip);
|
||||
btn_slide_tool_ = CreateToolButton(olive::icon::ToolSlide, olive::tool::kSlide);
|
||||
btn_hand_tool_ = CreateToolButton(olive::icon::ToolHand, olive::tool::kHand);
|
||||
btn_zoom_tool_ = CreateToolButton(olive::icon::ZoomIn, olive::tool::kZoom);
|
||||
btn_record_ = CreateToolButton(olive::icon::Record, olive::tool::kRecord);
|
||||
btn_transition_tool_ = CreateToolButton(olive::icon::ToolTransition, olive::tool::kTransition);
|
||||
btn_add_ = CreateToolButton(olive::icon::Add, olive::tool::kAdd);
|
||||
btn_pointer_tool_ = CreateToolButton(olive::tool::kPointer);
|
||||
btn_edit_tool_ = CreateToolButton(olive::tool::kEdit);
|
||||
btn_ripple_tool_ = CreateToolButton(olive::tool::kRipple);
|
||||
btn_rolling_tool_ = CreateToolButton(olive::tool::kRolling);
|
||||
btn_razor_tool_ = CreateToolButton(olive::tool::kRazor);
|
||||
btn_slip_tool_ = CreateToolButton(olive::tool::kSlip);
|
||||
btn_slide_tool_ = CreateToolButton(olive::tool::kSlide);
|
||||
btn_hand_tool_ = CreateToolButton(olive::tool::kHand);
|
||||
btn_zoom_tool_ = CreateToolButton(olive::tool::kZoom);
|
||||
btn_record_ = CreateToolButton(olive::tool::kRecord);
|
||||
btn_transition_tool_ = CreateToolButton(olive::tool::kTransition);
|
||||
btn_add_ = CreateToolButton(olive::tool::kAdd);
|
||||
|
||||
// Create snapping button, which is not actually a tool, it's a toggle option
|
||||
btn_snapping_toggle_ = CreateNonToolButton(olive::icon::Snapping);
|
||||
btn_snapping_toggle_ = CreateNonToolButton();
|
||||
connect(btn_snapping_toggle_, SIGNAL(clicked(bool)), this, SLOT(SnappingButtonClicked(bool)));
|
||||
|
||||
Retranslate();
|
||||
UpdateIcons();
|
||||
}
|
||||
|
||||
void Toolbar::SetTool(const olive::tool::Tool& tool)
|
||||
@@ -74,6 +75,8 @@ void Toolbar::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
} else if (e->type() == QEvent::StyleChange) {
|
||||
UpdateIcons();
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
@@ -95,10 +98,27 @@ void Toolbar::Retranslate()
|
||||
btn_snapping_toggle_->setToolTip(tr("Toggle Snapping"));
|
||||
}
|
||||
|
||||
ToolbarButton* Toolbar::CreateToolButton(const QIcon &icon, const olive::tool::Tool& tool)
|
||||
void Toolbar::UpdateIcons()
|
||||
{
|
||||
btn_pointer_tool_->setIcon(olive::icon::ToolPointer);
|
||||
btn_edit_tool_->setIcon(olive::icon::ToolEdit);
|
||||
btn_ripple_tool_->setIcon(olive::icon::ToolRipple);
|
||||
btn_rolling_tool_->setIcon(olive::icon::ToolRolling);
|
||||
btn_razor_tool_->setIcon(olive::icon::ToolRazor);
|
||||
btn_slip_tool_->setIcon(olive::icon::ToolSlip);
|
||||
btn_slide_tool_->setIcon(olive::icon::ToolSlide);
|
||||
btn_hand_tool_->setIcon(olive::icon::ToolHand);
|
||||
btn_zoom_tool_->setIcon(olive::icon::ZoomIn);
|
||||
btn_record_->setIcon(olive::icon::Record);
|
||||
btn_transition_tool_->setIcon(olive::icon::ToolTransition);
|
||||
btn_add_->setIcon(olive::icon::Add);
|
||||
btn_snapping_toggle_->setIcon(olive::icon::Snapping);
|
||||
}
|
||||
|
||||
ToolbarButton* Toolbar::CreateToolButton(const olive::tool::Tool& tool)
|
||||
{
|
||||
// Create a ToolbarButton object
|
||||
ToolbarButton* b = new ToolbarButton(this, icon, tool);
|
||||
ToolbarButton* b = new ToolbarButton(this, tool);
|
||||
|
||||
// Add it to the layout
|
||||
layout_->addWidget(b);
|
||||
@@ -112,10 +132,10 @@ ToolbarButton* Toolbar::CreateToolButton(const QIcon &icon, const olive::tool::T
|
||||
return b;
|
||||
}
|
||||
|
||||
ToolbarButton *Toolbar::CreateNonToolButton(const QIcon &icon)
|
||||
ToolbarButton *Toolbar::CreateNonToolButton()
|
||||
{
|
||||
// Create a ToolbarButton object
|
||||
ToolbarButton* b = new ToolbarButton(this, icon, olive::tool::kNone);
|
||||
ToolbarButton* b = new ToolbarButton(this, olive::tool::kNone);
|
||||
|
||||
// Add it to the layout
|
||||
layout_->addWidget(b);
|
||||
|
||||
@@ -112,6 +112,11 @@ private:
|
||||
*/
|
||||
void Retranslate();
|
||||
|
||||
/**
|
||||
* @brief Update icons after a style change
|
||||
*/
|
||||
void UpdateIcons();
|
||||
|
||||
/**
|
||||
* @brief Internal convenience function for creating tool buttons quickly
|
||||
*
|
||||
@@ -125,7 +130,7 @@ private:
|
||||
*
|
||||
* The created ToolbarButton. The button parent is automatically set to `this`.
|
||||
*/
|
||||
ToolbarButton* CreateToolButton(const QIcon &icon, const olive::tool::Tool& tool);
|
||||
ToolbarButton* CreateToolButton(const olive::tool::Tool& tool);
|
||||
|
||||
/**
|
||||
* @brief Internal convenience function for creating buttons quickly
|
||||
@@ -138,7 +143,7 @@ private:
|
||||
*
|
||||
* The created ToolbarButton. The button parent is automatically set to `this`.
|
||||
*/
|
||||
ToolbarButton* CreateNonToolButton(const QIcon &icon);
|
||||
ToolbarButton* CreateNonToolButton();
|
||||
|
||||
/**
|
||||
* @brief Internal layout used for buttons
|
||||
|
||||
@@ -20,12 +20,11 @@
|
||||
|
||||
#include "toolbarbutton.h"
|
||||
|
||||
ToolbarButton::ToolbarButton(QWidget *parent, const QIcon &icon, const olive::tool::Tool &tool) :
|
||||
ToolbarButton::ToolbarButton(QWidget *parent, const olive::tool::Tool &tool) :
|
||||
QPushButton(parent),
|
||||
tool_(tool)
|
||||
{
|
||||
setCheckable(true);
|
||||
setIcon(icon);
|
||||
}
|
||||
|
||||
const olive::tool::Tool &ToolbarButton::tool()
|
||||
|
||||
@@ -38,15 +38,11 @@ public:
|
||||
*
|
||||
* QWidget parent. Almost always an instance of Toolbar.
|
||||
*
|
||||
* @param icon
|
||||
*
|
||||
* Icon to set this QWidget to.
|
||||
*
|
||||
* @param tool
|
||||
*
|
||||
* Tool object. Must be a member of enum olive::tool::Tool, including kNone if this button does not represent a tool.
|
||||
*/
|
||||
ToolbarButton(QWidget* parent, const QIcon& icon, const olive::tool::Tool& tool);
|
||||
ToolbarButton(QWidget* parent, const olive::tool::Tool& tool);
|
||||
|
||||
/**
|
||||
* @brief Retrieve tool ID that this button represents
|
||||
|
||||
Reference in New Issue
Block a user