LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
item.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <memory>
12#include <optional>
13#include <QHash>
14#include <QDebug>
15#include <QIcon>
17#include "xdgconfig.h"
18#include "itemtypes.h"
19
20namespace LC::Util::XDG
21{
22 class Item;
23
24 using Item_ptr = std::shared_ptr<Item>;
25
36 {
37 QHash<QString, QString> Name_;
38 QHash<QString, QString> GenericName_;
39 QHash<QString, QString> Comments_;
40
41 QStringList Categories_;
42 QString Command_;
43 QString WD_;
44
45 QString IconName_;
46 mutable std::optional<QIcon> Icon_;
47
48 bool IsHidden_ = false;
49 Type Type_ = Type::Other;
50 public:
60 friend UTIL_XDG_API bool operator== (const Item& left, const Item& right);
61
71 friend UTIL_XDG_API bool operator!= (const Item& left, const Item& right);
72
79 bool IsValid () const;
80
88 bool IsHidden () const;
89
99 void Execute (const ICoreProxy_ptr& proxy) const;
100
110 QString GetName (const QString& language) const;
111
122 QString GetGenericName (const QString& language) const;
123
132 QString GetComment (const QString& language) const;
133
143 QString GetIconName () const;
144
149 QStringList GetCategories () const;
150
155 Type GetType () const;
156
167 QString GetCommand () const;
168
179 QString GetWorkingDirectory () const;
180
188 QString GetPermanentID () const;
189
206 QIcon GetIcon (const ICoreProxy_ptr&) const;
207
217 QDebug DebugPrint (QDebug stream) const;
218
228 static Item_ptr FromDesktopFile (const QString& file);
229 };
230
240 QDebug operator<< (QDebug stream, const Item& item);
241}
Describes a single XDG .desktop entry.
Definition item.h:36
QIcon GetIcon(const ICoreProxy_ptr &) const
Returns the icon previously set by SetIcon().
Definition item.cpp:164
void Execute(const ICoreProxy_ptr &proxy) const
Executes this item, if possible.
Definition item.cpp:51
QString GetCommand() const
Returns type type-specific command for this item.
Definition item.cpp:125
bool IsValid() const
Checks whether this XDG item is valid.
Definition item.cpp:41
static Item_ptr FromDesktopFile(const QString &file)
Loads the XDG .desktop item from file.
Definition item.cpp:197
Type GetType() const
Returns the type of this item.
Definition item.cpp:120
QString GetWorkingDirectory() const
Returns the working directory for command execution.
Definition item.cpp:130
QString GetComment(const QString &language) const
Returns the comment of this item.
Definition item.cpp:105
QString GetPermanentID() const
Returns the permanent ID of this item.
Definition item.cpp:135
bool IsHidden() const
Checks whether this XDG item should be hidden.
Definition item.cpp:46
QString GetGenericName(const QString &language) const
Returns the generic name of this item.
Definition item.cpp:100
QString GetName(const QString &language) const
Returns the name of this item.
Definition item.cpp:95
QString GetIconName() const
Returns the name of the icon for this item.
Definition item.cpp:110
QStringList GetCategories() const
Returns the categories where this item belongs.
Definition item.cpp:115
QDebug DebugPrint(QDebug stream) const
Serializes item contents to the debugging stream.
Definition item.cpp:172
auto operator==(const T &left, const T &right)
Definition common.h:38
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition icoreproxy.h:181
std::shared_ptr< Item > Item_ptr
Definition item.h:24
Type
Describes the various types of XDG .desktop files.
Definition itemtypes.h:20
@ Other
Unknown type.
Definition itemtypes.h:23
QDebug operator<<(QDebug dbg, const Item &item)
Serializes item contents to the debugging stream.
Definition item.cpp:239
#define UTIL_XDG_API
Definition xdgconfig.h:16