recreating menu structure

This commit is contained in:
itsmattkc
2019-06-18 00:24:08 -07:00
parent a468b3727d
commit 25564fdb6b
13 changed files with 330 additions and 9 deletions
+2 -1
View File
@@ -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}
+24
View File
@@ -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
)
+65
View File
@@ -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);
//}
}
+28
View File
@@ -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
+31
View File
@@ -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"));
}
+26
View File
@@ -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