mainwindow: improved panel organization
This commit is contained in:
@@ -37,7 +37,6 @@ add_subdirectory(nodetableview)
|
||||
add_subdirectory(nodetreeview)
|
||||
add_subdirectory(nodevaluetree)
|
||||
add_subdirectory(nodeview)
|
||||
add_subdirectory(panel)
|
||||
add_subdirectory(path)
|
||||
add_subdirectory(pixelsampler)
|
||||
add_subdirectory(playbackcontrols)
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2022 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/panel/panel.h
|
||||
widget/panel/panel.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -1,166 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 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/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "panel.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#include <QStyleOption>
|
||||
#include <QVariant>
|
||||
|
||||
#include "panel/panelmanager.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
PanelWidget::PanelWidget(const QString &object_name, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
border_visible_(false),
|
||||
signal_instead_of_close_(false)
|
||||
{
|
||||
setObjectName(object_name);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
connect(this, &PanelWidget::visibilityChanged, this, &PanelWidget::PanelVisibilityChanged);
|
||||
|
||||
PanelManager::instance()->RegisterPanel(this);
|
||||
}
|
||||
|
||||
PanelWidget::~PanelWidget()
|
||||
{
|
||||
PanelManager::instance()->UnregisterPanel(this);
|
||||
}
|
||||
|
||||
void PanelWidget::SetMovementLocked(bool locked)
|
||||
{
|
||||
if (locked) {
|
||||
// Disable moving on QDockWidget
|
||||
setFeatures(features() & ~QDockWidget::DockWidgetMovable);
|
||||
|
||||
// Hide the title bar (only real way to do this is to replace it with an empty QWidget)
|
||||
setTitleBarWidget(new QWidget(this));
|
||||
} else {
|
||||
// Re-enable moving on QDockWidget
|
||||
setFeatures(features() | QDockWidget::DockWidgetMovable);
|
||||
|
||||
// Set the "custom" titlebar to null so the default gets restored
|
||||
setTitleBarWidget(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void PanelWidget::SetBorderVisible(bool enabled)
|
||||
{
|
||||
border_visible_ = enabled;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void PanelWidget::SetTitle(const QString &t)
|
||||
{
|
||||
title_ = t;
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
void PanelWidget::SetSubtitle(const QString &t)
|
||||
{
|
||||
subtitle_ = t;
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
void PanelWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
// Perform default behavior
|
||||
QDockWidget::paintEvent(event);
|
||||
|
||||
// Check if this panel (or a child of it) has focus using PanelFocusManager
|
||||
if (border_visible_) {
|
||||
|
||||
// Draw a highlight border if so
|
||||
QPainter p(this);
|
||||
|
||||
// We need to adjust the rect by 1 pixel since the bottom and right are "offscreen"
|
||||
QRect highlight_border = rect();
|
||||
highlight_border.adjust(0, 0, -1, -1);
|
||||
|
||||
// Set the color to the palette's highlight color
|
||||
p.setPen(palette().highlight().color());
|
||||
|
||||
// Draw the highlight border
|
||||
p.drawRect(highlight_border);
|
||||
}
|
||||
}
|
||||
|
||||
void PanelWidget::UpdateTitle()
|
||||
{
|
||||
// If there's no subtitle, just use the title. Otherwise, we set a formatted combination of the two that can
|
||||
// differ based on translation
|
||||
if (subtitle_.isEmpty()) {
|
||||
setWindowTitle(title_);
|
||||
} else {
|
||||
setWindowTitle(tr("%1: %2").arg(title_, subtitle_));
|
||||
}
|
||||
}
|
||||
|
||||
void PanelWidget::PanelVisibilityChanged(bool e)
|
||||
{
|
||||
if (e) {
|
||||
setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void PanelWidget::SetSignalInsteadOfClose(bool e)
|
||||
{
|
||||
signal_instead_of_close_ = e;
|
||||
}
|
||||
|
||||
void PanelWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (signal_instead_of_close_) {
|
||||
event->ignore();
|
||||
emit CloseRequested();
|
||||
} else {
|
||||
QDockWidget::closeEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void PanelWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
}
|
||||
QDockWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
void PanelWidget::Retranslate()
|
||||
{
|
||||
}
|
||||
|
||||
void PanelWidget::SetWidgetWithPadding(QWidget *widget)
|
||||
{
|
||||
QWidget* wrapper = new QWidget();
|
||||
QHBoxLayout* layout = new QHBoxLayout(wrapper);
|
||||
layout->setContentsMargins(layout->contentsMargins() / 2);
|
||||
layout->addWidget(widget);
|
||||
setWidget(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,251 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 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/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PANEL_WIDGET_H
|
||||
#define PANEL_WIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QEvent>
|
||||
|
||||
#include "common/define.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
/**
|
||||
* @brief A widget that is always dockable within the MainWindow.
|
||||
*/
|
||||
class PanelWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief PanelWidget Constructor
|
||||
*
|
||||
* @param parent
|
||||
*
|
||||
* The PanelWidget's parent, enforced to help with memory handling. Most of the time this will be an instance of
|
||||
* MainWindow.
|
||||
*/
|
||||
PanelWidget(const QString& object_name, QWidget* parent);
|
||||
|
||||
virtual ~PanelWidget() override;
|
||||
|
||||
/**
|
||||
* @brief Set whether panel movement is locked or not
|
||||
*/
|
||||
void SetMovementLocked(bool locked);
|
||||
|
||||
/**
|
||||
* @brief Set visibility of panel's highlighted border, mostly used for showing panel focus
|
||||
*
|
||||
* @param enabled
|
||||
*/
|
||||
void SetBorderVisible(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief If enabled, sends signal CloseRequested() when the user closes instead of closing
|
||||
*
|
||||
* Defaults to FALSE. Use this to override default panel closing functionality.
|
||||
*/
|
||||
void SetSignalInsteadOfClose(bool e);
|
||||
|
||||
/**
|
||||
* @brief Called whenever this panel is focused and user uses "Zoom In" (either in menus or as a keyboard shortcut)
|
||||
*
|
||||
* This function is up to the Panel's interpretation of what the user intends to zoom into. Default behavior is a
|
||||
* no-op.
|
||||
*/
|
||||
virtual void ZoomIn(){}
|
||||
|
||||
/**
|
||||
* @brief Called whenever this panel is focused and user uses "Zoom Out" (either in menus or as a keyboard shortcut)
|
||||
*
|
||||
* This function is up to the Panel's interpretation of what the user intends to zoom out of. Default behavior is a
|
||||
* no-op.
|
||||
*/
|
||||
virtual void ZoomOut(){}
|
||||
|
||||
virtual void GoToStart(){}
|
||||
|
||||
virtual void PrevFrame(){}
|
||||
|
||||
/**
|
||||
* @brief Called whenever this panel is focused and user uses "Play/Pause" (either in menus or as a keyboard shortcut)
|
||||
*
|
||||
* This function is up to the Panel's interpretation of what the user intends to zoom out of. Default behavior is a
|
||||
* no-op.
|
||||
*/
|
||||
virtual void PlayPause(){}
|
||||
|
||||
virtual void PlayInToOut(){}
|
||||
|
||||
virtual void NextFrame(){}
|
||||
|
||||
virtual void GoToEnd(){}
|
||||
|
||||
virtual void SelectAll(){}
|
||||
|
||||
virtual void DeselectAll(){}
|
||||
|
||||
virtual void RippleToIn(){}
|
||||
|
||||
virtual void RippleToOut(){}
|
||||
|
||||
virtual void EditToIn(){}
|
||||
|
||||
virtual void EditToOut(){}
|
||||
|
||||
virtual void ShuttleLeft(){}
|
||||
|
||||
virtual void ShuttleStop(){}
|
||||
|
||||
virtual void ShuttleRight(){}
|
||||
|
||||
virtual void GoToPrevCut(){}
|
||||
|
||||
virtual void GoToNextCut(){}
|
||||
|
||||
virtual void RenameSelected(){}
|
||||
|
||||
virtual void DeleteSelected(){}
|
||||
|
||||
virtual void RippleDelete(){}
|
||||
|
||||
virtual void IncreaseTrackHeight(){}
|
||||
|
||||
virtual void DecreaseTrackHeight(){}
|
||||
|
||||
virtual void SetIn(){}
|
||||
|
||||
virtual void SetOut(){}
|
||||
|
||||
virtual void ResetIn(){}
|
||||
|
||||
virtual void ResetOut(){}
|
||||
|
||||
virtual void ClearInOut(){}
|
||||
|
||||
virtual void SetMarker(){}
|
||||
|
||||
virtual void ToggleLinks(){}
|
||||
|
||||
virtual void CutSelected(){}
|
||||
|
||||
virtual void CopySelected(){}
|
||||
|
||||
virtual void Paste(){}
|
||||
|
||||
virtual void PasteInsert(){}
|
||||
|
||||
virtual void ToggleShowAll(){}
|
||||
|
||||
virtual void GoToIn(){}
|
||||
|
||||
virtual void GoToOut(){}
|
||||
|
||||
virtual void DeleteInToOut(){}
|
||||
|
||||
virtual void RippleDeleteInToOut(){}
|
||||
|
||||
virtual void ToggleSelectedEnabled(){}
|
||||
|
||||
virtual void Duplicate(){}
|
||||
|
||||
virtual void SetColorLabel(int){}
|
||||
|
||||
virtual void NudgeLeft(){}
|
||||
|
||||
virtual void NudgeRight(){}
|
||||
|
||||
virtual void MoveInToPlayhead(){}
|
||||
|
||||
virtual void MoveOutToPlayhead(){}
|
||||
|
||||
signals:
|
||||
void CloseRequested();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief paintEvent
|
||||
* @param event
|
||||
*/
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
virtual void changeEvent(QEvent* e) override;
|
||||
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
virtual void Retranslate();
|
||||
|
||||
void SetWidgetWithPadding(QWidget* widget);
|
||||
|
||||
protected slots:
|
||||
/**
|
||||
* @brief Set panel's title
|
||||
*
|
||||
* Use this function to set the title of the panel.
|
||||
*
|
||||
* A PanelWidget has the default format of "Title: Subtitle" (can differ depending on translation). If no Subtitle
|
||||
* is set, the title will just be formatted "Title".
|
||||
*
|
||||
* @param t
|
||||
*
|
||||
* String to set the title to
|
||||
*/
|
||||
void SetTitle(const QString& t);
|
||||
|
||||
/**
|
||||
* @brief Set panel's subtitle
|
||||
*
|
||||
* Use this function to set the subtitle of the panel.
|
||||
*
|
||||
* A PanelWidget has the default format of "Title: Subtitle" (can differ depending on translation). If no Subtitle
|
||||
* is set, the title will just be formatted "Title".
|
||||
*
|
||||
* @param t
|
||||
*
|
||||
* String to set the subtitle to
|
||||
*/
|
||||
void SetSubtitle(const QString& t);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Internal function that sets the QDockWidget's window title whenever the title/subtitle change.
|
||||
*
|
||||
* Should be called any time a change is made to title_ or subtitle_
|
||||
*/
|
||||
void UpdateTitle();
|
||||
|
||||
QString title_;
|
||||
|
||||
QString subtitle_;
|
||||
|
||||
bool border_visible_;
|
||||
|
||||
bool signal_instead_of_close_;
|
||||
|
||||
private slots:
|
||||
void PanelVisibilityChanged(bool e);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PANEL_WIDGET_H
|
||||
@@ -495,12 +495,12 @@ void ProjectExplorer::ReplaceSelectedFootage()
|
||||
|
||||
void ProjectExplorer::OpenContextMenuItemInNewTab()
|
||||
{
|
||||
Core::instance()->main_window()->FolderOpen(project(), static_cast<Folder*>(context_menu_items_.first()), false);
|
||||
Core::instance()->main_window()->OpenFolder(project(), static_cast<Folder*>(context_menu_items_.first()), false);
|
||||
}
|
||||
|
||||
void ProjectExplorer::OpenContextMenuItemInNewWindow()
|
||||
{
|
||||
Core::instance()->main_window()->FolderOpen(project(), static_cast<Folder*>(context_menu_items_.first()), true);
|
||||
Core::instance()->main_window()->OpenFolder(project(), static_cast<Folder*>(context_menu_items_.first()), true);
|
||||
}
|
||||
|
||||
void ProjectExplorer::ContextMenuStartProxy(QAction *a)
|
||||
|
||||
Reference in New Issue
Block a user