Kaynağa Gözat

fullscreen management

Nicolas Winkler 5 yıl önce
ebeveyn
işleme
114b518915

+ 34 - 5
Almond.cpp

@@ -43,15 +43,15 @@ Almond::Almond(QWidget* parent) :
     auto* p = new QPushButton("About");
     bar->addPermanentWidget(p);
     QObject::connect(p, &QPushButton::clicked, [this]() {
-        ui.centralWidget = this->takeCentralWidget();
-        this->setCentralWidget(mw.get());
-        emit this->showFullScreen();
-        QThread::sleep(2);
+        /*QThread::sleep(2);
         ui.mandel_container->addWidget(this->takeCentralWidget());
-        emit this->showNormal();
+        emit this->showNormal();*/
+        toggleFullscreen();
     });
     ui.mainContainer->addWidget(bar);
 
+    installEventFilter(this);
+
     backgroundTasks.setMaxThreadCount(1);
     QIcon icon{ ":/icons/icon" };
     icon.addFile(":/icons/icon@2x");
@@ -89,6 +89,35 @@ void Almond::submitBackgroundTask(BackgroundTask* task)
     //}
 }
 
+bool Almond::eventFilter(QObject *target, QEvent *event)
+{
+    if (event->type() == QEvent::KeyPress) {
+        QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
+        if (keyEvent->key() == Qt::Key_F11) {
+            emit toggleFullscreen();
+        }
+    }
+    return QObject::eventFilter(target, event);
+}
+
+
+void Almond::toggleFullscreen(void)
+{
+    if (fullscreenMode) {
+        auto* m = this->takeCentralWidget();
+        ui.mandel_container->addWidget(m);
+        this->setCentralWidget(cw);
+        emit this->showNormal();
+        fullscreenMode = false;
+    }
+    else {
+        cw = this->takeCentralWidget();
+        this->setCentralWidget(mw.get());
+        emit this->showFullScreen();
+        fullscreenMode = true;
+    }
+}
+
 
 void Almond::backgroundTaskFinished(bool succ, QString message)
 {

+ 7 - 0
Almond.h

@@ -35,6 +35,10 @@ class Almond : public QMainWindow
 private:
     mnd::MandelContext mandelContext;
     QThreadPool backgroundTasks;
+
+
+    bool fullscreenMode = false;
+    QWidget* cw;
 public:
     std::unique_ptr<MandelWidget> mw;
 private:
@@ -59,6 +63,9 @@ public:
 
     void submitBackgroundTask(BackgroundTask* task);
 
+    bool eventFilter(QObject *target, QEvent *event);
+public slots:
+    void toggleFullscreen(void);
 private slots:
     void on_zoom_out_clicked();
     void on_zoom_in_clicked();

+ 1 - 1
Almond.ui

@@ -29,7 +29,7 @@
   </widget>
   <widget class="QDockWidget" name="dockWidget_2">
    <property name="features">
-    <set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
+    <set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetClosable</set>
    </property>
    <property name="allowedAreas">
     <set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>

+ 7 - 2
CMakeLists.txt

@@ -71,11 +71,16 @@ ELSEIF (UNIX AND NOT APPLE)
     install(TARGETS Almond RUNTIME DESTINATION "bin")
     install(FILES Almond.desktop DESTINATION "share/applications")
     install(FILES Almond.png DESTINATION "share/pixmaps")
+    install(FILES LICENSE DESTINATION "share/doc/almond/" RENAME "copyright")
     set(CPACK_GENERATOR "DEB")
+    set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
+    set(CPACK_STRIP_FILES TRUE)
     set(CPACK_SOURCE_GENERATOR "DEB")
     set(CPACK_COMPONENTS_ALL Almond)
-    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nicolas Winkler")
-    set(CPACK_DEBIAN_PACKAGE_DEPENDS "qt5-default,libavformat58,libavdevice58,libavfilter7,libavutil56,libswscale5,libgl1,ocl-icd-libopencl1,libpng16-16")
+    set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "A fractal viewer")
+    set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
+    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nicolas Winkler <nicolas.winkler@gmx.ch>")
+    set(CPACK_DEBIAN_PACKAGE_DEPENDS "qtbase5-dev,libavformat58,libavdevice58,libavfilter7,libavutil56,libswscale5,libgl1,ocl-icd-libopencl1,libpng16-16,libc6")
     set(CPACK_SET_DESTDIR True)
     set(CPACK_INSTALL_PREFIX "/usr")
     include(CPack)

+ 17 - 0
installer/packages/almond/meta/zlib.txt

@@ -0,0 +1,17 @@
+Copyright (c) 2020 Nicolas Winkler
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+   claim that you wrote the original software. If you use this software
+   in a product, an acknowledgment in the product documentation would be
+   appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+   misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.

+ 1 - 1
libmandel/src/opencl/float.cl

@@ -72,7 +72,7 @@ __kernel void iterate_vec4(__global float* A, const int width, float xl, float y
     }
     for (int i = 0; i < 4 && i + x < width; i++) {
     if (smooth != 0) {
-        if (count[i] != 0)
+        if (count[i] >= 0)
             A[index + i] = ((float) count[i]) + 1 - log(log(fma(resa[i], resa[i], resb[i] * resb[i])) / 2) / log(2.0f);
     }
     else

+ 1 - 1
libmandel/src/opencl/float.h

@@ -209,7 +209,7 @@ unsigned char float_cl[] = {
   0x20, 0x69, 0x66, 0x20, 0x28, 0x73, 0x6d, 0x6f, 0x6f, 0x74, 0x68, 0x20,
   0x21, 0x3d, 0x20, 0x30, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
   0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x63, 0x6f, 0x75, 0x6e,
-  0x74, 0x5b, 0x69, 0x5d, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x29, 0x0a, 0x20,
+  0x74, 0x5b, 0x69, 0x5d, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x29, 0x0a, 0x20,
   0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41,
   0x5b, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x2b, 0x20, 0x69, 0x5d, 0x20,
   0x3d, 0x20, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x29, 0x20, 0x63,