author | ar <ar> | 2004-02-07 23:52:31 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-07 23:52:31 (UTC) |
commit | 6582895befc98131430710191238a93b9dde161c (patch) (unidiff) | |
tree | d050483742d0e102e08138bcdd8f170a9558b12d /core/apps/textedit | |
parent | 3f261fa6eac46b8d0d4ac8b8bb95b385435004da (diff) | |
download | opie-6582895befc98131430710191238a93b9dde161c.zip opie-6582895befc98131430710191238a93b9dde161c.tar.gz opie-6582895befc98131430710191238a93b9dde161c.tar.bz2 |
QPEApplication::showDialog() and QPEAPplication::execDialog() for better big screen handling
-rw-r--r-- | core/apps/textedit/textedit.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index be18140..1299fe3 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -897,172 +897,170 @@ bool TextEdit::saveAs() { | |||
897 | text << "text/*"; | 897 | text << "text/*"; |
898 | map.insert(tr("Text"), text ); | 898 | map.insert(tr("Text"), text ); |
899 | text << "*"; | 899 | text << "*"; |
900 | map.insert(tr("All"), text ); | 900 | map.insert(tr("All"), text ); |
901 | 901 | ||
902 | QFileInfo cuFi( currentFileName); | 902 | QFileInfo cuFi( currentFileName); |
903 | QString filee = cuFi.fileName(); | 903 | QString filee = cuFi.fileName(); |
904 | QString dire = cuFi.dirPath(); | 904 | QString dire = cuFi.dirPath(); |
905 | if(dire==".") | 905 | if(dire==".") |
906 | dire = QPEApplication::documentDir(); | 906 | dire = QPEApplication::documentDir(); |
907 | QString str; | 907 | QString str; |
908 | if( !featureAutoSave) | 908 | if( !featureAutoSave) |
909 | { | 909 | { |
910 | str = OFileDialog::getSaveFileName( 2, | 910 | str = OFileDialog::getSaveFileName( 2, |
911 | dire, | 911 | dire, |
912 | filee, map); | 912 | filee, map); |
913 | } | 913 | } |
914 | else | 914 | else |
915 | str=currentFileName; | 915 | str=currentFileName; |
916 | if(!str.isEmpty()) { | 916 | if(!str.isEmpty()) { |
917 | QString fileNm=str; | 917 | QString fileNm=str; |
918 | 918 | ||
919 | qDebug("saving filename "+fileNm); | 919 | qDebug("saving filename "+fileNm); |
920 | QFileInfo fi(fileNm); | 920 | QFileInfo fi(fileNm); |
921 | currentFileName=fi.fileName(); | 921 | currentFileName=fi.fileName(); |
922 | if(doc) | 922 | if(doc) |
923 | // QString file = doc->file(); | 923 | // QString file = doc->file(); |
924 | // doc->removeFiles(); | 924 | // doc->removeFiles(); |
925 | delete doc; | 925 | delete doc; |
926 | DocLnk nf; | 926 | DocLnk nf; |
927 | nf.setType("text/plain"); | 927 | nf.setType("text/plain"); |
928 | nf.setFile( fileNm); | 928 | nf.setFile( fileNm); |
929 | doc = new DocLnk(nf); | 929 | doc = new DocLnk(nf); |
930 | // editor->setText(rt); | 930 | // editor->setText(rt); |
931 | qDebug("Saving file as "+currentFileName); | 931 | qDebug("Saving file as "+currentFileName); |
932 | doc->setName( currentFileName); | 932 | doc->setName( currentFileName); |
933 | updateCaption( currentFileName); | 933 | updateCaption( currentFileName); |
934 | 934 | ||
935 | FileManager fm; | 935 | FileManager fm; |
936 | if ( !fm.saveFile( *doc, rt ) ) { | 936 | if ( !fm.saveFile( *doc, rt ) ) { |
937 | return false; | 937 | return false; |
938 | } | 938 | } |
939 | 939 | ||
940 | if( filePerms ) { | 940 | if( filePerms ) { |
941 | filePermissions *filePerm; | 941 | filePermissions *filePerm; |
942 | filePerm = new filePermissions(this, | 942 | filePerm = new filePermissions(this, |
943 | tr("Permissions"),true, | 943 | tr("Permissions"),true, |
944 | 0,(const QString &)fileNm); | 944 | 0,(const QString &)fileNm); |
945 | filePerm->showMaximized(); | 945 | QPEApplication::execDialog( filePerm ); |
946 | filePerm->exec(); | ||
947 | 946 | ||
948 | if( filePerm) | 947 | if( filePerm) |
949 | delete filePerm; | 948 | delete filePerm; |
950 | } | 949 | } |
951 | // } | 950 | // } |
952 | editor->setEdited( false); | 951 | editor->setEdited( false); |
953 | edited1 = false; | 952 | edited1 = false; |
954 | edited = false; | 953 | edited = false; |
955 | if(caption().left(1)=="*") | 954 | if(caption().left(1)=="*") |
956 | setCaption(caption().right(caption().length()-1)); | 955 | setCaption(caption().right(caption().length()-1)); |
957 | 956 | ||
958 | return true; | 957 | return true; |
959 | } | 958 | } |
960 | qDebug("returning false"); | 959 | qDebug("returning false"); |
961 | return false; | 960 | return false; |
962 | } //end saveAs | 961 | } //end saveAs |
963 | 962 | ||
964 | void TextEdit::clear() { | 963 | void TextEdit::clear() { |
965 | delete doc; | 964 | delete doc; |
966 | doc = 0; | 965 | doc = 0; |
967 | editor->clear(); | 966 | editor->clear(); |
968 | } | 967 | } |
969 | 968 | ||
970 | void TextEdit::updateCaption( const QString &name ) { | 969 | void TextEdit::updateCaption( const QString &name ) { |
971 | 970 | ||
972 | if ( name.isEmpty() ) | 971 | if ( name.isEmpty() ) |
973 | setCaption( tr("Text Editor") ); | 972 | setCaption( tr("Text Editor") ); |
974 | else { | 973 | else { |
975 | QString s = name; | 974 | QString s = name; |
976 | if ( s.isNull() ) | 975 | if ( s.isNull() ) |
977 | s = doc->name(); | 976 | s = doc->name(); |
978 | if ( s.isEmpty() ) { | 977 | if ( s.isEmpty() ) { |
979 | s = tr( "Unnamed" ); | 978 | s = tr( "Unnamed" ); |
980 | currentFileName=s; | 979 | currentFileName=s; |
981 | } | 980 | } |
982 | // if(s.left(1) == "/") | 981 | // if(s.left(1) == "/") |
983 | // s = s.right(s.length()-1); | 982 | // s = s.right(s.length()-1); |
984 | setCaption( tr("%1 - Text Editor").arg( s ) ); | 983 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
985 | } | 984 | } |
986 | } | 985 | } |
987 | 986 | ||
988 | void TextEdit::setDocument(const QString& fileref) { | 987 | void TextEdit::setDocument(const QString& fileref) { |
989 | if(fileref != "Unnamed") { | 988 | if(fileref != "Unnamed") { |
990 | currentFileName=fileref; | 989 | currentFileName=fileref; |
991 | qDebug("setDocument"); | 990 | qDebug("setDocument"); |
992 | QFileInfo fi(currentFileName); | 991 | QFileInfo fi(currentFileName); |
993 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); | 992 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); |
994 | if( (fi.baseName().left(1)).isEmpty() ) { | 993 | if( (fi.baseName().left(1)).isEmpty() ) { |
995 | openDotFile(currentFileName); | 994 | openDotFile(currentFileName); |
996 | 995 | ||
997 | } else { | 996 | } else { |
998 | qDebug("setDoc open"); | 997 | qDebug("setDoc open"); |
999 | bFromDocView = true; | 998 | bFromDocView = true; |
1000 | openFile(fileref); | 999 | openFile(fileref); |
1001 | editor->setEdited(true); | 1000 | editor->setEdited(true); |
1002 | edited1=false; | 1001 | edited1=false; |
1003 | edited=true; | 1002 | edited=true; |
1004 | // fromSetDocument=false; | 1003 | // fromSetDocument=false; |
1005 | // doSearchBar(); | 1004 | // doSearchBar(); |
1006 | } | 1005 | } |
1007 | } | 1006 | } |
1008 | updateCaption( currentFileName); | 1007 | updateCaption( currentFileName); |
1009 | } | 1008 | } |
1010 | 1009 | ||
1011 | void TextEdit::changeFont() { | 1010 | void TextEdit::changeFont() { |
1012 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 1011 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
1013 | d-> setCaption ( tr( "Choose font" )); | 1012 | d-> setCaption ( tr( "Choose font" )); |
1014 | QBoxLayout *lay = new QVBoxLayout ( d ); | 1013 | QBoxLayout *lay = new QVBoxLayout ( d ); |
1015 | OFontSelector *ofs = new OFontSelector ( true, d ); | 1014 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1016 | lay-> addWidget ( ofs ); | 1015 | lay-> addWidget ( ofs ); |
1017 | ofs-> setSelectedFont ( editor-> font ( )); | 1016 | ofs-> setSelectedFont ( editor-> font ( )); |
1018 | 1017 | ||
1019 | d-> showMaximized ( ); | 1018 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) |
1020 | if ( d-> exec ( ) == QDialog::Accepted ) | ||
1021 | editor-> setFont ( ofs-> selectedFont ( )); | 1019 | editor-> setFont ( ofs-> selectedFont ( )); |
1022 | delete d; | 1020 | delete d; |
1023 | 1021 | ||
1024 | } | 1022 | } |
1025 | 1023 | ||
1026 | void TextEdit::editDelete() { | 1024 | void TextEdit::editDelete() { |
1027 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1025 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1028 | tr("Do you really want<BR>to <B>delete</B> " | 1026 | tr("Do you really want<BR>to <B>delete</B> " |
1029 | "the current file\nfrom the disk?<BR>This is " | 1027 | "the current file\nfrom the disk?<BR>This is " |
1030 | "<B>irreversable!</B>"), | 1028 | "<B>irreversable!</B>"), |
1031 | tr("Yes"),tr("No"),0,0,1) ) { | 1029 | tr("Yes"),tr("No"),0,0,1) ) { |
1032 | case 0: | 1030 | case 0: |
1033 | if(doc) { | 1031 | if(doc) { |
1034 | doc->removeFiles(); | 1032 | doc->removeFiles(); |
1035 | clear(); | 1033 | clear(); |
1036 | setCaption( tr("Text Editor") ); | 1034 | setCaption( tr("Text Editor") ); |
1037 | } | 1035 | } |
1038 | break; | 1036 | break; |
1039 | case 1: | 1037 | case 1: |
1040 | // exit | 1038 | // exit |
1041 | break; | 1039 | break; |
1042 | }; | 1040 | }; |
1043 | } | 1041 | } |
1044 | 1042 | ||
1045 | void TextEdit::changeStartConfig( bool b ) { | 1043 | void TextEdit::changeStartConfig( bool b ) { |
1046 | startWithNew=b; | 1044 | startWithNew=b; |
1047 | Config cfg("TextEdit"); | 1045 | Config cfg("TextEdit"); |
1048 | cfg.setGroup("View"); | 1046 | cfg.setGroup("View"); |
1049 | cfg.writeEntry("startNew",b); | 1047 | cfg.writeEntry("startNew",b); |
1050 | update(); | 1048 | update(); |
1051 | } | 1049 | } |
1052 | 1050 | ||
1053 | void TextEdit::editorChanged() { | 1051 | void TextEdit::editorChanged() { |
1054 | // qDebug("editor changed"); | 1052 | // qDebug("editor changed"); |
1055 | if( /*editor->edited() &&*/ /*edited && */!edited1) { | 1053 | if( /*editor->edited() &&*/ /*edited && */!edited1) { |
1056 | setCaption( "*"+caption()); | 1054 | setCaption( "*"+caption()); |
1057 | edited1=true; | 1055 | edited1=true; |
1058 | } | 1056 | } |
1059 | edited=true; | 1057 | edited=true; |
1060 | } | 1058 | } |
1061 | 1059 | ||
1062 | void TextEdit::receive(const QCString&msg, const QByteArray &) { | 1060 | void TextEdit::receive(const QCString&msg, const QByteArray &) { |
1063 | qDebug("QCop "+msg); | 1061 | qDebug("QCop "+msg); |
1064 | if ( msg == "setDocument(QString)" ) { | 1062 | if ( msg == "setDocument(QString)" ) { |
1065 | qDebug("bugger all"); | 1063 | qDebug("bugger all"); |
1066 | 1064 | ||
1067 | } | 1065 | } |
1068 | 1066 | ||