summarylogtreecommitdiffstats
path: root/qt5.patch
blob: e87d1a678a3aaa06214e7b452899e56a0d6a625c (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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
diff -Naur a/install.sh b/install.sh
--- a/install.sh	2012-03-06 15:44:43.000000000 +0800
+++ b/install.sh	2015-12-09 17:16:50.755868557 +0800
@@ -1,11 +1,12 @@
 #!/bin/bash
-
+basedir=$(cd `dirname $0`;pwd)
+cd "$basedir"
 # root check
-if [ `whoami` != "root" ];
-then
-    echo "You have to be root to run this script ....";
-    exit -1;
-fi;
+#if [ `whoami` != "root" ];
+#then
+#    echo "You have to be root to run this script ....";
+#    exit -1;
+#fi;
 echo "***********************************************"
 echo "*                                             *"
 echo "* clean up .....................              *"
@@ -18,31 +19,40 @@
 echo "* compiling ....................              *"
 echo "*                                             *"
 echo "***********************************************"
-qmake
+mkdir -p "$basedir/build"
+cd "$basedir/build"
+qmake-qt5 ..
 make
 echo "***********************************************"
 echo "*                                             *"
 echo "* Translations .................              *"
 echo "*                                             *"
 echo "***********************************************"
-lrelease kndiswrapper.pro
+
+#lrelease ../kndiswrapper.pro
+cp -r "$basedir/translations" "$basedir/build"
+lrelease-qt5 "$basedir/build/translations"/*.ts
 echo "***********************************************"
 echo "*                                             *"
 echo "* installing ...................              *"
 echo "*                                             *"
 echo "***********************************************"
-if [ ! -e /usr/share/kndiswrapper ];
-then
-    mkdir -p /usr/share/kndiswrapper
-fi
 
-echo "cp icons/kndiswrapper.xpm /usr/share/kndiswrapper" && cp icons/kndiswrapper.xpm /usr/share/kndiswrapper/kndiswrapper.xpm
-echo "cp kndiswrapper /usr/sbin" && cp kndiswrapper /usr/sbin
-chown root:root /usr/sbin/kndiswrapper
-chmod 755 /usr/sbin/kndiswrapper
-echo "cp translations/*.qm /usr/share/kndiswrapper" && cp translations/*.qm /usr/share/kndiswrapper
-echo "cp translations/cards_known_to_work.txt /usr/share/kndiswrapper" && cp translations/cards_known_to_work.txt /usr/share/kndiswrapper
-cat > /usr/share/applications/kndiswrapper.desktop <<EOF
+mkdir -p ${1}/usr/share/{kndiswrapper,applications,pixmaps}
+mkdir -p ${1}/usr/bin
+
+echo "cp icons/kndiswrapper.xpm ${1}/usr/share/kndiswrapper"
+cp "$basedir/icons/kndiswrapper.xpm" ${1}/usr/share/kndiswrapper/kndiswrapper.xpm
+echo "cp icons/kndiswrapper.xpm ${1}/usr/share/pixmaps"
+cp "$basedir/icons/kndiswrapper.xpm" ${1}/usr/share/pixmaps/kndiswrapper.xpm
+echo "cp kndiswrapper ${1}/usr/bin" && cp kndiswrapper ${1}/usr/bin
+#chown root:root ${1}/usr/bin/kndiswrapper
+chmod 755 ${1}/usr/bin/kndiswrapper
+echo "cp translations/build/*.qm ${1}/usr/share/kndiswrapper"
+cp "$basedir/translations/"*.qm ${1}/usr/share/kndiswrapper
+echo "cp translations/cards_known_to_work.txt ${1}/usr/share/kndiswrapper"
+cp "$basedir/translations/cards_known_to_work.txt" ${1}/usr/share/kndiswrapper
+cat > ${1}/usr/share/applications/kndiswrapper.desktop <<EOF
 [Desktop Entry]
 Encoding=UTF-8
 Name=kndiswrapper
@@ -52,7 +62,7 @@
 Comment=A GUI for ndiswrapper
 Comment[de]=Eine GUI fuer ndiswrapper.
 Exec=/usr/bin/kndiswrapper
-Icon=/usr/share/kndiswrapper/kndiswrapper.png
+Icon=kndiswrapper
 Terminal=false
 Type=Application
 StartupNotify=true
diff -Naur a/kndiswrapper.pro b/kndiswrapper.pro
--- a/kndiswrapper.pro	2012-03-06 15:44:43.000000000 +0800
+++ b/kndiswrapper.pro	2015-12-09 17:16:50.755868557 +0800
@@ -4,7 +4,7 @@
 #
 #-------------------------------------------------
 
-QT       += core gui
+QT       += core gui widgets
 
 TARGET = kndiswrapper
 TEMPLATE = app
diff -Naur a/src/kndiswrapper.cpp b/src/kndiswrapper.cpp
--- a/src/kndiswrapper.cpp	2012-03-06 15:44:43.000000000 +0800
+++ b/src/kndiswrapper.cpp	2015-12-09 18:02:43.402730822 +0800
@@ -1,7 +1,8 @@
 #include "kndiswrapper.h"
-#include <klocale.h>
+#include <QDebug>
+#include <unistd.h>
 //
-kndiswrapper::kndiswrapper( QWidget * parent, Qt::WFlags f) : QDialog(parent, f)
+kndiswrapper::kndiswrapper( QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f)
 {
 	//setupUi(this);
 
@@ -35,19 +36,35 @@
 	disablenetconf=false;
 	invokeSetup=false;
         debug=false;
-	if (qApp->argc() > 1){
-		for (int i=0; i < qApp->argc();i++){
-			if ((QString)qApp->argv()[i] == "--disablerootcheck") disablerootcheck=true;
-			if ((QString)qApp->argv()[i] == "--setup") invokeSetup=true;
-			if ((QString)qApp->argv()[i] == "--disablenetconf") disablenetconf=true;
-                        if ((QString)qApp->argv()[i] == "--debug") debug=true;
+	if (QCoreApplication::arguments().count() > 1){
+		for (int i=0; i < QCoreApplication::arguments().count();i++){
+			if ((QString)QCoreApplication::arguments()[i] == "--disablerootcheck") disablerootcheck=true;
+			if ((QString)QCoreApplication::arguments()[i] == "--setup") invokeSetup=true;
+			if ((QString)QCoreApplication::arguments()[i] == "--disablenetconf") disablenetconf=true;
+                        if ((QString)QCoreApplication::arguments()[i] == "--debug") debug=true;
 		}
 	}
 
-        QString rootcheck = (QString)getenv("HOME");
-        if (rootcheck != "/root"){
+        if (getuid() != 0){
             if (!disablerootcheck){
-                QMessageBox::information(this,"DEBUG","You have to be root to run this programm.\nTry --disablerootcheck for testing.");
+                QStringList SuCandidates;
+                QString SuCmd; 
+                SuCandidates << "kdesu" << "gksu" << "kdesudo" << "gksudo";
+                for (int i=0;i<SuCandidates.count();++i) {
+                    QString rval;
+                    rval = QStandardPaths::findExecutable(SuCandidates[i]);
+                    if (QFileInfo(rval).isExecutable()) {
+                        SuCmd = SuCandidates[i];
+                        break;
+                    }
+                }
+                if (SuCmd != QString()) {
+                    QProcess process;
+                    process.startDetached(SuCmd+QString(" ")+QCoreApplication::applicationFilePath());
+                    //process.waitForFinished(-1);
+                } else {
+                    QMessageBox::information(this,"DEBUG","You have to be root to run this programm.\nTry --disablerootcheck for testing.");
+                }
                 exit(0);
             }
         }
@@ -173,9 +190,9 @@
         QString launcher;
         launcher = "kdesu ";
         launcher = launcher + "\"kndiswrapper ";
-        if (qApp->argc() > 1){
-          for (int i=1; i < qApp->argc();i++){
-            launcher = launcher + (QString)qApp->argv()[i] + " ";
+        if (QCoreApplication::arguments().count() > 1){
+          for (int i=1; i < QCoreApplication::arguments().count();i++){
+            launcher = launcher + (QString)QCoreApplication::arguments()[i] + " ";
           }
         }
         launcher = launcher + "\" &";
diff -Naur a/src/kndiswrapper.h b/src/kndiswrapper.h
--- a/src/kndiswrapper.h	2012-03-06 15:44:43.000000000 +0800
+++ b/src/kndiswrapper.h	2015-12-09 17:43:30.160769769 +0800
@@ -19,6 +19,7 @@
 #include <QFont>
 #include <QDir>
 #include <QAction>
+#include <QStandardPaths>
 //#include <cstdlib>
 //#include <cstring>
 #include "ui_kndiswrapper.h"
@@ -26,7 +27,7 @@
 class kndiswrapper : public QDialog, public Ui::kndiswrapper{
 	Q_OBJECT
 public:
-	kndiswrapper(QWidget * parent = 0, Qt::WFlags f = 0);
+	kndiswrapper(QWidget * parent = 0, Qt::WindowFlags f = 0);
 	virtual ~kndiswrapper();
 
 private: