recreating menu structure
This commit is contained in:
+5
-1
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "ui/icons/icons.h"
|
||||
#include "ui/style/style.h"
|
||||
#include "widget/menu/menushared.h"
|
||||
|
||||
Core olive::core;
|
||||
|
||||
@@ -52,7 +53,10 @@ void Core::Start()
|
||||
olive::icon::LoadAll();
|
||||
|
||||
// Set UI style
|
||||
olive::style::SetDefault();
|
||||
olive::style::AppSetDefault();
|
||||
|
||||
// Set up shared menus
|
||||
olive::menu_shared.Initialize();
|
||||
|
||||
// Create main window and open it
|
||||
main_window_ = new olive::MainWindow();
|
||||
|
||||
+14
-2
@@ -4,7 +4,7 @@
|
||||
#include <QPalette>
|
||||
#include <QStyleFactory>
|
||||
|
||||
void olive::style::SetDefault()
|
||||
void olive::style::AppSetDefault()
|
||||
{
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
|
||||
@@ -35,10 +35,22 @@ void olive::style::SetDefault()
|
||||
bool set_separator_color = false;
|
||||
#ifndef Q_OS_WIN
|
||||
//set_separator_color = !olive::config.use_native_menu_styling;
|
||||
set_separator_color = true;
|
||||
#endif
|
||||
if (set_separator_color) {
|
||||
stylesheet.append("QMenu::separator { background: #404040; }");
|
||||
stylesheet.append("QMenu::separator { background: #303030; }");
|
||||
}
|
||||
|
||||
qApp->setStyleSheet(stylesheet);
|
||||
}
|
||||
|
||||
void olive::style::WidgetSetNative(QWidget *w)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
w->setStyleSheet("");
|
||||
w->setPalette(w->style()->standardPalette());
|
||||
w->setStyle(QStyleFactory::create("windowsvista"));
|
||||
#else
|
||||
Q_UNUSED(w)
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#ifndef STYLEMANAGER_H
|
||||
#define STYLEMANAGER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace olive {
|
||||
namespace style {
|
||||
|
||||
void SetDefault();
|
||||
void AppSetDefault();
|
||||
|
||||
void WidgetSetNative(QWidget *w);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
window/mainwindow/mainmenu.h
|
||||
window/mainwindow/mainmenu.cpp
|
||||
window/mainwindow/mainwindow.h
|
||||
window/mainwindow/mainwindow.cpp
|
||||
PARENT_SCOPE
|
||||
|
||||
@@ -1,6 +1,94 @@
|
||||
#include "mainmenu.h"
|
||||
|
||||
MainMenu::MainMenu()
|
||||
{
|
||||
#include <QEvent>
|
||||
|
||||
#include "widget/menu/menushared.h"
|
||||
|
||||
MainMenu::MainMenu(QWidget *parent) :
|
||||
QMenuBar(parent)
|
||||
{
|
||||
//
|
||||
// FILE MENU
|
||||
//
|
||||
file_menu_ = new Menu(this);
|
||||
file_new_menu_ = new Menu(file_menu_);
|
||||
olive::menu_shared.AddItemsForNewMenu(file_new_menu_);
|
||||
file_open_item_ = file_menu_->AddItem("openproj", nullptr, nullptr, "Ctrl+O");
|
||||
file_open_recent_menu_ = new Menu(file_menu_);
|
||||
file_open_recent_clear_item_ = file_open_recent_menu_->AddItem("clearopenrecent", nullptr, nullptr);
|
||||
file_save_item_ = file_menu_->AddItem("saveproj", nullptr, nullptr, "Ctrl+S");
|
||||
file_save_as_item_ = file_menu_->AddItem("saveprojas", nullptr, nullptr, "Ctrl+Shift+S");
|
||||
file_menu_->addSeparator();
|
||||
file_import_item_ = file_menu_->AddItem("import", nullptr, nullptr, "Ctrl+I");
|
||||
file_menu_->addSeparator();
|
||||
file_export_item_ = file_menu_->AddItem("export", nullptr, nullptr, "Ctrl+M");
|
||||
file_menu_->addSeparator();
|
||||
file_exit_item_ = file_menu_->AddItem("exit", nullptr, nullptr);
|
||||
|
||||
//
|
||||
// EDIT MENU
|
||||
//
|
||||
edit_menu_ = new Menu(this);
|
||||
edit_undo_item_ = edit_menu_->AddItem("undo", nullptr, nullptr, "Ctrl+Z");
|
||||
edit_redo_item_ = edit_menu_->AddItem("redo", nullptr, nullptr, "Ctrl+Shift+Z");
|
||||
|
||||
//
|
||||
// VIEW MENU
|
||||
//
|
||||
view_menu_ = new Menu(this);
|
||||
|
||||
//
|
||||
// PLAYBACK MENU
|
||||
//
|
||||
playback_menu_ = new Menu(this);
|
||||
|
||||
//
|
||||
// WINDOW MENU
|
||||
//
|
||||
window_menu_ = new Menu(this);
|
||||
|
||||
//
|
||||
// HELP MENU
|
||||
//
|
||||
tools_menu_ = new Menu(this);
|
||||
|
||||
//
|
||||
// FILE MENU
|
||||
//
|
||||
help_menu_ = new Menu(this);
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
void MainMenu::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
}
|
||||
QMenuBar::changeEvent(e);
|
||||
}
|
||||
|
||||
void MainMenu::Retranslate()
|
||||
{
|
||||
file_menu_->setTitle(tr("&File"));
|
||||
file_new_menu_->setTitle(tr("&New"));
|
||||
file_open_item_->setText(tr("&Open Project"));
|
||||
file_open_recent_menu_->setTitle(tr("Open Recent"));
|
||||
file_open_recent_clear_item_->setText(tr("Clear Recent List"));
|
||||
file_save_item_->setText(tr("&Save Project"));
|
||||
file_save_as_item_->setText(tr("Save Project &As"));
|
||||
file_import_item_->setText(tr("&Import..."));
|
||||
file_export_item_->setText(tr("&Export..."));
|
||||
file_exit_item_->setText(tr("E&xit"));
|
||||
|
||||
edit_menu_->setTitle(tr("&Edit"));
|
||||
edit_undo_item_->setText(tr("&Undo"));
|
||||
edit_redo_item_->setText(tr("Redo"));
|
||||
edit_menu_->addSeparator();
|
||||
|
||||
view_menu_->setTitle(tr("&View"));
|
||||
playback_menu_->setTitle(tr("&Playback"));
|
||||
window_menu_->setTitle("&Window");
|
||||
tools_menu_->setTitle(tr("&Tools"));
|
||||
help_menu_->setTitle(tr("&Help"));
|
||||
}
|
||||
|
||||
@@ -1,11 +1,41 @@
|
||||
#ifndef MAINMENU_H
|
||||
#define MAINMENU_H
|
||||
|
||||
#include <QMenuBar>
|
||||
|
||||
class MainMenu
|
||||
#include "widget/menu/menu.h"
|
||||
|
||||
class MainMenu : public QMenuBar
|
||||
{
|
||||
public:
|
||||
MainMenu();
|
||||
MainMenu(QWidget* parent);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* e);
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
|
||||
Menu* file_menu_;
|
||||
Menu* file_new_menu_;
|
||||
QAction* file_open_item_;
|
||||
Menu* file_open_recent_menu_;
|
||||
QAction* file_open_recent_clear_item_;
|
||||
QAction* file_save_item_;
|
||||
QAction* file_save_as_item_;
|
||||
QAction* file_import_item_;
|
||||
QAction* file_export_item_;
|
||||
QAction* file_exit_item_;
|
||||
|
||||
Menu* edit_menu_;
|
||||
QAction* edit_undo_item_;
|
||||
QAction* edit_redo_item_;
|
||||
|
||||
Menu* view_menu_;
|
||||
Menu* playback_menu_;
|
||||
Menu* window_menu_;
|
||||
Menu* tools_menu_;
|
||||
Menu* help_menu_;
|
||||
};
|
||||
|
||||
#endif // MAINMENU_H
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include "panel/viewer/viewer.h"
|
||||
#include "panel/timeline/timeline.h"
|
||||
|
||||
// Main menu bar
|
||||
#include "mainmenu.h"
|
||||
|
||||
olive::MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent)
|
||||
{
|
||||
@@ -29,4 +32,7 @@ olive::MainWindow::MainWindow(QWidget *parent) :
|
||||
addDockWidget(Qt::TopDockWidgetArea, viewer_panel4);
|
||||
TimelinePanel* viewer_panel3 = new TimelinePanel(this);
|
||||
addDockWidget(Qt::BottomDockWidgetArea, viewer_panel3);
|
||||
|
||||
MainMenu* main_menu = new MainMenu(this);
|
||||
setMenuBar(main_menu);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user