Skip to content

Commit

Permalink
stash SVGs that are continuously reused
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Mar 10, 2019
1 parent 9fc1bc3 commit d768871
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 194 deletions.
21 changes: 0 additions & 21 deletions oliveglobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,27 +302,6 @@ void OliveGlobal::open_project_worker(const QString& fn, bool autorecovery) {
olive::UndoStack.clear();
}

QIcon OliveGlobal::CreateIconFromSVG(const QString &path)
{
QIcon icon;

QPixmap normal(path);
icon.addPixmap(normal, QIcon::Normal, QIcon::On);

QPixmap disabled(normal.size());
disabled.fill(Qt::transparent);

// draw semi-transparent version of icon for the disabled variant
QPainter p(&disabled);
p.setOpacity(0.5);
p.drawPixmap(0, 0, normal);
p.end();

icon.addPixmap(disabled, QIcon::Disabled, QIcon::On);

return icon;
}

void OliveGlobal::undo() {
// workaround to prevent crash (and also users should never need to do this)
if (!panel_timeline->importing) {
Expand Down
9 changes: 0 additions & 9 deletions oliveglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ class OliveGlobal : public QObject {
*/
void load_translation_from_config();

/**
* @brief Converts an SVG into a QIcon with a semi-transparent for the QIcon::Disabled property
*
* @param path
*
* Path to SVG file
*/
static QIcon CreateIconFromSVG(const QString& path);

public slots:
/**
* @brief Undo user's last action
Expand Down
17 changes: 9 additions & 8 deletions panels/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "io/clipboard.h"
#include "ui/sourcetable.h"
#include "ui/sourceiconview.h"
#include "ui/icons.h"
#include "ui/menuhelper.h"
#include "ui/mediaiconservice.h"
#include "project/sourcescommon.h"
Expand Down Expand Up @@ -102,31 +103,31 @@ Project::Project(QWidget *parent) :
toolbar->setSpacing(0);

QPushButton* toolbar_new = new QPushButton();
toolbar_new->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/add-button.svg")));
toolbar_new->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/add-button.svg")));
toolbar_new->setToolTip("New");
connect(toolbar_new, SIGNAL(clicked(bool)), this, SLOT(make_new_menu()));
toolbar->addWidget(toolbar_new);

QPushButton* toolbar_open = new QPushButton();
toolbar_open->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/open.svg")));
toolbar_open->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/open.svg")));
toolbar_open->setToolTip("Open Project");
connect(toolbar_open, SIGNAL(clicked(bool)), olive::Global.get(), SLOT(open_project()));
toolbar->addWidget(toolbar_open);

QPushButton* toolbar_save = new QPushButton();
toolbar_save->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/save.svg")));
toolbar_save->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/save.svg")));
toolbar_save->setToolTip("Save Project");
connect(toolbar_save, SIGNAL(clicked(bool)), olive::Global.get(), SLOT(save_project()));
toolbar->addWidget(toolbar_save);

QPushButton* toolbar_undo = new QPushButton();
toolbar_undo->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/undo.svg")));
toolbar_undo->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/undo.svg")));
toolbar_undo->setToolTip("Undo");
connect(toolbar_undo, SIGNAL(clicked(bool)), olive::Global.get(), SLOT(undo()));
toolbar->addWidget(toolbar_undo);

QPushButton* toolbar_redo = new QPushButton();
toolbar_redo->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/redo.svg")));
toolbar_redo->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/redo.svg")));
toolbar_redo->setToolTip("Redo");
connect(toolbar_redo, SIGNAL(clicked(bool)), olive::Global.get(), SLOT(redo()));
toolbar->addWidget(toolbar_redo);
Expand All @@ -137,13 +138,13 @@ Project::Project(QWidget *parent) :
toolbar->addWidget(toolbar_search);

QPushButton* toolbar_tree_view = new QPushButton();
toolbar_tree_view->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/treeview.svg")));
toolbar_tree_view->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/treeview.svg")));
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();
toolbar_icon_view->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/iconview.svg")));
toolbar_icon_view->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/iconview.svg")));
toolbar_icon_view->setToolTip("Icon View");
connect(toolbar_icon_view, SIGNAL(clicked(bool)), this, SLOT(set_icon_view()));
toolbar->addWidget(toolbar_icon_view);
Expand Down Expand Up @@ -174,7 +175,7 @@ Project::Project(QWidget *parent) :
icon_view_controls->setSpacing(0);

directory_up = new QPushButton();
directory_up->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/dirup.svg")));
directory_up->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/dirup.svg")));
directory_up->setEnabled(false);
icon_view_controls->addWidget(directory_up);

Expand Down
27 changes: 14 additions & 13 deletions panels/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "project/projectelements.h"

#include "ui/timelinewidget.h"
#include "ui/icons.h"
#include "ui/viewerwidget.h"
#include "rendering/audio.h"
#include "rendering/cacher.h"
Expand Down Expand Up @@ -1870,84 +1871,84 @@ void Timeline::setup_ui() {
tool_buttons_layout->setMargin(0);

toolArrowButton = new QPushButton();
toolArrowButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/arrow.svg")));
toolArrowButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/arrow.svg")));
toolArrowButton->setCheckable(true);
toolArrowButton->setProperty("tool", TIMELINE_TOOL_POINTER);
connect(toolArrowButton, SIGNAL(clicked(bool)), this, SLOT(set_tool()));
tool_buttons_layout->addWidget(toolArrowButton);

toolEditButton = new QPushButton();
toolEditButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/beam.svg")));
toolEditButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/beam.svg")));
toolEditButton->setCheckable(true);
toolEditButton->setProperty("tool", TIMELINE_TOOL_EDIT);
connect(toolEditButton, SIGNAL(clicked(bool)), this, SLOT(set_tool()));
tool_buttons_layout->addWidget(toolEditButton);

toolRippleButton = new QPushButton();
toolRippleButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/ripple.svg")));
toolRippleButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/ripple.svg")));
toolRippleButton->setCheckable(true);
toolRippleButton->setProperty("tool", TIMELINE_TOOL_RIPPLE);
connect(toolRippleButton, SIGNAL(clicked(bool)), this, SLOT(set_tool()));
tool_buttons_layout->addWidget(toolRippleButton);

toolRazorButton = new QPushButton();
toolRazorButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/razor.svg")));
toolRazorButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/razor.svg")));
toolRazorButton->setCheckable(true);
toolRazorButton->setProperty("tool", TIMELINE_TOOL_RAZOR);
connect(toolRazorButton, SIGNAL(clicked(bool)), this, SLOT(set_tool()));
tool_buttons_layout->addWidget(toolRazorButton);

toolSlipButton = new QPushButton();
toolSlipButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/slip.svg")));
toolSlipButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/slip.svg")));
toolSlipButton->setCheckable(true);
toolSlipButton->setProperty("tool", TIMELINE_TOOL_SLIP);
connect(toolSlipButton, SIGNAL(clicked(bool)), this, SLOT(set_tool()));
tool_buttons_layout->addWidget(toolSlipButton);

toolSlideButton = new QPushButton();
toolSlideButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/slide.svg")));
toolSlideButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/slide.svg")));
toolSlideButton->setCheckable(true);
toolSlideButton->setProperty("tool", TIMELINE_TOOL_SLIDE);
connect(toolSlideButton, SIGNAL(clicked(bool)), this, SLOT(set_tool()));
tool_buttons_layout->addWidget(toolSlideButton);

toolHandButton = new QPushButton();
toolHandButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/hand.svg")));
toolHandButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/hand.svg")));
toolHandButton->setCheckable(true);

toolHandButton->setProperty("tool", TIMELINE_TOOL_HAND);
connect(toolHandButton, SIGNAL(clicked(bool)), this, SLOT(set_tool()));
tool_buttons_layout->addWidget(toolHandButton);
toolTransitionButton = new QPushButton();
toolTransitionButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/transition-tool.svg")));
toolTransitionButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/transition-tool.svg")));
toolTransitionButton->setCheckable(true);
connect(toolTransitionButton, SIGNAL(clicked(bool)), this, SLOT(transition_tool_click()));
tool_buttons_layout->addWidget(toolTransitionButton);

snappingButton = new QPushButton();
snappingButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/magnet.svg")));
snappingButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/magnet.svg")));
snappingButton->setCheckable(true);
snappingButton->setChecked(true);
connect(snappingButton, SIGNAL(toggled(bool)), this, SLOT(snapping_clicked(bool)));
tool_buttons_layout->addWidget(snappingButton);

zoomInButton = new QPushButton();
zoomInButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/zoomin.svg")));
zoomInButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/zoomin.svg")));
connect(zoomInButton, SIGNAL(clicked(bool)), this, SLOT(zoom_in()));
tool_buttons_layout->addWidget(zoomInButton);

zoomOutButton = new QPushButton();
zoomOutButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/zoomout.svg")));
zoomOutButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/zoomout.svg")));
connect(zoomOutButton, SIGNAL(clicked(bool)), this, SLOT(zoom_out()));
tool_buttons_layout->addWidget(zoomOutButton);

recordButton = new QPushButton();
recordButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/record.svg")));
recordButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/record.svg")));
connect(recordButton, SIGNAL(clicked(bool)), this, SLOT(record_btn_click()));
tool_buttons_layout->addWidget(recordButton);

addButton = new QPushButton();
addButton->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/add-button.svg")));
addButton->setIcon(olive::icon::CreateIconFromSVG(QStringLiteral(":/icons/add-button.svg")));
connect(addButton, SIGNAL(clicked()), this, SLOT(add_btn_click()));
tool_buttons_layout->addWidget(addButton);

Expand Down
20 changes: 11 additions & 9 deletions panels/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "ui/labelslider.h"
#include "ui/timelineheader.h"
#include "ui/resizablescrollbar.h"
#include "ui/icons.h"
#include "oliveglobal.h"
#include "debug.h"

Expand Down Expand Up @@ -669,30 +670,27 @@ void Viewer::setup_ui() {
playback_control_layout->setMargin(0);

go_to_start_button = new QPushButton();
go_to_start_button->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/prev.svg")));
go_to_start_button->setIcon(olive::icon::ViewerGoToStart);
connect(go_to_start_button, SIGNAL(clicked(bool)), this, SLOT(go_to_in()));
playback_control_layout->addWidget(go_to_start_button);

prev_frame_button = new QPushButton();
prev_frame_button->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/rew.svg")));
prev_frame_button->setIcon(olive::icon::ViewerPrevFrame);
connect(prev_frame_button, SIGNAL(clicked(bool)), this, SLOT(previous_frame()));
playback_control_layout->addWidget(prev_frame_button);

play_icon_ = OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/play.svg"));
pause_icon_ = QPixmap(":/icons/pause.svg");

play_button = new QPushButton();
play_button->setIcon(play_icon_);
play_button->setIcon(olive::icon::ViewerPlay);
connect(play_button, SIGNAL(clicked(bool)), this, SLOT(toggle_play()));
playback_control_layout->addWidget(play_button);

next_frame_button = new QPushButton();
next_frame_button->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/ff.svg")));
next_frame_button->setIcon(olive::icon::ViewerNextFrame);
connect(next_frame_button, SIGNAL(clicked(bool)), this, SLOT(next_frame()));
playback_control_layout->addWidget(next_frame_button);

go_to_end_frame = new QPushButton();
go_to_end_frame->setIcon(OliveGlobal::CreateIconFromSVG(QStringLiteral(":/icons/next.svg")));
go_to_end_frame->setIcon(olive::icon::ViewerGoToEnd);
connect(go_to_end_frame, SIGNAL(clicked(bool)), this, SLOT(go_to_out()));
playback_control_layout->addWidget(go_to_end_frame);

Expand Down Expand Up @@ -737,6 +735,7 @@ void Viewer::set_media(Media* m) {
seq->workarea_out = footage->out;
}

// FIXME: Move this magic number to Config
seq->frame_rate = 30;

if (footage->video_tracks.size() > 0) {
Expand All @@ -750,13 +749,15 @@ void Viewer::set_media(Media* m) {
c->set_timeline_in(0);
c->set_timeline_out(footage->get_length_in_frames(seq->frame_rate));
if (c->timeline_out() <= 0) {
// FIXME: Move this magic number to Config
c->set_timeline_out(150);
}
c->set_track(-1);
c->set_clip_in(0);
c->refresh();
seq->clips.append(c);
} else {
// FIXME: Move this magic number to Config
seq->width = 1920;
seq->height = 1080;
}
Expand All @@ -781,6 +782,7 @@ void Viewer::set_media(Media* m) {
viewer_widget->frame_update();
}
} else {
// FIXME: Move this magic number to Config
seq->audio_frequency = 48000;
}

Expand Down Expand Up @@ -907,5 +909,5 @@ void Viewer::set_sequence(bool main, SequencePtr s) {
}

void Viewer::set_playpause_icon(bool play) {
play_button->setIcon(play ? play_icon_ : pause_icon_);
play_button->setIcon(play ? olive::icon::ViewerPlay : olive::icon::ViewerPause);
}
3 changes: 0 additions & 3 deletions panels/viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ private slots:
long get_seq_in();
long get_seq_out();

QIcon play_icon_;
QIcon pause_icon_;

void setup_ui();

ResizableScrollBar* horizontal_bar;
Expand Down
5 changes: 3 additions & 2 deletions project/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "io/config.h"
#include "panels/viewer.h"
#include "panels/project.h"
#include "ui/icons.h"
#include "projectmodel.h"

#include <QCoreApplication>
Expand Down Expand Up @@ -86,7 +87,7 @@ void Media::set_footage(FootagePtr f) {
}

void Media::set_sequence(SequencePtr s) {
set_icon(":/icons/sequence.svg");
set_icon(olive::icon::MediaSequence);
type = MEDIA_TYPE_SEQUENCE;
object = VoidPtr(s);
if (s != nullptr) update_tooltip();
Expand All @@ -96,7 +97,7 @@ void Media::set_folder() {
if (folder_name.isEmpty()) {
folder_name = QCoreApplication::translate("Media", "New Folder");
}
set_icon(":/icons/folder.svg");
set_icon(olive::icon::MediaFolder);
type = MEDIA_TYPE_FOLDER;
object = nullptr;
}
Expand Down
Loading

0 comments on commit d768871

Please sign in to comment.