-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 10 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 100 | ||||
-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 2 |
4 files changed, 49 insertions, 65 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index f4ca0bf..5c40569 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -172,100 +172,106 @@ static const char *commonCmds[] = | |||
172 | "rm ", | 172 | "rm ", |
173 | "rmdir ", | 173 | "rmdir ", |
174 | "route ", | 174 | "route ", |
175 | "set ", | 175 | "set ", |
176 | "traceroute", | 176 | "traceroute", |
177 | 177 | ||
178 | /* | 178 | /* |
179 | "gzip", | 179 | "gzip", |
180 | "gunzip", | 180 | "gunzip", |
181 | "chgrp", | 181 | "chgrp", |
182 | "chown", | 182 | "chown", |
183 | "date", | 183 | "date", |
184 | "dd", | 184 | "dd", |
185 | "df", | 185 | "df", |
186 | "dmesg", | 186 | "dmesg", |
187 | "fuser", | 187 | "fuser", |
188 | "hostname", | 188 | "hostname", |
189 | "kill", | 189 | "kill", |
190 | "killall", | 190 | "killall", |
191 | "ln", | 191 | "ln", |
192 | "ping", | 192 | "ping", |
193 | "mount", | 193 | "mount", |
194 | "more", | 194 | "more", |
195 | "sort", | 195 | "sort", |
196 | "touch", | 196 | "touch", |
197 | "umount", | 197 | "umount", |
198 | "mknod", | 198 | "mknod", |
199 | "netstat", | 199 | "netstat", |
200 | */ | 200 | */ |
201 | 201 | ||
202 | "exit", | 202 | "exit", |
203 | NULL | 203 | NULL |
204 | }; | 204 | }; |
205 | 205 | ||
206 | 206 | ||
207 | static void konsoleInit(const char** shell) { | 207 | static void konsoleInit(const char** shell) { |
208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; | 208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; |
209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges | 209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges |
210 | 210 | ||
211 | 211 | ||
212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
213 | 213 | ||
214 | odebug << "keyboard grabbed" << oendl; | 214 | odebug << "keyboard grabbed" << oendl; |
215 | #ifdef FAKE_CTRL_AND_ALT | 215 | #ifdef FAKE_CTRL_AND_ALT |
216 | odebug << "Fake Ctrl and Alt defined" << oendl; | 216 | odebug << "Fake Ctrl and Alt defined" << oendl; |
217 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 217 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
218 | #endif | 218 | #endif |
219 | 219 | ||
220 | if (!shell) { | ||
221 | owarn << "No double pointer 'shell'" << oendl; | ||
222 | return; | ||
223 | } | ||
224 | |||
220 | *shell = getenv("SHELL"); | 225 | *shell = getenv("SHELL"); |
221 | owarn << "SHell initially is " << *shell << "" << oendl; | 226 | if (*shell) |
227 | owarn << "Current shell: " << *shell << "" << oendl; | ||
222 | 228 | ||
223 | if (shell == NULL || *shell == '\0') { | 229 | if (*shell == NULL || **shell == '\0') { |
224 | struct passwd *ent = 0; | 230 | struct passwd *ent = 0; |
225 | uid_t me = getuid(); | 231 | uid_t me = getuid(); |
226 | *shell = "/bin/sh"; | 232 | *shell = "/bin/sh"; |
227 | 233 | ||
228 | while ( (ent = getpwent()) != 0 ) { | 234 | while ( (ent = getpwent()) != 0 ) { |
229 | if (ent->pw_uid == me) { | 235 | if (ent->pw_uid == me) { |
230 | if (ent->pw_shell != "") | 236 | if (ent->pw_shell != "") |
231 | *shell = ent->pw_shell; | 237 | *shell = ent->pw_shell; |
232 | break; | 238 | break; |
233 | } | 239 | } |
234 | } | 240 | } |
235 | endpwent(); | 241 | endpwent(); |
236 | } | 242 | } |
237 | 243 | ||
238 | if( putenv((char*)"COLORTERM=") !=0) | 244 | if( putenv((char*)"COLORTERM=") !=0) |
239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection | 245 | odebug << "putenv failed" << oendl; // to trigger mc's color detection |
240 | } | 246 | } |
241 | 247 | ||
242 | 248 | ||
243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 249 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
244 | QMainWindow(parent, name, fl) | 250 | QMainWindow(parent, name, fl) |
245 | { | 251 | { |
246 | QStrList tmp; const char* shell; | 252 | QStrList tmp; const char* shell; |
247 | 253 | ||
248 | konsoleInit( &shell); | 254 | konsoleInit( &shell); |
249 | init(shell,tmp); | 255 | init(shell,tmp); |
250 | } | 256 | } |
251 | 257 | ||
252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 258 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
253 | : QMainWindow(0, name) | 259 | : QMainWindow(0, name) |
254 | { | 260 | { |
255 | init(_pgm,_args); | 261 | init(_pgm,_args); |
256 | } | 262 | } |
257 | 263 | ||
258 | struct HistoryItem | 264 | struct HistoryItem |
259 | { | 265 | { |
260 | HistoryItem(int c, const QString &l) | 266 | HistoryItem(int c, const QString &l) |
261 | { | 267 | { |
262 | count = c; | 268 | count = c; |
263 | line = l; | 269 | line = l; |
264 | } | 270 | } |
265 | int count; | 271 | int count; |
266 | QString line; | 272 | QString line; |
267 | }; | 273 | }; |
268 | 274 | ||
269 | class HistoryList : public QList<HistoryItem> | 275 | class HistoryList : public QList<HistoryItem> |
270 | { | 276 | { |
271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 277 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 61beac5..4bbc62b 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -805,196 +805,176 @@ bool TextEdit::save() { | |||
805 | currentFileName = name; | 805 | currentFileName = name; |
806 | odebug << "saveFile "+currentFileName << oendl; | 806 | odebug << "saveFile "+currentFileName << oendl; |
807 | 807 | ||
808 | struct stat buf; | 808 | struct stat buf; |
809 | mode_t mode; | 809 | mode_t mode; |
810 | stat(file.latin1(), &buf); | 810 | stat(file.latin1(), &buf); |
811 | mode = buf.st_mode; | 811 | mode = buf.st_mode; |
812 | 812 | ||
813 | if(!fileIs) { | 813 | if(!fileIs) { |
814 | doc->setName( name); | 814 | doc->setName( name); |
815 | FileManager fm; | 815 | FileManager fm; |
816 | if ( !fm.saveFile( *doc, rt ) ) { | 816 | if ( !fm.saveFile( *doc, rt ) ) { |
817 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 817 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
818 | return false; | 818 | return false; |
819 | } | 819 | } |
820 | } else { | 820 | } else { |
821 | odebug << "regular save file" << oendl; | 821 | odebug << "regular save file" << oendl; |
822 | QFile f(file); | 822 | QFile f(file); |
823 | if( f.open(IO_WriteOnly)) { | 823 | if( f.open(IO_WriteOnly)) { |
824 | QCString crt = rt.utf8(); | 824 | QCString crt = rt.utf8(); |
825 | f.writeBlock(crt,crt.length()); | 825 | f.writeBlock(crt,crt.length()); |
826 | } else { | 826 | } else { |
827 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 827 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
828 | return false; | 828 | return false; |
829 | } | 829 | } |
830 | 830 | ||
831 | } | 831 | } |
832 | editor->setEdited( false); | 832 | editor->setEdited( false); |
833 | edited1=false; | 833 | edited1=false; |
834 | edited=false; | 834 | edited=false; |
835 | if(caption().left(1)=="*") | 835 | if(caption().left(1)=="*") |
836 | setCaption(caption().right(caption().length()-1)); | 836 | setCaption(caption().right(caption().length()-1)); |
837 | 837 | ||
838 | 838 | ||
839 | chmod( file.latin1(), mode); | 839 | chmod( file.latin1(), mode); |
840 | } | 840 | } |
841 | return true; | 841 | return true; |
842 | } | 842 | } |
843 | return false; | 843 | return false; |
844 | } | 844 | } |
845 | 845 | ||
846 | /*! | 846 | /*! |
847 | prompted save */ | 847 | prompted save */ |
848 | bool TextEdit::saveAs() { | 848 | bool TextEdit::saveAs() { |
849 | 849 | ||
850 | if(caption() == tr("Text Editor")) | 850 | if(caption() == tr("Text Editor")) |
851 | return false; | 851 | return false; |
852 | odebug << "saveAsFile " + currentFileName << oendl; | 852 | odebug << "saveAsFile " + currentFileName << oendl; |
853 | // case of nothing to save... | ||
854 | // if ( !doc && !currentFileName.isEmpty()) { | ||
855 | // //|| !bFromDocView) | ||
856 | // odebug << "no doc" << oendl; | ||
857 | // return true; | ||
858 | // } | ||
859 | // if ( !editor->edited() ) { | ||
860 | // delete doc; | ||
861 | // doc = 0; | ||
862 | // return true; | ||
863 | // } | ||
864 | 853 | ||
865 | QString rt = editor->text(); | 854 | QString rt = editor->text(); |
866 | odebug << currentFileName << oendl; | 855 | odebug << currentFileName << oendl; |
867 | 856 | ||
868 | if( currentFileName.isEmpty() | 857 | if( currentFileName.isEmpty() |
869 | || currentFileName == tr("Unnamed") | 858 | || currentFileName == tr("Unnamed") |
870 | || currentFileName == tr("Text Editor")) { | 859 | || currentFileName == tr("Text Editor")) |
860 | { | ||
871 | odebug << "do silly TT filename thing" << oendl; | 861 | odebug << "do silly TT filename thing" << oendl; |
872 | // if ( doc && doc->name().isEmpty() ) { | ||
873 | QString pt = rt.simplifyWhiteSpace(); | 862 | QString pt = rt.simplifyWhiteSpace(); |
874 | int i = pt.find( ' ' ); | 863 | int i = pt.find( ' ' ); |
875 | QString docname = pt; | 864 | QString docname = pt; |
876 | if ( i > 0 ) | 865 | if ( i > 0 ) docname = pt.left( i ); |
877 | docname = pt.left( i ); | 866 | |
878 | // remove "." at the beginning | ||
879 | while( docname.startsWith( "." ) ) | 867 | while( docname.startsWith( "." ) ) |
880 | docname = docname.mid( 1 ); | 868 | docname = docname.mid( 1 ); |
881 | docname.replace( QRegExp("/"), "_" ); | 869 | docname.replace( QRegExp("/"), "_" ); |
882 | // cut the length. filenames longer than that | 870 | // Cut the length. Filenames longer than 40 are not helpful |
883 | //don't make sense and something goes wrong when they get too long. | 871 | // and something goes wrong when they get too long. |
884 | if ( docname.length() > 40 ) | 872 | if ( docname.length() > 40 ) docname = docname.left(40); |
885 | docname = docname.left(40); | 873 | |
886 | if ( docname.isEmpty() ) | 874 | if ( docname.isEmpty() ) docname = tr("Unnamed"); |
887 | docname = tr("Unnamed"); | 875 | |
888 | if(doc) doc->setName(docname); | 876 | if(doc) doc->setName(docname); |
877 | |||
889 | currentFileName=docname; | 878 | currentFileName=docname; |
890 | // } | ||
891 | // else | ||
892 | // odebug << "hmmmmmm" << oendl; | ||
893 | } | 879 | } |
894 | 880 | ||
895 | 881 | ||
896 | QMap<QString, QStringList> map; | 882 | QMap<QString, QStringList> map; |
897 | map.insert(tr("All"), QStringList() ); | 883 | map.insert(tr("All"), QStringList() ); |
898 | QStringList text; | 884 | QStringList text; |
899 | text << "text/*"; | 885 | text << "text/*"; |
900 | map.insert(tr("Text"), text ); | 886 | map.insert(tr("Text"), text ); |
901 | text << "*"; | 887 | text << "*"; |
902 | map.insert(tr("All"), text ); | 888 | map.insert(tr("All"), text ); |
903 | 889 | ||
904 | QFileInfo cuFi( currentFileName); | 890 | QFileInfo cuFi( currentFileName); |
905 | QString filee = cuFi.fileName(); | 891 | QString filee = cuFi.fileName(); |
906 | QString dire = cuFi.dirPath(); | 892 | QString dire = cuFi.dirPath(); |
907 | if(dire==".") | 893 | if(dire==".") |
908 | dire = QPEApplication::documentDir(); | 894 | dire = QPEApplication::documentDir(); |
895 | |||
909 | QString str; | 896 | QString str; |
910 | if( !featureAutoSave) { | 897 | if( !featureAutoSave) { |
911 | str = OFileDialog::getSaveFileName( 2, | 898 | str = OFileDialog::getSaveFileName( 2, dire, filee, map); |
912 | dire, | 899 | } else |
913 | filee, map); | ||
914 | } else | ||
915 | str = currentFileName; | 900 | str = currentFileName; |
916 | 901 | ||
917 | if(!str.isEmpty()) { | 902 | if(!str.isEmpty()) { |
918 | QString fileNm=str; | 903 | QString fileNm=str; |
919 | 904 | ||
920 | odebug << "saving filename "+fileNm << oendl; | 905 | odebug << "saving filename "+fileNm << oendl; |
921 | QFileInfo fi(fileNm); | 906 | QFileInfo fi(fileNm); |
922 | currentFileName=fi.fileName(); | 907 | currentFileName=fi.fileName(); |
923 | if(doc) | 908 | if(doc) |
924 | // QString file = doc->file(); | ||
925 | // doc->removeFiles(); | ||
926 | delete doc; | 909 | delete doc; |
927 | DocLnk nf; | 910 | |
928 | nf.setType("text/plain"); | 911 | DocLnk nf; |
929 | nf.setFile( fileNm); | 912 | nf.setType("text/plain"); |
930 | doc = new DocLnk(nf); | 913 | nf.setFile( fileNm); |
931 | // editor->setText(rt); | 914 | doc = new DocLnk(nf); |
932 | odebug << "Saving file as "+currentFileName << oendl; | 915 | odebug << "Saving file as "+currentFileName << oendl; |
933 | doc->setName( fi.baseName() /*currentFileName*/); | 916 | doc->setName( fi.baseName() ); |
934 | updateCaption( currentFileName); | 917 | updateCaption( currentFileName); |
935 | 918 | ||
936 | FileManager fm; | 919 | FileManager fm; |
937 | if ( !fm.saveFile( *doc, rt ) ) { | 920 | if ( !fm.saveFile( *doc, rt ) ) { |
938 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 921 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
939 | return false; | 922 | return false; |
940 | } | 923 | } |
941 | 924 | ||
942 | if( filePerms ) { | 925 | if( filePerms ) { |
943 | filePermissions *filePerm; | 926 | filePermissions *filePerm; |
944 | filePerm = new filePermissions(this, | 927 | filePerm = new filePermissions(this, tr("Permissions"),true, 0, |
945 | tr("Permissions"),true, | 928 | (const QString &)fileNm); |
946 | 0,(const QString &)fileNm); | 929 | QPEApplication::execDialog( filePerm ); |
947 | QPEApplication::execDialog( filePerm ); | 930 | |
948 | 931 | delete filePerm; | |
949 | if( filePerm) | 932 | } |
950 | delete filePerm; | ||
951 | } | ||
952 | // } | ||
953 | editor->setEdited( false); | 933 | editor->setEdited( false); |
954 | edited1 = false; | 934 | edited1 = false; |
955 | edited = false; | 935 | edited = false; |
956 | if(caption().left(1)=="*") | 936 | if(caption().left(1)=="*") |
957 | setCaption(caption().right(caption().length()-1)); | 937 | setCaption(caption().right(caption().length()-1)); |
958 | 938 | ||
959 | return true; | 939 | return true; |
960 | } | 940 | } |
961 | odebug << "returning false" << oendl; | 941 | odebug << "returning false" << oendl; |
962 | currentFileName = ""; | 942 | currentFileName = ""; |
963 | return false; | 943 | return false; |
964 | } //end saveAs | 944 | } //end saveAs |
965 | 945 | ||
966 | void TextEdit::clear() { | 946 | void TextEdit::clear() { |
967 | delete doc; | 947 | delete doc; |
968 | doc = 0; | 948 | doc = 0; |
969 | editor->clear(); | 949 | editor->clear(); |
970 | } | 950 | } |
971 | 951 | ||
972 | void TextEdit::updateCaption( const QString &name ) { | 952 | void TextEdit::updateCaption( const QString &name ) { |
973 | 953 | ||
974 | if ( name.isEmpty() ) | 954 | if ( name.isEmpty() ) |
975 | setCaption( tr("Text Editor") ); | 955 | setCaption( tr("Text Editor") ); |
976 | else { | 956 | else { |
977 | QString s = name; | 957 | QString s = name; |
978 | if ( s.isNull() ) | 958 | if ( s.isNull() ) |
979 | s = doc->name(); | 959 | s = doc->name(); |
980 | if ( s.isEmpty() ) { | 960 | if ( s.isEmpty() ) { |
981 | s = tr( "Unnamed" ); | 961 | s = tr( "Unnamed" ); |
982 | currentFileName=s; | 962 | currentFileName=s; |
983 | } | 963 | } |
984 | // if(s.left(1) == "/") | 964 | // if(s.left(1) == "/") |
985 | // s = s.right(s.length()-1); | 965 | // s = s.right(s.length()-1); |
986 | setCaption( tr("%1 - Text Editor").arg( s ) ); | 966 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
987 | } | 967 | } |
988 | } | 968 | } |
989 | 969 | ||
990 | void TextEdit::setDocument(const QString& fileref) { | 970 | void TextEdit::setDocument(const QString& fileref) { |
991 | if(fileref != "Unnamed") { | 971 | if(fileref != "Unnamed") { |
992 | currentFileName=fileref; | 972 | currentFileName=fileref; |
993 | odebug << "setDocument" << oendl; | 973 | odebug << "setDocument" << oendl; |
994 | QFileInfo fi(currentFileName); | 974 | QFileInfo fi(currentFileName); |
995 | odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl; | 975 | odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl; |
996 | if( (fi.baseName().left(1)).isEmpty() ) { | 976 | if( (fi.baseName().left(1)).isEmpty() ) { |
997 | openDotFile(currentFileName); | 977 | openDotFile(currentFileName); |
998 | 978 | ||
999 | } else { | 979 | } else { |
1000 | odebug << "setDoc open" << oendl; | 980 | odebug << "setDoc open" << oendl; |
@@ -1152,62 +1132,60 @@ void TextEdit::timerCrank() | |||
1152 | } | 1132 | } |
1153 | setTimer(); | 1133 | setTimer(); |
1154 | } | 1134 | } |
1155 | } | 1135 | } |
1156 | 1136 | ||
1157 | void TextEdit::doTimer(bool b) | 1137 | void TextEdit::doTimer(bool b) |
1158 | { | 1138 | { |
1159 | Config cfg("TextEdit"); | 1139 | Config cfg("TextEdit"); |
1160 | cfg.setGroup ( "View" ); | 1140 | cfg.setGroup ( "View" ); |
1161 | cfg.writeEntry ( "autosave", b); | 1141 | cfg.writeEntry ( "autosave", b); |
1162 | featureAutoSave = b; | 1142 | featureAutoSave = b; |
1163 | nAutoSave->setOn(b); | 1143 | nAutoSave->setOn(b); |
1164 | if(b) | 1144 | if(b) |
1165 | { | 1145 | { |
1166 | // odebug << "doTimer true" << oendl; | 1146 | // odebug << "doTimer true" << oendl; |
1167 | setTimer(); | 1147 | setTimer(); |
1168 | } | 1148 | } |
1169 | // else | 1149 | // else |
1170 | // odebug << "doTimer false" << oendl; | 1150 | // odebug << "doTimer false" << oendl; |
1171 | } | 1151 | } |
1172 | 1152 | ||
1173 | void TextEdit::setTimer() | 1153 | void TextEdit::setTimer() |
1174 | { | 1154 | { |
1175 | if(featureAutoSave) | 1155 | if(featureAutoSave) |
1176 | { | 1156 | { |
1177 | // odebug << "setting autosave" << oendl; | 1157 | // odebug << "setting autosave" << oendl; |
1178 | QTimer *timer = new QTimer(this ); | 1158 | QTimer *timer = new QTimer(this ); |
1179 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); | 1159 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); |
1180 | timer->start( 300000, true); //5 minutes | 1160 | timer->start( 300000, true); //5 minutes |
1181 | } | 1161 | } |
1182 | } | 1162 | } |
1183 | 1163 | ||
1184 | void TextEdit::gotoLine() { | 1164 | void TextEdit::gotoLine() { |
1185 | if( editor->length() < 1) | 1165 | if( editor->length() < 1) |
1186 | return; | 1166 | return; |
1187 | QWidget *d = QApplication::desktop(); | 1167 | QWidget *d = QApplication::desktop(); |
1188 | gotoEdit = new QLineEdit( 0, "Goto line"); | 1168 | gotoEdit = new QLineEdit( 0, "Goto line"); |
1189 | 1169 | ||
1190 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); | 1170 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); |
1191 | gotoEdit->setFrame(true); | 1171 | gotoEdit->setFrame(true); |
1192 | gotoEdit->show(); | 1172 | gotoEdit->show(); |
1193 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); | 1173 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); |
1194 | } | 1174 | } |
1195 | 1175 | ||
1196 | void TextEdit::doGoto() { | 1176 | void TextEdit::doGoto() { |
1197 | QString number = gotoEdit->text(); | 1177 | QString number = gotoEdit->text(); |
1198 | gotoEdit->hide(); | 1178 | gotoEdit->hide(); |
1199 | 1179 | ||
1200 | if(gotoEdit) { | 1180 | delete gotoEdit; |
1201 | delete gotoEdit; | 1181 | gotoEdit = 0; |
1202 | gotoEdit = 0; | ||
1203 | } | ||
1204 | 1182 | ||
1205 | bool ok; | 1183 | bool ok; |
1206 | int lineNumber = number.toInt(&ok, 10); | 1184 | int lineNumber = number.toInt(&ok, 10); |
1207 | if( editor->numLines() < lineNumber) | 1185 | if( editor->numLines() < lineNumber) |
1208 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); | 1186 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); |
1209 | else | 1187 | else |
1210 | { | 1188 | { |
1211 | editor->setCursorPosition(lineNumber, 0, false); | 1189 | editor->setCursorPosition(lineNumber, 0, false); |
1212 | } | 1190 | } |
1213 | } | 1191 | } |
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index 13f297e..61a47d7 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp | |||
@@ -190,97 +190,97 @@ void NotesControl::slotBeamButton() { | |||
190 | } else { | 190 | } else { |
191 | this->hide(); | 191 | this->hide(); |
192 | QString selectedText = box->currentText(); | 192 | QString selectedText = box->currentText(); |
193 | if( !selectedText.isEmpty()) { | 193 | if( !selectedText.isEmpty()) { |
194 | QString file = QDir::homeDirPath()+"/"+selectedText; | 194 | QString file = QDir::homeDirPath()+"/"+selectedText; |
195 | QFile f(file); | 195 | QFile f(file); |
196 | Ir *irFile = new Ir(this, "IR"); | 196 | Ir *irFile = new Ir(this, "IR"); |
197 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished(Ir*))); | 197 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished(Ir*))); |
198 | irFile->send( file, "Note", "text/plain" ); | 198 | irFile->send( file, "Note", "text/plain" ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | void NotesControl::slotBeamFinished(Ir *) { | 203 | void NotesControl::slotBeamFinished(Ir *) { |
204 | this->show(); | 204 | this->show(); |
205 | } | 205 | } |
206 | 206 | ||
207 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { | 207 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { |
208 | switch (mouse) { | 208 | switch (mouse) { |
209 | case 1:{ | 209 | case 1:{ |
210 | } | 210 | } |
211 | break; | 211 | break; |
212 | case 2: | 212 | case 2: |
213 | menuTimer.start( 500, TRUE ); | 213 | menuTimer.start( 500, TRUE ); |
214 | break; | 214 | break; |
215 | }; | 215 | }; |
216 | } | 216 | } |
217 | 217 | ||
218 | void NotesControl::slotBoxSelected(const QString &itemString) { | 218 | void NotesControl::slotBoxSelected(const QString &itemString) { |
219 | if(edited) { | 219 | if(edited) { |
220 | save(); | 220 | save(); |
221 | } | 221 | } |
222 | loaded=false; | 222 | loaded=false; |
223 | edited=false; | 223 | edited=false; |
224 | load(itemString); | 224 | load(itemString); |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | void NotesControl::showMenu() { | 228 | void NotesControl::showMenu() { |
229 | QPopupMenu *m = new QPopupMenu(0); | 229 | QPopupMenu *m = new QPopupMenu(0); |
230 | m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); | 230 | m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); |
231 | m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() )); | 231 | m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() )); |
232 | m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() )); | 232 | m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() )); |
233 | m->insertSeparator(); | 233 | m->insertSeparator(); |
234 | m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); | 234 | m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); |
235 | m->setFocus(); | 235 | m->setFocus(); |
236 | m->exec( QCursor::pos() ); | 236 | m->exec( QCursor::pos() ); |
237 | 237 | ||
238 | if(m) delete m; | 238 | delete m; |
239 | } | 239 | } |
240 | 240 | ||
241 | void NotesControl::focusOutEvent ( QFocusEvent * e) { | 241 | void NotesControl::focusOutEvent ( QFocusEvent * e) { |
242 | if( e->reason() == QFocusEvent::Popup) | 242 | if( e->reason() == QFocusEvent::Popup) |
243 | save(); | 243 | save(); |
244 | else { | 244 | else { |
245 | if(!loaded) { | 245 | if(!loaded) { |
246 | populateBox(); | 246 | populateBox(); |
247 | load(); | 247 | load(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | QWidget::focusOutEvent(e); | 250 | QWidget::focusOutEvent(e); |
251 | } | 251 | } |
252 | 252 | ||
253 | void NotesControl::save() { | 253 | void NotesControl::save() { |
254 | Config cfg("Notes"); | 254 | Config cfg("Notes"); |
255 | cfg.setGroup("Docs"); | 255 | cfg.setGroup("Docs"); |
256 | if( edited) { | 256 | if( edited) { |
257 | // odebug << "is edited" << oendl; | 257 | // odebug << "is edited" << oendl; |
258 | QString rt = view->text(); | 258 | QString rt = view->text(); |
259 | if( rt.length()>1) { | 259 | if( rt.length()>1) { |
260 | QString pt = rt.simplifyWhiteSpace(); | 260 | QString pt = rt.simplifyWhiteSpace(); |
261 | int i = pt.find( ' ', pt.find( ' ' )+2 ); | 261 | int i = pt.find( ' ', pt.find( ' ' )+2 ); |
262 | QString docname = pt; | 262 | QString docname = pt; |
263 | if ( i > 0 ) | 263 | if ( i > 0 ) |
264 | docname = pt.left(i); | 264 | docname = pt.left(i); |
265 | // remove "." at the beginning | 265 | // remove "." at the beginning |
266 | while( docname.startsWith( "." ) ) | 266 | while( docname.startsWith( "." ) ) |
267 | docname = docname.mid( 1 ); | 267 | docname = docname.mid( 1 ); |
268 | docname.replace( QRegExp("/"), "_" ); | 268 | docname.replace( QRegExp("/"), "_" ); |
269 | // cut the length. filenames longer than that don't make sense | 269 | // cut the length. filenames longer than that don't make sense |
270 | // and something goes wrong when they get too long. | 270 | // and something goes wrong when they get too long. |
271 | if ( docname.length() > 40 ) | 271 | if ( docname.length() > 40 ) |
272 | docname = docname.left(40); | 272 | docname = docname.left(40); |
273 | if ( docname.isEmpty() ) | 273 | if ( docname.isEmpty() ) |
274 | docname = "Empty Text"; | 274 | docname = "Empty Text"; |
275 | // odebug << docname << oendl; | 275 | // odebug << docname << oendl; |
276 | 276 | ||
277 | if( oldDocName != docname) { | 277 | if( oldDocName != docname) { |
278 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 278 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
279 | QString entryName; | 279 | QString entryName; |
280 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 280 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
281 | cfg.writeEntry( entryName,docname ); | 281 | cfg.writeEntry( entryName,docname ); |
282 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); | 282 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); |
283 | cfg.write(); | 283 | cfg.write(); |
284 | } | 284 | } |
285 | // else | 285 | // else |
286 | // odebug << "oldname equals docname" << oendl; | 286 | // odebug << "oldname equals docname" << oendl; |
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 828f5a1..cf19ba8 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -451,97 +451,97 @@ void AdvancedFm::showFileMenu() { | |||
451 | } else { | 451 | } else { |
452 | 452 | ||
453 | if (app) | 453 | if (app) |
454 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 454 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
455 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 455 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
456 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 456 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
457 | m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ), | 457 | m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ), |
458 | tr("Open as text"),this,SLOT(runText())); | 458 | tr("Open as text"),this,SLOT(runText())); |
459 | } | 459 | } |
460 | 460 | ||
461 | m->insertItem(tr("Actions"),n); | 461 | m->insertItem(tr("Actions"),n); |
462 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); | 462 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); |
463 | 463 | ||
464 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); | 464 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); |
465 | 465 | ||
466 | n->insertSeparator(); | 466 | n->insertSeparator(); |
467 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); | 467 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); |
468 | 468 | ||
469 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); | 469 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); |
470 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); | 470 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); |
471 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); | 471 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); |
472 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); | 472 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); |
473 | 473 | ||
474 | n->insertSeparator(); | 474 | n->insertSeparator(); |
475 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); | 475 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); |
476 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); | 476 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); |
477 | 477 | ||
478 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); | 478 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); |
479 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); | 479 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); |
480 | 480 | ||
481 | m->insertSeparator(); | 481 | m->insertSeparator(); |
482 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); | 482 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); |
483 | 483 | ||
484 | #if defined(QT_QWS_OPIE) | 484 | #if defined(QT_QWS_OPIE) |
485 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); | 485 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); |
486 | #endif | 486 | #endif |
487 | m->setCheckable(TRUE); | 487 | m->setCheckable(TRUE); |
488 | if (!b) | 488 | if (!b) |
489 | m->setItemChecked(m->idAt(0),TRUE); | 489 | m->setItemChecked(m->idAt(0),TRUE); |
490 | else | 490 | else |
491 | m->setItemChecked(m->idAt(0),FALSE); | 491 | m->setItemChecked(m->idAt(0),FALSE); |
492 | 492 | ||
493 | if(Ir::supported()) | 493 | if(Ir::supported()) |
494 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); | 494 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); |
495 | m->setFocus(); | 495 | m->setFocus(); |
496 | 496 | ||
497 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); | 497 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); |
498 | 498 | ||
499 | if(m) delete m; | 499 | delete m; |
500 | } | 500 | } |
501 | 501 | ||
502 | 502 | ||
503 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 503 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
504 | struct statfs fss; | 504 | struct statfs fss; |
505 | if ( !statfs( path.latin1(), &fss ) ) { | 505 | if ( !statfs( path.latin1(), &fss ) ) { |
506 | int blkSize = fss.f_bsize; | 506 | int blkSize = fss.f_bsize; |
507 | // int totalBlks = fs.f_blocks; | 507 | // int totalBlks = fs.f_blocks; |
508 | int availBlks = fss.f_bavail; | 508 | int availBlks = fss.f_bavail; |
509 | 509 | ||
510 | long mult = blkSize / 1024; | 510 | long mult = blkSize / 1024; |
511 | long div = 1024 / blkSize; | 511 | long div = 1024 / blkSize; |
512 | if ( !mult ) mult = 1; | 512 | if ( !mult ) mult = 1; |
513 | if ( !div ) div = 1; | 513 | if ( !div ) div = 1; |
514 | 514 | ||
515 | 515 | ||
516 | return QString::number(availBlks * mult / div); | 516 | return QString::number(availBlks * mult / div); |
517 | } | 517 | } |
518 | return ""; | 518 | return ""; |
519 | } | 519 | } |
520 | 520 | ||
521 | void AdvancedFm::addToDocs() { | 521 | void AdvancedFm::addToDocs() { |
522 | QStringList strListPaths = getPath(); | 522 | QStringList strListPaths = getPath(); |
523 | QDir *thisDir = CurrentDir(); | 523 | QDir *thisDir = CurrentDir(); |
524 | 524 | ||
525 | if( strListPaths.count() > 0) { | 525 | if( strListPaths.count() > 0) { |
526 | QString curFile; | 526 | QString curFile; |
527 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 527 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
528 | curFile = thisDir->canonicalPath()+"/"+(*it); | 528 | curFile = thisDir->canonicalPath()+"/"+(*it); |
529 | // odebug << curFile << oendl; | 529 | // odebug << curFile << oendl; |
530 | QFileInfo fi(curFile); | 530 | QFileInfo fi(curFile); |
531 | DocLnk f; | 531 | DocLnk f; |
532 | // curFile.replace(QRegExp("\\..*"),""); | 532 | // curFile.replace(QRegExp("\\..*"),""); |
533 | f.setName(fi.baseName() ); | 533 | f.setName(fi.baseName() ); |
534 | f.setFile( curFile); | 534 | f.setFile( curFile); |
535 | f.writeLink(); | 535 | f.writeLink(); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | 540 | ||
541 | void AdvancedFm::customDirsToMenu() { | 541 | void AdvancedFm::customDirsToMenu() { |
542 | 542 | ||
543 | Config cfg("AdvancedFm"); | 543 | Config cfg("AdvancedFm"); |
544 | cfg.setGroup("Menu"); | 544 | cfg.setGroup("Menu"); |
545 | 545 | ||
546 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 546 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
547 | menuButton->insertItems(list ); | 547 | menuButton->insertItems(list ); |