Added CMake magic for plugin infrastructure.

Added ViewManager.
Added dummy Settings class.
Added dummy plugin interface (UI plugins only).
Added dummy greeting plugin.
Added DLLEXPORT macros for UI plugin interface and plugins.
This commit is contained in:
Teo Mrnjavac 2014-06-11 13:37:10 +02:00
parent bfc5316c56
commit 6899b1f0fa
26 changed files with 777 additions and 131 deletions

View file

@ -1,3 +1,5 @@
include( ${PROJECT_BINARY_DIR}/CalamaresUse.cmake )
include_directories( ${CMAKE_CURRENT_BINARY_DIR}/libcalamares )
include_directories( ${CMAKE_CURRENT_LIST_DIR}/libcalamares )
@ -9,3 +11,9 @@ add_subdirectory( libcalamares )
# application
add_subdirectory( calamares )
include_directories( ${CMAKE_CURRENT_BINARY_DIR}/calamares )
include_directories( ${CMAKE_CURRENT_LIST_DIR}/calamares )
# plugins
add_subdirectory( modules )

View file

@ -8,6 +8,11 @@ set( calamaresSources
main.cpp
CalamaresApplication.cpp
CalamaresWindow.cpp
ViewManager.cpp
Settings.cpp
viewpages/PagePlugin.cpp
viewpages/AbstractPage.cpp
)
set( calamaresUi

View file

@ -18,8 +18,18 @@
#include "CalamaresWindow.h"
#include "ViewManager.h"
#include "QBoxLayout"
CalamaresWindow::CalamaresWindow( QWidget* parent )
: QWidget( parent )
{
setupUi( this );
//This should create a PageManager or ViewManager or whatever, which
//should control the sidebar, next/back buttons and QSW.
Calamares::ViewManager* vm = new Calamares::ViewManager( this );
layout()->addWidget( vm->widget() );
}

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>500</height>
<height>592</height>
</rect>
</property>
<property name="maximumSize">
@ -22,8 +22,8 @@
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="leftSidebar">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
@ -98,7 +98,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../github/installer/ui/installer.qrc">:/Images/images/install.png</pixmap>
<pixmap>:/Images/images/install.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
@ -540,133 +540,8 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>578</width>
<height>420</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<widget class="QPushButton" name="abortButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>48</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Abort installation</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="previousButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>48</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string comment="Previous Page">Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="nextButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>48</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string comment="Next Page">Next</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../github/installer/ui/installer.qrc"/>
<include location="../github/installer/ui/installer.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

32
src/calamares/DllMacro.h Normal file
View file

@ -0,0 +1,32 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UIDLLMACRO_H
#define UIDLLMACRO_H
#include <QtCore/qglobal.h>
#ifndef UIDLLEXPORT
# if defined (UIDLLEXPORT_PRO)
# define UIDLLEXPORT Q_DECL_EXPORT
# else
# define UIDLLEXPORT Q_DECL_IMPORT
# endif
#endif
#endif

View file

@ -0,0 +1,24 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Settings.h"
Settings::Settings( QObject* parent )
: QObject( parent )
{
}

39
src/calamares/Settings.h Normal file
View file

@ -0,0 +1,39 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SETTINGS_H
#define SETTINGS_H
#include <QObject>
// Settings::instance() ?
class Settings : public QObject
{
Q_OBJECT
public:
explicit Settings( QObject *parent = 0 );
//TODO: load from JSON then emit ready
signals:
public slots:
};
#endif // SETTINGS_H

View file

@ -0,0 +1,82 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ViewManager.h"
#include <QBoxLayout>
namespace Calamares
{
ViewManager* ViewManager::s_instance = 0;
ViewManager*
ViewManager::instance()
{
return s_instance;
}
ViewManager::ViewManager( QObject* parent )
: QObject( parent )
, m_widget( new QWidget() )
{
s_instance = this;
QBoxLayout* mainLayout = new QVBoxLayout;
m_widget->setLayout( mainLayout );
m_stack = new QStackedWidget( m_widget );
mainLayout->addWidget( m_stack );
m_back = new QPushButton( tr( "&Back" ), m_widget );
m_next = new QPushButton( tr( "&Next" ), m_widget );
QBoxLayout* bottomLayout = new QHBoxLayout;
mainLayout->addLayout( bottomLayout );
bottomLayout->addStretch();
bottomLayout->addWidget( m_back );
bottomLayout->addWidget( m_next );
}
ViewManager::~ViewManager()
{
m_widget->deleteLater();
}
QWidget*
ViewManager::widget()
{
return m_widget;
}
void
ViewManager::next()
{
Q_ASSERT( 0 );
}
void
ViewManager::back()
{
Q_ASSERT( 0 );
}
}

View file

@ -0,0 +1,63 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VIEWMANAGER_H
#define VIEWMANAGER_H
#include "DllMacro.h"
#include "viewpages/PagePlugin.h"
#include <QPushButton>
#include <QStackedWidget>
namespace Calamares
{
class UIDLLEXPORT ViewManager : public QObject
{
Q_OBJECT
public:
static ViewManager* instance();
explicit ViewManager( QObject* parent = 0 );
virtual ~ViewManager();
QWidget* widget();
void addPagePlugin( PagePlugin* plugin );
void insertPage( AbstractPage* page );
void setNext( AbstractPage* page );
void removePage( AbstractPage* page );
public slots:
void next();
void back();
private:
static ViewManager* s_instance;
QWidget* m_widget;
QStackedWidget* m_stack;
QPushButton* m_back;
QPushButton* m_next;
};
}
#endif // VIEWMANAGER_H

View file

@ -0,0 +1,29 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AbstractPage.h"
namespace Calamares
{
AbstractPage::AbstractPage( QWidget* parent )
: QWidget( parent )
{
}
}

View file

@ -0,0 +1,43 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ABSTRACTPAGE_H
#define ABSTRACTPAGE_H
#include <QWidget>
#include "../DllMacro.h"
namespace Calamares
{
class UIDLLEXPORT AbstractPage : public QWidget
{
Q_OBJECT
public:
explicit AbstractPage(QWidget *parent = 0);
signals:
public slots:
};
}
#endif // ABSTRACTPAGE_H

View file

@ -0,0 +1,29 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PagePlugin.h"
namespace Calamares
{
PagePlugin::PagePlugin( QObject* parent )
: QObject( parent )
{
}
}

View file

@ -0,0 +1,46 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PAGEPLUGIN_H
#define PAGEPLUGIN_H
#include <QObject>
#include "../DllMacro.h"
namespace Calamares
{
class AbstractPage;
class UIDLLEXPORT PagePlugin : public QObject
{
Q_OBJECT
public:
explicit PagePlugin( QObject *parent = 0 );
signals:
void done();
};
}
Q_DECLARE_INTERFACE( Calamares::PagePlugin, "calamares.PagePlugin/1.0" )
#endif // PAGEPLUGIN_H

View file

@ -0,0 +1,32 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLUGINDLLMACRO_H
#define PLUGINDLLMACRO_H
#include <QtCore/qglobal.h>
#ifndef PLUGINDLLEXPORT
# if defined (PLUGINDLLEXPORT_PRO)
# define PLUGINDLLEXPORT Q_DECL_EXPORT
# else
# define PLUGINDLLEXPORT Q_DECL_IMPORT
# endif
#endif
#endif

View file

@ -0,0 +1,6 @@
file(GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*")
foreach(SUBDIRECTORY ${SUBDIRECTORIES})
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt")
add_subdirectory(${SUBDIRECTORY})
endif()
endforeach()

5
src/modules/README.md Normal file
View file

@ -0,0 +1,5 @@
Calamares modules directory
===
Calamares modules are plugins that implement the Calamares module API and can provide features like installer pages, batch jobs, etc.
To add a module, put it in a subdirectory and make sure it has a CMakeLists.txt, it should be picked up automatically by our CMake magic.

View file

@ -0,0 +1,12 @@
include_directories( ${PROJECT_BINARY_DIR}/src/calamares )
calamares_add_plugin( greeting
TYPE pageplugin
EXPORT_MACRO PLUGINDLLEXPORT_PRO
SOURCES
GreetingPagePlugin.cpp
GreetingPage.cpp
UI
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
SHARED_LIB
)

View file

@ -0,0 +1,25 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GreetingPage.h"
GreetingPage::GreetingPage( QWidget* parent )
: AbstractPage( parent )
{
}

View file

@ -0,0 +1,36 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GREETINGPAGE_H
#define GREETINGPAGE_H
#include "viewpages/AbstractPage.h"
class GreetingPage : public Calamares::AbstractPage
{
Q_OBJECT
public:
explicit GreetingPage( QWidget* parent = 0 );
signals:
public slots:
};
#endif // GREETINGPAGE_H

View file

@ -0,0 +1,24 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GreetingPagePlugin.h"
GreetingPagePlugin::GreetingPagePlugin( QObject *parent )
: PagePlugin( parent )
{
}

View file

@ -0,0 +1,39 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GREETINGPAGEPLUGIN_H
#define GREETINGPAGEPLUGIN_H
#include <QObject>
#include "viewpages/PagePlugin.h"
#include "PluginDllMacro.h"
class PLUGINDLLEXPORT GreetingPagePlugin : public Calamares::PagePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA( IID "calamares.PagePlugin/1.0" )
//FILE "module.json" )
Q_INTERFACES( Calamares::PagePlugin )
public:
explicit GreetingPagePlugin(QObject *parent = 0);
};
#endif // GREETINGPAGEPLUGIN_H