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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
//
// C++ Implementation: apppropprg
//
// Description:
//
//
// Author: KoolDock team <radix@kde.cl>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include <kicondialog.h>
#include <tdefiledialog.h>
#include <tdemessagebox.h>
#include <kstandarddirs.h>
#include <tdelocale.h>
#include "apppropprg.h"
#include "appProp.h"
#include "kooldock.h"
appPropPrg::appPropPrg(TQWidget *parent,
const char* name):
appProp(parent, name)
{
}
appPropPrg::~appPropPrg()
{
}
void appPropPrg::accept()
{
TQString icon;
TQString desktop;
TQString path;
TQString puser;
icon = iconbutton->icon();
desktop = cmdname->text();
path = cmdpath->text();
puser = user->text();
if (icon.length() == 0) {
KMessageBox::sorry(0, i18n("You must select an icon!"), i18n("Error"), 1);
return;
}
if (desktop.length() == 0) {
KMessageBox::sorry(0, i18n("You must enter a name!"), i18n("Error"), 1);
return;
}
if (path.length() == 0) {
KMessageBox::sorry(0, i18n("You must enter a command or path!"), i18n("Error"), 1);
return;
}
if ((cuser->isChecked() == true) && (puser.length() == 0)) {
KMessageBox::sorry(0, i18n("You must provide a username!"), i18n("Error"), 1);
return;
}
// Modify desktop (lowercase, no spaces)
desktop.remove(" ", true);
desktop = desktop.lower();
desktop.append(".desktop");
// Handle position
TQString progPath = locateLocal("data", "kooldock");
TQDir dir(progPath + TQString("/menu/"));
TQString preffix;
TQStringList fileList = dir.entryList("*.desktop");
int pos = fileList.count();
if (pos < 10) {
preffix = TQString("0%1_").arg(pos);
}
if (pos >= 10) {
preffix = TQString("%1_").arg(pos);
}
desktop.prepend(preffix);
// End handling position
// Add the .desktop file to the menuPath
KoolDock::addFile(desktop, icon, cmdpath->text(), cmdname->text(),
true, terminal->isChecked(), tclose->isChecked(),
cuser->isChecked(), user->text());
user->setEnabled(false);
cuser->setChecked(false);
terminal->setChecked(false);
tclose->setChecked(false);
tclose->setEnabled(false);
this->hide();
emit apply();
}
void appPropPrg::reject()
{
user->setEnabled(false);
cuser->setChecked(false);
terminal->setChecked(false);
tclose->setChecked(false);
tclose->setEnabled(false);
this->hide();
}
void appPropPrg::closeEvent(TQCloseEvent* e)
{
e->ignore();
reject();
}
void appPropPrg::cmdfile_clicked()
{
TQString fileToOpen = KFileDialog::getOpenFileName(TQDir::currentDirPath(), "*.*", this, i18n("Open File"));
if (!fileToOpen.isEmpty()) {
cmdpath->setText(fileToOpen);
// Set a default icon based on the program name
TQString tmp = fileToOpen;
int pos = tmp.findRev("/", -1);
if (pos != -1) {
tmp.remove(1, pos);
tmp.remove("/", true);
}
iconbutton->setIcon(tmp);
cmdname->setText(tmp);
}
}
void appPropPrg::cuserchk()
{
if (cuser->isChecked() == true) {
user->setEnabled(true);
}
else {
user->setEnabled(false);
}
}
void appPropPrg::terminalchk()
{
if (terminal->isChecked() == true) {
tclose->setEnabled(true);
}
else {
tclose->setChecked(false);
tclose->setEnabled(false);
}
}
#include "apppropprg.moc"
|