feat: msvc build compat

pull/2/head
PikachuHy 5 years ago
parent 44c845f05a
commit 525ade39fa

@ -22,7 +22,10 @@ option(COMPONENT_SYNCING "Build syncing component" ON)
find_package(ECM 5.45.0 NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
set(QT Core Widgets Quick QuickControls2 X11Extras DBus)
set(QT Core Widgets Quick QuickControls2 DBus)
if (UNIX)
set(QT ${QT} X11Extras)
endif ()
find_package(Qt5 REQUIRED ${QT})
find_package(KF5WindowSystem REQUIRED)
@ -47,10 +50,21 @@ else()
message(FATAL_ERROR "qml directory cannot be detected.")
endif()
# Install
if (MSVC)
# Install FishUI to vcpkg installed dir
# for example.
# _VCPKG_INSTALLED_DIR:PATH=C:/app/vcpkg/installed
# VCPKG_TARGET_TRIPLET:STRING=x64-windows
# The final installed dir is C:/app/vcpkg/installed/x64-windows/share/FishUI
set(CMAKECONFIG_INSTALL_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/FishUI")
set(CMAKE_INSTALL_PREFIX "${_VCPKG_INSTALLED_DIR}")
else()
set(CMAKECONFIG_INSTALL_DIR "/usr/lib/cmake/FishUI")
endif ()
message(STATUS "install directory:" "${CMAKECONFIG_INSTALL_DIR}")
add_subdirectory(src)
# Install
set(CMAKECONFIG_INSTALL_DIR "/usr/lib/cmake/FishUI")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/FishUIConfig.cmake.in"

@ -1,29 +1,38 @@
set(TARGET FishUI)
set(MODULE_VERSION "1.0")
set(SOURCES
fishui.cpp
iconthemeprovider.cpp
thememanager.cpp
shadowhelper/windowshadow.cpp
shadowhelper/boxshadowrenderer.cpp
shadowhelper/tileset.cpp
blurhelper/windowblur.cpp
blurhelper/windowblur.h
windowhelper.cpp
iconitem.cpp
newiconitem.cpp
managedtexturenode.cpp
wheelhandler.cpp
desktop/menupopupwindow.cpp
fishui.qrc
fish-style/style.qrc
)
add_library(${TARGET} SHARED ${SOURCES})
add_library(${TARGET} SHARED "")
target_sources(${TARGET} PRIVATE
fishui.cpp
iconthemeprovider.cpp
thememanager.cpp
shadowhelper/windowshadow.cpp
shadowhelper/boxshadowrenderer.cpp
shadowhelper/tileset.cpp
iconitem.cpp
newiconitem.cpp
managedtexturenode.cpp
wheelhandler.cpp
desktop/menupopupwindow.cpp
fishui.qrc
fish-style/style.qrc
)
if (MSVC)
target_sources(${TARGET} PRIVATE
platforms/windows/windowhelper.cpp platforms/windows/windowhelper.h
platforms/windows/blurhelper/windowblur.cpp platforms/windows/blurhelper/windowblur.h
)
target_include_directories(${TARGET} PRIVATE platforms/windows)
else()
target_sources(${TARGET} PRIVATE
platforms/linux/windowhelper.cpp platforms/linux/windowhelper.h
platforms/linux/blurhelper/windowblur.cpp platforms/linux/blurhelper/windowblur.h
)
target_include_directories(${TARGET} PRIVATE platforms/linux)
endif ()
target_link_libraries (${TARGET}
PUBLIC
Qt5::Core
@ -34,13 +43,14 @@ target_link_libraries (${TARGET}
Qt5::Quick
Qt5::QuickControls2
Qt5::GuiPrivate
Qt5::X11Extras
KF5::WindowSystem
)
if (UNIX)
target_link_libraries(${TARGET} PRIVATE Qt5::X11Extras)
endif ()
generate_export_header(${TARGET} BASE_NAME ${TARGET})
install(TARGETS ${TARGET} EXPORT ${TARGET}Targets ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS ${TARGET} DESTINATION ${INSTALL_QMLDIR}/${TARGET})
# Install Controls

@ -0,0 +1,118 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: cutefish <cutefishos@foxmail.com>
*
* This program 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
* any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "windowblur.h"
#include <QApplication>
#include <QPainterPath>
#include <QScreen>
#include <QDebug>
WindowBlur::WindowBlur(QObject *parent) noexcept
: QObject(parent)
, m_view(nullptr)
, m_enabled(false)
, m_windowRadius(0.0)
{
}
WindowBlur::~WindowBlur()
{
}
void WindowBlur::classBegin()
{
}
void WindowBlur::componentComplete()
{
updateBlur();
}
void WindowBlur::setView(QWindow *view)
{
if (view != m_view) {
m_view = view;
updateBlur();
emit viewChanged();
connect(m_view, &QWindow::visibleChanged, this, &WindowBlur::onViewVisibleChanged);
}
}
QWindow* WindowBlur::view() const
{
return m_view;
}
void WindowBlur::setGeometry(const QRect &rect)
{
if (rect != m_rect) {
m_rect = rect;
updateBlur();
emit geometryChanged();
}
}
QRect WindowBlur::geometry() const
{
return m_rect;
}
void WindowBlur::setEnabled(bool enabled)
{
if (enabled != m_enabled) {
m_enabled = enabled;
updateBlur();
emit enabledChanged();
}
}
bool WindowBlur::enabled() const
{
return m_enabled;
}
void WindowBlur::setWindowRadius(qreal radius)
{
if (radius != m_windowRadius) {
m_windowRadius = radius;
updateBlur();
emit windowRadiusChanged();
}
}
qreal WindowBlur::windowRadius() const
{
return m_windowRadius;
}
void WindowBlur::onViewVisibleChanged(bool visible)
{
if (visible)
updateBlur();
}
void WindowBlur::updateBlur()
{
if (!m_view)
return;
qWarning() << "not implement";
}

@ -0,0 +1,78 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: cutefish <cutefishos@foxmail.com>
*
* This program 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
* any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WINDOWBLUR_H
#define WINDOWBLUR_H
#include <QApplication>
#include <QObject>
#include <QQmlEngine>
#include <QQmlParserStatus>
#include <QRect>
#include <QWindow>
#include <QVector>
class WindowBlur : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_PROPERTY(QWindow *view READ view WRITE setView NOTIFY viewChanged)
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(qreal windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged)
Q_INTERFACES(QQmlParserStatus)
public:
WindowBlur(QObject *parent = nullptr) noexcept;
~WindowBlur() override;
void classBegin() override;
void componentComplete() override;
void setView(QWindow *view);
QWindow *view() const;
void setGeometry(const QRect &rect);
QRect geometry() const;
void setEnabled(bool enabled);
bool enabled() const;
void setWindowRadius(qreal radius);
qreal windowRadius() const;
private slots:
void onViewVisibleChanged(bool);
private:
void updateBlur();
signals:
void viewChanged();
void enabledChanged();
void windowRadiusChanged();
void geometryChanged();
private:
QWindow *m_view;
QRect m_rect;
bool m_enabled;
qreal m_windowRadius;
};
#endif

@ -0,0 +1,51 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: cutefish <cutefishos@foxmail.com>
*
* This program 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
* any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "windowhelper.h"
#include <QApplication>
#include <QCursor>
#include <QDebug>
#include <KWindowSystem>
WindowHelper::WindowHelper(QObject *parent)
: QObject(parent)
{
}
void WindowHelper::startSystemMove(QWindow *w)
{
doStartSystemMoveResize(w, 16);
}
void WindowHelper::startSystemResize(QWindow *w, Qt::Edges edges)
{
doStartSystemMoveResize(w, edges);
}
void WindowHelper::minimizeWindow(QWindow *w)
{
KWindowSystem::minimizeWindow(w->winId());
}
void WindowHelper::doStartSystemMoveResize(QWindow *w, int edges)
{
qWarning() << "not implement";
}

@ -0,0 +1,44 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: cutefish <cutefishos@foxmail.com>
*
* This program 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
* any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WINDOWHELPER_H
#define WINDOWHELPER_H
#include <QObject>
#include <QWindow>
class WindowHelper : public QObject
{
Q_OBJECT
public:
explicit WindowHelper(QObject *parent = nullptr);
Q_INVOKABLE void startSystemMove(QWindow *w);
Q_INVOKABLE void startSystemResize(QWindow *w, Qt::Edges edges);
Q_INVOKABLE void minimizeWindow(QWindow *w);
private:
void doStartSystemMoveResize(QWindow *w, int edges);
private:
};
#endif // WINDOWHELPER_H
Loading…
Cancel
Save