recreating menu structure
This commit is contained in:
@@ -14,11 +14,12 @@
|
||||
# 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(viewer)
|
||||
add_subdirectory(menu)
|
||||
add_subdirectory(panel)
|
||||
add_subdirectory(playbackcontrols)
|
||||
add_subdirectory(projectexplorer)
|
||||
add_subdirectory(projecttoolbar)
|
||||
add_subdirectory(viewer)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# 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/menu/menu.h
|
||||
widget/menu/menu.cpp
|
||||
widget/menu/menushared.h
|
||||
widget/menu/menushared.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "menu.h"
|
||||
|
||||
#include "ui/style/style.h"
|
||||
|
||||
Menu::Menu(QMenuBar *bar, const QObject* receiver, const char* member) :
|
||||
QMenu(bar)
|
||||
{
|
||||
SetStyling();
|
||||
|
||||
bar->addMenu(this);
|
||||
|
||||
if (receiver != nullptr) {
|
||||
connect(this, SIGNAL(aboutToShow()), receiver, member);
|
||||
}
|
||||
}
|
||||
|
||||
Menu::Menu(Menu *menu, const QObject *receiver, const char *member)
|
||||
{
|
||||
SetStyling();
|
||||
|
||||
menu->addMenu(this);
|
||||
|
||||
if (receiver != nullptr) {
|
||||
connect(this, SIGNAL(aboutToShow()), receiver, member);
|
||||
}
|
||||
}
|
||||
|
||||
QAction *Menu::AddItem(const QString &id,
|
||||
const QObject *receiver,
|
||||
const char *member,
|
||||
const QString &key)
|
||||
{
|
||||
QAction* a = CreateItem(this, id, receiver, member, key);
|
||||
|
||||
addAction(a);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
QAction *Menu::CreateItem(QObject* parent,
|
||||
const QString &id,
|
||||
const QObject *receiver,
|
||||
const char *member,
|
||||
const QString &key)
|
||||
{
|
||||
QAction* a = new QAction(parent);
|
||||
|
||||
a->setProperty("id", id);
|
||||
|
||||
if (!key.isEmpty()) {
|
||||
a->setShortcut(key);
|
||||
a->setProperty("keydefault", key);
|
||||
}
|
||||
|
||||
connect(a, SIGNAL(triggered(bool)), receiver, member);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
void Menu::SetStyling()
|
||||
{
|
||||
//if (olive::config.use_native_menu_styling) {
|
||||
olive::style::WidgetSetNative(this);
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef WIDGETMENU_H
|
||||
#define WIDGETMENU_H
|
||||
|
||||
#include <QMenuBar>
|
||||
#include <QMenu>
|
||||
|
||||
class Menu : public QMenu
|
||||
{
|
||||
public:
|
||||
Menu(QMenuBar* bar, const QObject* receiver = nullptr, const char* member = nullptr);
|
||||
Menu(Menu* bar, const QObject* receiver = nullptr, const char* member = nullptr);
|
||||
|
||||
QAction* AddItem(const QString& id,
|
||||
const QObject* receiver,
|
||||
const char* member,
|
||||
const QString &key = QString());
|
||||
|
||||
static QAction* CreateItem(QObject* parent,
|
||||
const QString& id,
|
||||
const QObject* receiver,
|
||||
const char* member,
|
||||
const QString& key = QString());
|
||||
|
||||
private:
|
||||
void SetStyling();
|
||||
};
|
||||
|
||||
#endif // WIDGETMENU_H
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "menushared.h"
|
||||
|
||||
MenuShared olive::menu_shared;
|
||||
|
||||
MenuShared::MenuShared()
|
||||
{
|
||||
}
|
||||
|
||||
void MenuShared::Initialize()
|
||||
{
|
||||
new_project_item_ = Menu::CreateItem(this, "newproj", nullptr, nullptr, "Ctrl+N");
|
||||
new_sequence_item_ = Menu::CreateItem(this, "newseq", nullptr, nullptr, "Ctrl+Shift+N");
|
||||
new_folder_item_ = Menu::CreateItem(this, "newfolder", nullptr, nullptr);
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForNewMenu(Menu *m)
|
||||
{
|
||||
m->addAction(new_project_item_);
|
||||
m->addSeparator();
|
||||
m->addAction(new_sequence_item_);
|
||||
m->addAction(new_folder_item_);
|
||||
}
|
||||
|
||||
void MenuShared::Retranslate()
|
||||
{
|
||||
new_project_item_->setText(tr("&Project"));
|
||||
new_sequence_item_->setText(tr("&Sequence"));
|
||||
new_folder_item_->setText(tr("&Folder"));
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef MENU_H
|
||||
#define MENU_H
|
||||
|
||||
#include "widget/menu/menu.h"
|
||||
|
||||
class MenuShared : public QObject {
|
||||
public:
|
||||
MenuShared();
|
||||
|
||||
void Initialize();
|
||||
|
||||
void AddItemsForNewMenu(Menu* m);
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
|
||||
QAction* new_project_item_;
|
||||
QAction* new_sequence_item_;
|
||||
QAction* new_folder_item_;
|
||||
};
|
||||
|
||||
namespace olive {
|
||||
extern MenuShared menu_shared;
|
||||
}
|
||||
|
||||
#endif // MENU_H
|
||||
Reference in New Issue
Block a user