# DEFINES += QT_VERSION_MAJOR=6 QT_MAJOR_VERSION=6
QT += core gui printsupport sql dbus multimedia svg
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets quickwidgets

CONFIG += c++17 link_pkgconfig

PKGCONFIG += KF6WindowSystem gsettings-qt6 glib-2.0 kysdk-datacollect kysdk-sysinfo kysdk-qtwidgets kysdk-alm
LIBS += -lukui-log4qt -lKF6Screen -lkysdk-qtwidgets -lcmark -lpolkit-qt6-core-1 -lKF6GlobalAccel

# The following define makes your compiler Q_EMIT warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
#DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
INCLUDEPATH += /usr/include/KF6/KWindowSystem/ \
              /usr/include/KF6/KGlobalAccel
TRANSLATIONS += translations/Internationalization_zh_CN.ts \
                translations/Internationalization_zh_HK.ts \
                translations/Internationalization_bo_CN.ts \
                translations/Internationalization_mn.ts

# Generate translations in build
TRANSLATIONS_FILES =

qtPrepareTool(LRELEASE, lrelease)
for(tsfile, TRANSLATIONS) {
    qmfile = $$shadowed($$tsfile)
    qmfile ~= s,.ts$,.qm,
    qmdir = $$dirname(qmfile)
    !exists($$qmdir) {
        mkpath($$qmdir)|error("Aborting.")
    }
    command = $$LRELEASE -removeidentical $$tsfile -qm $$qmfile
    system($$command)|error("Failed to run: $$command")
    TRANSLATIONS_FILES += $$qmfile
}

include(libukcc/widgets.pri)

SOURCES += \
    aiservicedialog.cpp \
    cmainwnd.cpp \
    chatdatabase.cpp \
    commandtemplatelist.cpp \
    configmanager.cpp \
    cpushbuttonex.cpp \
    # ctrl.cpp \
    custommessagebox.cpp \
    dbus/kadbusoperator.cpp \
    global/kaglobal.cpp \
    introductionview.cpp \
    main.cpp \
    msgpane.cpp \
    reader.cpp \
    recorder.cpp \
    setting/clickfixlabel.cpp \
    setting/commandconfigdialog.cpp \
    setting/commandpage.cpp \
    setting/conventionpage.cpp \
    setting/scribewordpage.cpp \
    setting/settingdialog.cpp \
    sqlconversationmodel.cpp \
    systemchat.cpp \
    textselect/clipboard.cpp \
    textselect/mypushbutton.cpp \
    textselect/selection.cpp \
    textselect/selectmorecommand.cpp \
    tipwidget.cpp \
    # xeventmonitor.cpp

HEADERS += \
    aiservicedialog.h \
    cmainwnd.h \
    chatdatabase.h \
    commandtemplatelist.h \
    configmanager.h \
    cpushbuttonex.h \
    # ctrl.h \
    custommessagebox.h \
    dbus/kadbusoperator.h \
    global/kaglobal.h \
    introductionview.h \
    msgpane.h \
    reader.h \
    recorder.h \
    setting/clickfixlabel.h \
    setting/commandconfigdialog.h \
    setting/commandpage.h \
    setting/conventionpage.h \
    setting/scribewordpage.h \
    setting/settingdialog.h \
    sqlconversationmodel.h \
    systemchat.h \
    textselect/clipboard.h \
    textselect/mypushbutton.h \
    textselect/selection.h \
    textselect/selectmorecommand.h \
    tipwidget.h \
    usdbrightness.h \
    # xeventmonitor.h

RESOURCES += \
    res/msgpane.qrc
CONFIG += link_pkgconfig
PKGCONFIG +=  kysdk-qtwidgets  kysdk-ukuiwindowhelper librsvg-2.0 kyai-config kyai-assistant kysdk-coreai-speech kysdk-ukenv kysdk-ai-common

DEFINES += UKUI_WINDOWHELPER_SUPPORT
PKGCONFIG += kysdk-ukuiwindowhelper kysdk-waylandhelper

TARGET = kylin-aiassistant
TEMPLATE = app

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

# installs
unix:!macx {
    isEmpty(PREFIX) {
      packaging {
        PREFIX = /usr
      } else {
        PREFIX = /usr/local
      }
    }

    DEFINES += APP_PREFIX=\\\"$$PREFIX\\\"

    target.path = $${PREFIX}/bin/

    guide.files = $$PWD/data/guide/kylin-aiassistant/
    guide.path = /usr/share/kylin-user-guide/data/guide

    qmfile.path = $${PREFIX}/share/kylin-aiassistant/translations/
    qmfile.files = $${TRANSLATIONS_FILES}

    autuostart.files = kylin-aiassistant-autostart.desktop
    autuostart.path = /etc/xdg/autostart/

#    shortcut.files = kylin-aiassistant-shortcut.desktop
#    shortcut.path = /usr/share/applications

    polkit.files += data/org.kylin.aiassistant.policy
    polkit.path = /usr/share/polkit-1/actions/
    
#    schemas.files = data/org.kylin.aiassistant.gschema.xml
#    schemas.path = /usr/share/glib-2.0/schemas

    service.files = data/org.ukui.kylin_aiassistant.service
    service.path = /usr/share/dbus-1/services

    icon.path = /usr/share/pixmaps
    icon.files = res/icon/AI-Writing.svg \
                 res/icon/AI-Writing.png

    desktopentry.path = $${PREFIX}/share/applications
    desktopentry.files = kylin-aiassistant.desktop

    plugin_schema.files = $$PWD/data/org.kylin.SettingsDaemon.plugins.media-keys.kylin-aiassistant.gschema.xml
    plugin_schema.path = /usr/share/glib-2.0/schemas/

    doctemplate.files = res/html/custom-reference.docx
    doctemplate.path = $${PREFIX}/share/kylin-aiassistant/

    INSTALLS += target qmfile schemas service icon desktopentry polkit plugin_schema doctemplate guide

}

DISTFILES += \
    data/guide/kylin-aiassistant/zh_CN/image/会议助手入口.png \
    data/guide/kylin-aiassistant/zh_CN/image/侧边栏模式.png \
    data/guide/kylin-aiassistant/zh_CN/image/关于.png \
    data/guide/kylin-aiassistant/zh_CN/image/切换模板-更多.png \
    data/guide/kylin-aiassistant/zh_CN/image/划词悬浮条-1.png \
    data/guide/kylin-aiassistant/zh_CN/image/划词悬浮条-右键菜单.png \
    data/guide/kylin-aiassistant/zh_CN/image/划词悬浮条.png \
    data/guide/kylin-aiassistant/zh_CN/image/历史对话清除1.png \
    data/guide/kylin-aiassistant/zh_CN/image/图片处理.png \
    data/guide/kylin-aiassistant/zh_CN/image/复制.png \
    data/guide/kylin-aiassistant/zh_CN/image/左侧导航栏.png \
    data/guide/kylin-aiassistant/zh_CN/image/帮助.png \
    data/guide/kylin-aiassistant/zh_CN/image/开启新话题.png \
    data/guide/kylin-aiassistant/zh_CN/image/开始菜单打开AI助手.png \
    data/guide/kylin-aiassistant/zh_CN/image/录制页.png \
    data/guide/kylin-aiassistant/zh_CN/image/托盘区图标.png \
    data/guide/kylin-aiassistant/zh_CN/image/指令模板.png \
    data/guide/kylin-aiassistant/zh_CN/image/文本对话.png \
    data/guide/kylin-aiassistant/zh_CN/image/文档拖入.png \
    data/guide/kylin-aiassistant/zh_CN/image/文生图.png \
    data/guide/kylin-aiassistant/zh_CN/image/日程添加1.png \
    data/guide/kylin-aiassistant/zh_CN/image/日程添加2.png \
    data/guide/kylin-aiassistant/zh_CN/image/朗读.png \
    data/guide/kylin-aiassistant/zh_CN/image/本地模型.png \
    data/guide/kylin-aiassistant/zh_CN/image/模型配置.png \
    data/guide/kylin-aiassistant/zh_CN/image/清空上下文.png \
    data/guide/kylin-aiassistant/zh_CN/image/点赞点踩.png \
    data/guide/kylin-aiassistant/zh_CN/image/用户昵称过长.png \
    data/guide/kylin-aiassistant/zh_CN/image/系统控制.png \
    data/guide/kylin-aiassistant/zh_CN/image/自选模型.png \
    data/guide/kylin-aiassistant/zh_CN/image/视图模式.png \
    data/guide/kylin-aiassistant/zh_CN/image/设置.png \
    data/guide/kylin-aiassistant/zh_CN/image/语音输入.png \
    data/guide/kylin-aiassistant/zh_CN/image/重新回答.png \
    data/guide/kylin-aiassistant/zh_CN/image/首页.png \
    data/guide/kylin-aiassistant/zh_CN/index.md \
    data/org.kylin.SettingsDaemon.plugins.media-keys.kylin-aiassistant.gschema.xml \
    data/org.kylin.aiassistant.policy

