File: main.cpp

package info (click to toggle)
dde-store 1.2.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 724 kB
  • sloc: cpp: 2,048; makefile: 5
file content (49 lines) | stat: -rw-r--r-- 1,660 bytes parent folder | download | duplicates (2)
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
#include "mainwindow.h"
#include "backend/sourcemanager.h"
#include <DApplication>
#include <DAboutDialog>
#include <DWidgetUtil>
#include <QDebug>
#include <QUrl>
#include <QCommandLineParser>

DWIDGET_USE_NAMESPACE

int main(int argc, char *argv[])
{
    DApplication app(argc, argv);

    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addPositionalArgument("url", "Appstream url of an app to open");
    parser.process(app);

    if (app.setSingleInstance("dde-store")) {
        app.loadTranslator();
        app.setApplicationName("dde-store");
        app.setOrganizationName("dekzi");
        app.setAttribute(Qt::AA_UseHighDpiPixmaps);

        DAboutDialog about;
        app.setAboutDialog(&about);
        about.setProductIcon(QIcon::fromTheme("deepin-app-store"));
        about.setProductName("DDE Store");
        about.setDescription(qApp->translate("main", "An app store for DDE built with DTK") + "<br/>" + qApp->translate("main", "Created by %1").arg("<a href='https://github.com/dekzi'>dekzi</a>") + "<br/><br/><a href='https://github.com/dekzi/dde-store'>https://github.com/dekzi/dde-store</a>");
        about.setVersion("1.2.3");

        MainWindow w;
        Dtk::Widget::moveToCenter(&w);
        w.show();

        if (!parser.positionalArguments().isEmpty()) {
            QUrl url(parser.positionalArguments()[0]);
            for (Source *source : SourceManager::instance()->sources()) {
                if (source->urlSchemes().contains(url.scheme()) && source->appFromUrl(url))
                    w.openItem(source->appFromUrl(url));
            }
        }

        return app.exec();
    }
    return 0;
}