Commit 3ce47717 authored by WINTZ Julien's avatar WINTZ Julien

Merging request #8.

parent d0be2e1d
......@@ -18,7 +18,7 @@ project(dtkWidgetsWorkspace)
## Sources
## #################################################################
set(${PROJECT_NAME}_SOURCES main.cpp)
set(${PROJECT_NAME}_SOURCES main.cpp)
set(${PROJECT_NAME}_SOURCES_QRC main.qrc)
## #################################################################
......@@ -37,5 +37,21 @@ target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} dtkWidgets)
target_link_libraries(${PROJECT_NAME} dtkCore)
## ###################################################################
## Bundle setup
## ###################################################################
if(APPLE)
set(${PROJECT_NAME}_RESOURCE_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/Resources)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${${PROJECT_NAME}_RESOURCE_DIR})
endif(APPLE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.plist.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.plist)
if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.plist)
endif(APPLE)
######################################################################
### CMakeLists.txt ends here
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>@PROJECT_NAME@</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string>@PROJECT_NAME@</string>
<key>CFBundleIdentifier</key>
<string>fr.inria.@PROJECT_NAME@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>@dtkWidgets_VERSION@</string>
<key>CFBundleName</key>
<string>@PROJECT_NAME@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@dtkWidgets_VERSION@</string>
<key>CFBundleVersion</key>
<string>@dtkWidgets_VERSION@</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Inria</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
......@@ -208,13 +208,10 @@ static const QString m_style = QString(""
"}"
"").arg(bg_color).arg(fg_color).arg(bd_color).arg(hl_color).arg(bl_color).arg(altbg_color);
// ///////////////////////////////////////////////////////////////////
// dummy workspace
// ///////////////////////////////////////////////////////////////////
class dummyWorkspaceA: public dtkWidgetsWorkspace
{
Q_OBJECT
......@@ -222,27 +219,33 @@ class dummyWorkspaceA: public dtkWidgetsWorkspace
public:
dummyWorkspaceA(QWidget *parent = nullptr) {
this->menubar = new dtkWidgetsMenuBar(this);
dtkWidgetsMenu *menu_1 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 1");
dtkWidgetsMenu *menu_2 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 2");
dtkWidgetsMenu *menu_3 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 3");
menubar->addMenu(menu_1);
menubar->addMenu(menu_2);
menubar->addMenu(menu_3);
menubar->build();
QLabel *label = new QLabel("my dummy workspace with menu", this);
label->setAlignment(Qt::AlignCenter);
QLabel *label = new QLabel("my dummy workspace with menu");
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(30, 30, 30, 30);
layout->setSpacing(0);
layout->addWidget(label);
// /////////////////////////////////////////////////////////////////////////////
// As an overlay: has to be declared last
// /////////////////////////////////////////////////////////////////////////////
dtkWidgetsMenu *menu_1 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 1");
dtkWidgetsMenu *menu_2 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 2");
dtkWidgetsMenu *menu_3 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 3");
this->menubar = new dtkWidgetsMenuBar(this);
this->menubar->addMenu(menu_1);
this->menubar->addMenu(menu_2);
this->menubar->addMenu(menu_3);
this->menubar->build();
};
~dummyWorkspaceA(void) {};
public:
void resizeEvent(QResizeEvent *event);
void resizeEvent(QResizeEvent *event) override;
public:
void enter(void) override {}
......@@ -272,15 +275,19 @@ class dummyWorkspaceB: public dtkWidgetsWorkspace
public:
dummyWorkspaceB(QWidget *parent = nullptr) {
QLabel *label = new QLabel("dummy workspace B");
QLabel *label = new QLabel("dummy workspace B", this);
label->setAlignment(Qt::AlignCenter);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(label);
this->setStyleSheet(m_style);
this->setObjectName("dummy workspace B");
};
~dummyWorkspaceB(void) {};
public:
......@@ -289,7 +296,6 @@ public:
public slots:
void apply(void) override {};
};
static dtkWidgetsWorkspace *dummyWorkspaceCreatorB(void) {
......@@ -302,15 +308,21 @@ class dummyWorkspaceC: public dtkWidgetsWorkspace
public:
dummyWorkspaceC(QWidget *parent = nullptr) {
QLabel *label = new QLabel;
QLabel *label = new QLabel(this);
label->setPixmap(QPixmap(":/logo.jpg"));
QScrollArea *scroll = new QScrollArea(this);
scroll->setWidget(label);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(label);
this->setObjectName("dummy workspace C");
layout->addWidget(scroll);
this->setObjectName("dummy workspace C");
};
~dummyWorkspaceC(void) {};
public:
......@@ -319,7 +331,6 @@ public:
public slots:
void apply(void) override {};
};
static dtkWidgetsWorkspace *dummyWorkspaceCreatorC(void) {
......@@ -342,7 +353,6 @@ public:
private:
dtkWidgetsMenuBar *menubar;
dtkWidgetsMenu *menu_1;
dtkWidgetsMenu *menu_2;
dtkWidgetsMenu *menu_3;
......@@ -357,7 +367,6 @@ public:
dummyWindow::dummyWindow(QWidget *parent) : QFrame(parent)
{
this->stack = new QStackedWidget(this);
this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceC"));
this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceB"));
......@@ -368,16 +377,13 @@ dummyWindow::dummyWindow(QWidget *parent) : QFrame(parent)
this->menu_1 = new dtkWidgetsMenu(fa::globe, "Workspaces");
this->menu_2 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 2");
this->menu_3 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 3");
dtkWidgetsMenuItemWorkspace *item = new dtkWidgetsMenuItemWorkspace("Workspaces", stack_bar);
this->menu_1->addItem(new dtkWidgetsMenuItemWorkspace("Workspaces", stack_bar));
this->menubar->addMenu(this->menu_1);
this->menubar->addMenu(this->menu_2);
this->menubar->addMenu(this->menu_3);
this->menu_1->addItem(item);
this->menubar->build();
QHBoxLayout *l = new QHBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
......@@ -394,7 +400,6 @@ void dummyWindow::resizeEvent(QResizeEvent *event)
this->menubar->setFixedHeight(event->size().height());
}
class dummyWindowBar : public QFrame
{
Q_OBJECT
......@@ -411,7 +416,6 @@ public:
dummyWindowBar::dummyWindowBar(QWidget *parent) : QFrame(parent)
{
this->stack = new QStackedWidget(this);
dtkWidgetsWorkspaceBar *bar = new dtkWidgetsWorkspaceBar;
......@@ -419,16 +423,15 @@ dummyWindowBar::dummyWindowBar(QWidget *parent) : QFrame(parent)
// For a dynamic bar with a botton that pops a menu to create new workspace:
//
// bar->addWorkspaceInMenu("dummyWorkspaceA", "My Dummy Workspace A");
// bar->addWorkspaceInMenu("dummyWorkspaceB", "My Dummy Workspace B", fa::image, "category1");
// bar->addWorkspaceInMenu("dummyWorkspaceC", "dtk", fa::image, "category1");
// bar->addWorkspaceInMenu("dummyWorkspaceA", "My Dummy Workspace A");
// bar->addWorkspaceInMenu("dummyWorkspaceB", "My Dummy Workspace B", fa::image, "category1");
// bar->addWorkspaceInMenu("dummyWorkspaceC", "dtk", fa::image, "category1");
// Another option is to build automatically the bar from the factory keys
// bar->buildFromFactory();
// here we use a static workspace bar
//
bar->setDynamic(false);
bar->createWorkspace("My Dummy Workspace A", "dummyWorkspaceA", false );
bar->createWorkspace("My Dummy Workspace B", "dummyWorkspaceB", false );
......@@ -442,7 +445,6 @@ dummyWindowBar::dummyWindowBar(QWidget *parent) : QFrame(parent)
this->setStyleSheet(m_style);
}
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
......@@ -458,12 +460,15 @@ int main(int argc, char **argv)
dtk::widgets::workspace::pluginFactory().record("dummyWorkspaceC", dummyWorkspaceCreatorC);
dummyWindow *window = new dummyWindow;
window->setWindowTitle("One menu, multiple workspaces");
window->show();
window->raise();
dummyWindowBar *windowBar = new dummyWindowBar;
windowBar->setWindowTitle("Multiple menus, multiple workspaces: one menu per workspace");
windowBar->show();
windowBar->raise();
windowBar->move(windowBar->pos() + QPoint(50, 50));
return application.exec();
}
......
......@@ -204,8 +204,6 @@ dtkWidgetsMenuItemParameterFacade::dtkWidgetsMenuItemParameterFacade(dtkWidgetsM
dtkWidgetsMenuItemWorkspaceFacade::dtkWidgetsMenuItemWorkspaceFacade(dtkWidgetsMenuItemWorkspace *source, QWidget *parent) : dtkWidgetsMenuItemFacade(source, parent)
{
QVBoxLayout *layout = new QVBoxLayout(this);
qDebug() << "add workspace widget in layout" << source;
layout->addWidget(source->widget());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment