blob: 0cea140165cb9a3fb2f98c4b0c1b8d108b6feb17 (
plain)
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
|
#ifndef ENV_SHORTCUT_H
#define ENV_SHORTCUT_H
#include <QString>
class Executable;
namespace env
{
// an application shortcut that can be either on the desktop or the start menu
//
class Shortcut
{
public:
// location of a shortcut
//
enum Locations
{
None = 0,
// on the desktop
Desktop,
// in the start menu
StartMenu
};
// empty shortcut
//
Shortcut();
// shortcut from an executable
//
explicit Shortcut(const Executable& exe);
// sets the name of the shortcut, shown on icons and start menu entries
//
Shortcut& name(const QString& s);
// the program to start
//
Shortcut& target(const QString& s);
// arguments to pass
//
Shortcut& arguments(const QString& s);
// shows in the status bar of explorer, for example
//
Shortcut& description(const QString& s);
// path to a binary that contains the icon and its index
//
Shortcut& icon(const QString& s, int index = 0);
// "start in" option for this shortcut
//
Shortcut& workingDirectory(const QString& s);
// returns whether this shortcut already exists at the given location; this
// does not check whether the shortcut parameters are different, it merely if
// the .lnk file exists
//
bool exists(Locations loc) const;
// calls remove() if exists(), or add()
//
bool toggle(Locations loc);
// adds the shortcut to the given location
//
bool add(Locations loc);
// removes the shortcut from the given location
//
bool remove(Locations loc);
private:
QString m_name;
QString m_target;
QString m_arguments;
QString m_description;
QString m_icon;
int m_iconIndex;
QString m_workingDirectory;
// returns the path where the shortcut file should be saved
//
QString shortcutPath(Locations loc) const;
// returns the directory where the shortcut file should be saved
//
QString shortcutDirectory(Locations loc) const;
// returns the filename of the shortcut file that should be used when saving
//
QString shortcutFilename() const;
};
// returns a string representation of the given location
//
QString toString(Shortcut::Locations loc);
} // namespace env
#endif // ENV_SHORTCUT_H
|