forked from go-qamel/qamel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c003b4b
commit 35f761c
Showing
4 changed files
with
57 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
# Exclude generated file | ||
cgo.go | ||
moc*.h | ||
|
||
# Exclude sample dir | ||
sample/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,140 @@ | ||
#include "viewer.h" | ||
#include <QQuickView> | ||
#include <QString> | ||
#include <QUrl> | ||
#include <QWindow> | ||
#include <QIcon> | ||
#include <QQmlEngine> | ||
#include "viewer.h" | ||
|
||
class QamelView : public QQuickView { | ||
Q_OBJECT | ||
|
||
public: | ||
QamelView(QWindow *parent = 0) : QQuickView(parent) {} | ||
QamelView(const QUrl &source, QWindow *parent = nullptr) : QQuickView(source, parent) {} | ||
|
||
public slots: | ||
void reload() { | ||
engine()->clearComponentCache(); | ||
setSource(source()); | ||
} | ||
}; | ||
|
||
void* Viewer_NewViewer() { | ||
return new QQuickView(); | ||
return new QamelView(); | ||
} | ||
|
||
void* Viewer_NewViewerWithSource(char* source) { | ||
QUrl url = QUrl(QString(source)); | ||
return new QQuickView(url); | ||
return new QamelView(url); | ||
} | ||
|
||
void Viewer_SetSource(void* ptr, char* url) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setSource(QUrl(QString(url))); | ||
} | ||
|
||
void Viewer_SetResizeMode(void* ptr, int resizeMode) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setResizeMode(QQuickView::ResizeMode(resizeMode)); | ||
} | ||
|
||
void Viewer_SetFlags(void* ptr, int flags) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setFlags(Qt::WindowFlags(flags)); | ||
} | ||
|
||
void Viewer_SetHeight(void* ptr, int height) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setHeight(height); | ||
} | ||
|
||
void Viewer_SetWidth(void* ptr, int width) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setWidth(width); | ||
} | ||
|
||
void Viewer_SetMaximumHeight(void* ptr, int height) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setMaximumHeight(height); | ||
} | ||
|
||
void Viewer_SetMaximumWidth(void* ptr, int width) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setMaximumWidth(width); | ||
} | ||
|
||
void Viewer_SetMinimumHeight(void* ptr, int height) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setMinimumHeight(height); | ||
} | ||
|
||
void Viewer_SetMinimumWidth(void* ptr, int width) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setMinimumWidth(width); | ||
} | ||
|
||
void Viewer_SetOpacity(void* ptr, double opacity) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setOpacity(opacity); | ||
} | ||
|
||
void Viewer_SetTitle(void* ptr, char* title) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setTitle(QString(title)); | ||
} | ||
|
||
void Viewer_SetVisible(void* ptr, bool visible) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setVisible(visible); | ||
} | ||
|
||
void Viewer_SetPosition(void* ptr, int x, int y) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setPosition(x, y); | ||
} | ||
|
||
void Viewer_SetIcon(void* ptr, char* fileName) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
QIcon icon = QIcon(QString(fileName)); | ||
view->setIcon(icon); | ||
} | ||
|
||
void Viewer_Show(void* ptr) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->show(); | ||
} | ||
|
||
void Viewer_ShowMaximized(void* ptr) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->showMaximized(); | ||
} | ||
|
||
void Viewer_ShowMinimized(void* ptr) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->showMinimized(); | ||
} | ||
|
||
void Viewer_ShowFullScreen(void* ptr) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->showFullScreen(); | ||
} | ||
|
||
void Viewer_ShowNormal(void* ptr) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->showNormal(); | ||
} | ||
|
||
void Viewer_SetWindowStates(void* ptr, int state) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->setWindowStates(Qt::WindowStates(state)); | ||
} | ||
|
||
void Viewer_ClearComponentCache(void* ptr) { | ||
QQuickView *view = static_cast<QQuickView*>(ptr); | ||
QamelView *view = static_cast<QamelView*>(ptr); | ||
view->engine()->clearComponentCache(); | ||
} | ||
|
||
void Viewer_Reload(void* ptr) { | ||
QMetaObject::invokeMethod(static_cast<QamelView*>(ptr), "reload"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters