File: defaultapp.h

package info (click to toggle)
ukui-control-center 3.22.1.29-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,420 kB
  • sloc: cpp: 77,963; xml: 2,408; sh: 30; makefile: 4
file content (125 lines) | stat: -rw-r--r-- 3,393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * Copyright (C) 2023, KylinSoft Co., Ltd.
 *
 * 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, or (at your option)
 * 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 DEFAULTAPP_H
#define DEFAULTAPP_H

#include <QObject>
#include <QtPlugin>
#include <QComboBox>
#include <QIcon>
#include <QStyledItemDelegate>
#include <QtDBus>
#include <QtConcurrent>
#include <QTime>
#include <QIcon>
#include <QFileSystemWatcher>
#include <QDBusInterface>
#include <QMap>
#include <KService>


#include "shell/interface.h"
#include "fixlabel.h"
#include "titlelabel.h"
#include "mthread.h"
#include "comboxwidget.h"
#include "settinggroup.h"
#include "pushbuttonwidget.h"

#include "defaultappui.h"

/* qt会将glib里的signals成员识别为宏,所以取消该宏
 * 后面如果用到signals时,使用Q_SIGNALS代替即可
 **/
#ifdef signals
#undef signals
#endif

#include <glib.h>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#include "service.h"

namespace Ui {
class DefaultAppWindow;
}

class DefaultApp : public QObject, CommonInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
    Q_INTERFACES(CommonInterface)

public:
    DefaultApp();
    ~DefaultApp();
    void preInitialize();
    QString plugini18nName() Q_DECL_OVERRIDE;
    int pluginTypes() Q_DECL_OVERRIDE;
    QWidget *pluginUi() Q_DECL_OVERRIDE;
    const QString name() const  Q_DECL_OVERRIDE;
    bool isShowOnHomePage() const Q_DECL_OVERRIDE;
    QIcon icon() const Q_DECL_OVERRIDE;
    bool isEnable() const Q_DECL_OVERRIDE;

    void initDefaultUI();
    void setupCompenent();
    void initSlots();
    void initSearchText();

    void load(ComboxWidget *widget, AppInfoService *appInfoService,
              const char *mimeType, const QString &type = NULL);
    void connectToServer();
    void findSelectItem(QComboBox *combox);

private:
    void loadData(AppInfoService *appInfoService, const char *mimeType);

private:
    DefaultAppUi *mDefaultWidget = nullptr;

    QString pluginName;
    int pluginType;
    QDBusInterface *m_cloudInterface;

    QString mDefaultString = NULL;
    QString mSelectString = NULL;
    QString mLocalMimefile = NULL;

    QMap <const char *, QString> mSysDefaultList;
    QDBusInterface  *mDefaultUkccDbus   = nullptr;
    bool mFirstLoad;
    AppInfoService browserService;
    AppInfoService imageService;
    AppInfoService mailService;
    AppInfoService audioService;
    AppInfoService videoService;
    AppInfoService textService;

public slots:
    void browserComBoBox_changed_cb(int index);
    void mailComBoBox_changed_cb(int index);
    void imageComBoBox_changed_cb(int index);
    void audioComBoBox_changed_cb(int index);
    void videoComBoBox_changed_cb(int index);
    void textComBoBox_changed_cb(int index);
    void keyChangedSlot(const QString &key);
    void reset();
};

#endif // DEFAULTAPP_H