Skip to content

Commit

Permalink
Start moving from gdocgallery
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Dec 26, 2024
1 parent a919ddc commit 9616be2
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 176 deletions.
5 changes: 1 addition & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(SRC
qt_add_resources(RESOURCES qml/glacier-gallery.qrc)

add_subdirectory(editorplugin)
add_subdirectory(plugin)

add_executable(glacier-gallery ${SRC} ${RESOURCES})

Expand All @@ -34,7 +35,3 @@ install(TARGETS glacier-gallery RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR})

FindQtInstallQml()

install(DIRECTORY qml/api/
DESTINATION
${QT_INSTALL_QML}/org/nemomobile/gallery)
4 changes: 2 additions & 2 deletions src/editorplugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

#include "editableimage.h"

class Q_DECL_EXPORT GlacierPackageManagerPlugin : public QQmlExtensionPlugin {
class Q_DECL_EXPORT GlacierImageEditorPlugin : public QQmlExtensionPlugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.glacier.imageeditor")
public:
virtual ~GlacierPackageManagerPlugin() { }
virtual ~GlacierImageEditorPlugin() { }

void initializeEngine(QQmlEngine*, const char* uri)
{
Expand Down
60 changes: 60 additions & 0 deletions src/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
### Sets QT_INSTALL_QML to the directory where QML Plugins should be installed
function(FindQtInstallQml)
find_program(QMAKE NAMES qmake6 qmake)
if(NOT QMAKE)
message(FATAL_ERROR "qmake not found")
endif()
execute_process(
COMMAND ${QMAKE} -query QT_INSTALL_QML
OUTPUT_VARIABLE PROC_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(QT_INSTALL_QML ${PROC_RESULT} PARENT_SCOPE)
endfunction()

set(SRC
plugin.cpp
gallerymodel.cpp)

set(HEADERS
plugin.h
gallerymodel.h)

set(QML
qml/GalleryDelegate.qml
qml/GalleryView.qml)

add_library(glaciergalleryplugin SHARED ${SRC})

qt6_add_qml_module(glaciergalleryplugin
URI Glacier.Gallery
VERSION 1.0
PLUGIN_TARGET glaciergalleryplugin
NO_GENERATE_PLUGIN_SOURCE
SOURCES
${SOURCES}
${HEADERS}
QML_FILES
${QML}
OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/Glacier/Gallery
RESOURCES qml/qmldir
SOURCES gallerymodel.h gallerymodel.cpp
)

target_link_libraries(glaciergalleryplugin PUBLIC
Qt6::Core
Qt6::Gui
Qt6::Qml
Qt6::Quick)

FindQtInstallQml()

install(TARGETS glaciergalleryplugin
RUNTIME DESTINATION "${QT_INSTALL_QML}/Glacier/Gallery"
BUNDLE DESTINATION "${QT_INSTALL_QML}/Glacier/Gallery"
LIBRARY DESTINATION "${QT_INSTALL_QML}/Glacier/Gallery"
)

install(DIRECTORY qml/
DESTINATION ${QT_INSTALL_QML}/Glacier/Gallery)
41 changes: 41 additions & 0 deletions src/plugin/gallerymodel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "gallerymodel.h"

GalleryModel::GalleryModel(QObject *parent)
: QAbstractListModel{parent}
, m_loading(false)
, m_error(true)
{
}

int GalleryModel::rowCount(const QModelIndex &parent) const
{
return -1;
}

QVariant GalleryModel::data(const QModelIndex &index, int role) const
{
return QVariant();
}

QStringList GalleryModel::sortProperties() const
{
return m_sortProperties;
}

void GalleryModel::setSortProperties(const QStringList &newSortProperties)
{
if (m_sortProperties == newSortProperties)
return;
m_sortProperties = newSortProperties;
emit sortPropertiesChanged();
}

bool GalleryModel::loading() const
{
return m_loading;
}

bool GalleryModel::error() const
{
return m_error;
}
40 changes: 40 additions & 0 deletions src/plugin/gallerymodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef GALLERYMODEL_H
#define GALLERYMODEL_H

#include <QAbstractListModel>

class GalleryModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QStringList sortProperties READ sortProperties WRITE setSortProperties NOTIFY sortPropertiesChanged FINAL)
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged FINAL)
Q_PROPERTY(bool error READ error NOTIFY errorChanged FINAL)

public:
explicit GalleryModel(QObject *parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role) const;
QHash<int, QByteArray> roleNames() const { return m_hash; }

QStringList sortProperties() const;
void setSortProperties(const QStringList &newSortProperties);

bool loading() const;

bool error() const;

signals:
void sortPropertiesChanged();

void loadingChanged();

void errorChanged();

private:
QHash<int, QByteArray> m_hash;
QStringList m_sortProperties;
bool m_loading;
bool m_error;
};

#endif // GALLERYMODEL_H
Empty file added src/plugin/glacier.gallery.json
Empty file.
30 changes: 30 additions & 0 deletions src/plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2024 Chupligin Sergey <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/

#include "plugin.h"
#include "gallerymodel.h"
#include <QtQml>

void QQuickNemoControlsExtensionPlugin::registerTypes(const char* uri)
{
Q_ASSERT(uri == QLatin1String("Glacier.Gallery"));
qmlRegisterModule(uri, 1, 0);
//@uri Glacier.Gallery
qmlRegisterType<GalleryModel>(uri, 1, 0, "GalleryModel");
}
34 changes: 34 additions & 0 deletions src/plugin/plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2024 Chupligin Sergey <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/


#ifndef PLUGIN_H
#define PLUGIN_H

#include <QQmlExtensionPlugin>

class QQuickNemoControlsExtensionPlugin : public QQmlExtensionPlugin {
public:
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid FILE "glacier.gallery.json")
public:
void registerTypes(const char* uri);
};

#endif // PLUGIN_H
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion src/qml/api/qmldir → src/plugin/qml/qmldir
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module Glacier.Gallery
plugin glaciergalleryplugin

GalleryDelegate 1.0 GalleryDelegate.qml
GalleryModel 1.0 GalleryModel.qml
GalleryView 1.0 GalleryView.qml
Loading

0 comments on commit 9616be2

Please sign in to comment.