author | pohly <pohly> | 2005-05-08 16:13:24 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-08 16:13:24 (UTC) |
commit | ea889d21f3b5bf846ff20a6fad9a756108a28ad7 (patch) (unidiff) | |
tree | 3d0462ccf147fb95886657d8bb610caa168e01ea | |
parent | 2ccb0ad8b77eb3c62914f5df5b1bba3becb83617 (diff) | |
download | opie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.zip opie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.tar.gz opie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.tar.bz2 |
code change by tim: ask the user to confirm the remapping of the ESC key
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 6753698..8ef0674 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -3065,193 +3065,198 @@ void QTReaderApp::showEditTools() | |||
3065 | #endif | 3065 | #endif |
3066 | regBar->show(); | 3066 | regBar->show(); |
3067 | } | 3067 | } |
3068 | if (m_fontVisible) m_fontBar->show(); | 3068 | if (m_fontVisible) m_fontBar->show(); |
3069 | //qDebug("sn"); | 3069 | //qDebug("sn"); |
3070 | showNormal(); | 3070 | showNormal(); |
3071 | //qDebug("sm"); | 3071 | //qDebug("sm"); |
3072 | #if defined(USEQPE) && !defined(SIMPAD) | 3072 | #if defined(USEQPE) && !defined(SIMPAD) |
3073 | showMaximized(); | 3073 | showMaximized(); |
3074 | #endif | 3074 | #endif |
3075 | //setCentralWidget(reader); | 3075 | //setCentralWidget(reader); |
3076 | } | 3076 | } |
3077 | 3077 | ||
3078 | // qDebug("uc"); | 3078 | // qDebug("uc"); |
3079 | updateCaption(); | 3079 | updateCaption(); |
3080 | // qDebug("rw"); | 3080 | // qDebug("rw"); |
3081 | editorStack->raiseWidget( reader ); | 3081 | editorStack->raiseWidget( reader ); |
3082 | // qDebug("sf"); | 3082 | // qDebug("sf"); |
3083 | reader->setFocus(); | 3083 | reader->setFocus(); |
3084 | // qDebug("ref"); | 3084 | // qDebug("ref"); |
3085 | //reader->refresh(true); | 3085 | //reader->refresh(true); |
3086 | // qDebug("done"); | 3086 | // qDebug("done"); |
3087 | } | 3087 | } |
3088 | /* | 3088 | /* |
3089 | void QTReaderApp::save() | 3089 | void QTReaderApp::save() |
3090 | { | 3090 | { |
3091 | if ( !doc ) | 3091 | if ( !doc ) |
3092 | return; | 3092 | return; |
3093 | if ( !editor->edited() ) | 3093 | if ( !editor->edited() ) |
3094 | return; | 3094 | return; |
3095 | 3095 | ||
3096 | QString rt = editor->text(); | 3096 | QString rt = editor->text(); |
3097 | QString pt = rt; | 3097 | QString pt = rt; |
3098 | 3098 | ||
3099 | if ( doc->name().isEmpty() ) { | 3099 | if ( doc->name().isEmpty() ) { |
3100 | unsigned ispace = pt.find( ' ' ); | 3100 | unsigned ispace = pt.find( ' ' ); |
3101 | unsigned ienter = pt.find( '\n' ); | 3101 | unsigned ienter = pt.find( '\n' ); |
3102 | int i = (ispace < ienter) ? ispace : ienter; | 3102 | int i = (ispace < ienter) ? ispace : ienter; |
3103 | QString docname; | 3103 | QString docname; |
3104 | if ( i == -1 ) { | 3104 | if ( i == -1 ) { |
3105 | if ( pt.isEmpty() ) | 3105 | if ( pt.isEmpty() ) |
3106 | docname = "Empty Text"; | 3106 | docname = "Empty Text"; |
3107 | else | 3107 | else |
3108 | docname = pt; | 3108 | docname = pt; |
3109 | } else { | 3109 | } else { |
3110 | docname = pt.left( i ); | 3110 | docname = pt.left( i ); |
3111 | } | 3111 | } |
3112 | doc->setName(docname); | 3112 | doc->setName(docname); |
3113 | } | 3113 | } |
3114 | FileManager fm; | 3114 | FileManager fm; |
3115 | fm.saveFile( *doc, rt ); | 3115 | fm.saveFile( *doc, rt ); |
3116 | } | 3116 | } |
3117 | */ | 3117 | */ |
3118 | 3118 | ||
3119 | void QTReaderApp::clear() | 3119 | void QTReaderApp::clear() |
3120 | { | 3120 | { |
3121 | // if (doc != 0) | 3121 | // if (doc != 0) |
3122 | // { | 3122 | // { |
3123 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); | 3123 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
3124 | //delete doc; | 3124 | //delete doc; |
3125 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); | 3125 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
3126 | //doc = 0; | 3126 | //doc = 0; |
3127 | // } | 3127 | // } |
3128 | reader->clear(); | 3128 | reader->clear(); |
3129 | } | 3129 | } |
3130 | 3130 | ||
3131 | void QTReaderApp::updateCaption() | 3131 | void QTReaderApp::updateCaption() |
3132 | { | 3132 | { |
3133 | // if ( !doc ) | 3133 | // if ( !doc ) |
3134 | //setCaption( tr("QTReader") ); | 3134 | //setCaption( tr("QTReader") ); |
3135 | // else { | 3135 | // else { |
3136 | //QString s = doc->name(); | 3136 | //QString s = doc->name(); |
3137 | //if ( s.isEmpty() ) | 3137 | //if ( s.isEmpty() ) |
3138 | // s = tr( "Unnamed" ); | 3138 | // s = tr( "Unnamed" ); |
3139 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); | 3139 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); |
3140 | // } | 3140 | // } |
3141 | } | 3141 | } |
3142 | 3142 | ||
3143 | void QTReaderApp::setDocument(const QString& fileref) | 3143 | void QTReaderApp::setDocument(const QString& fileref) |
3144 | { | 3144 | { |
3145 | //QMessageBox::information(0, "setDocument", fileref); | 3145 | //QMessageBox::information(0, "setDocument", fileref); |
3146 | openFile(fileref); | 3146 | openFile(fileref); |
3147 | // showEditTools(); | 3147 | // showEditTools(); |
3148 | } | 3148 | } |
3149 | 3149 | ||
3150 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 3150 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
3151 | { | 3151 | { |
3152 | // qDebug("Close event"); | 3152 | // qDebug("Close event"); |
3153 | if (m_fullscreen) | 3153 | if (m_fullscreen) |
3154 | { | 3154 | { |
3155 | m_fullscreen = false; | 3155 | m_fullscreen = false; |
3156 | showEditTools(); | 3156 | showEditTools(); |
3157 | e->ignore(); | 3157 | e->ignore(); |
3158 | } | 3158 | } |
3159 | else if (editorStack->visibleWidget() == m_buttonprefs) | 3159 | else if (editorStack->visibleWidget() == m_buttonprefs) |
3160 | { | 3160 | { |
3161 | m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); | 3161 | int ret = QMessageBox::warning(this, PROGNAME, |
3162 | tr("Do you wish to map this key?\n\nIf you proceed you will map\nthe escape key and you will\nneed to press the close box\ntwice to exit this program\n\nContinue?"), tr("Yes"), tr("No"), QString::null, 0, 1); | ||
3163 | if (ret == 0) | ||
3164 | { | ||
3165 | m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); | ||
3166 | } | ||
3162 | e->ignore(); | 3167 | e->ignore(); |
3163 | } | 3168 | } |
3164 | else if (m_dontSave) | 3169 | else if (m_dontSave) |
3165 | { | 3170 | { |
3166 | e->accept(); | 3171 | e->accept(); |
3167 | } | 3172 | } |
3168 | else | 3173 | else |
3169 | { | 3174 | { |
3170 | if (editorStack->visibleWidget() == reader) | 3175 | if (editorStack->visibleWidget() == reader) |
3171 | { | 3176 | { |
3172 | if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) | 3177 | if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) |
3173 | { | 3178 | { |
3174 | //qDebug("Close disabled"); | 3179 | //qDebug("Close disabled"); |
3175 | m_bcloseDisabled = false; | 3180 | m_bcloseDisabled = false; |
3176 | e->ignore(); | 3181 | e->ignore(); |
3177 | } | 3182 | } |
3178 | else | 3183 | else |
3179 | { | 3184 | { |
3180 | if (m_fontVisible) | 3185 | if (m_fontVisible) |
3181 | { | 3186 | { |
3182 | m_fontBar->hide(); | 3187 | m_fontBar->hide(); |
3183 | m_fontVisible = false; | 3188 | m_fontVisible = false; |
3184 | e->ignore(); | 3189 | e->ignore(); |
3185 | return; | 3190 | return; |
3186 | } | 3191 | } |
3187 | if (regVisible) | 3192 | if (regVisible) |
3188 | { | 3193 | { |
3189 | regBar->hide(); | 3194 | regBar->hide(); |
3190 | #ifdef USEQPE | 3195 | #ifdef USEQPE |
3191 | Global::hideInputMethod(); | 3196 | Global::hideInputMethod(); |
3192 | #endif | 3197 | #endif |
3193 | regVisible = false; | 3198 | regVisible = false; |
3194 | e->ignore(); | 3199 | e->ignore(); |
3195 | return; | 3200 | return; |
3196 | } | 3201 | } |
3197 | if (searchVisible) | 3202 | if (searchVisible) |
3198 | { | 3203 | { |
3199 | searchBar->hide(); | 3204 | searchBar->hide(); |
3200 | #ifdef USEQPE | 3205 | #ifdef USEQPE |
3201 | Global::hideInputMethod(); | 3206 | Global::hideInputMethod(); |
3202 | #endif | 3207 | #endif |
3203 | searchVisible = false; | 3208 | searchVisible = false; |
3204 | e->ignore(); | 3209 | e->ignore(); |
3205 | return; | 3210 | return; |
3206 | } | 3211 | } |
3207 | if (m_fBkmksChanged && pBkmklist != NULL) | 3212 | if (m_fBkmksChanged && pBkmklist != NULL) |
3208 | { | 3213 | { |
3209 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 3214 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
3210 | savebkmks(); | 3215 | savebkmks(); |
3211 | delete pBkmklist; | 3216 | delete pBkmklist; |
3212 | reader->pBkmklist = pBkmklist = NULL; | 3217 | reader->pBkmklist = pBkmklist = NULL; |
3213 | m_fBkmksChanged = false; | 3218 | m_fBkmksChanged = false; |
3214 | } | 3219 | } |
3215 | updatefileinfo(); | 3220 | updatefileinfo(); |
3216 | saveprefs(); | 3221 | saveprefs(); |
3217 | e->accept(); | 3222 | e->accept(); |
3218 | } | 3223 | } |
3219 | } | 3224 | } |
3220 | else | 3225 | else |
3221 | { | 3226 | { |
3222 | showEditTools(); | 3227 | showEditTools(); |
3223 | m_disableesckey = true; | 3228 | m_disableesckey = true; |
3224 | } | 3229 | } |
3225 | } | 3230 | } |
3226 | } | 3231 | } |
3227 | 3232 | ||
3228 | void QTReaderApp::do_gotomark() | 3233 | void QTReaderApp::do_gotomark() |
3229 | { | 3234 | { |
3230 | m_nBkmkAction = cGotoBkmk; | 3235 | m_nBkmkAction = cGotoBkmk; |
3231 | if (!listbkmk(pBkmklist)) | 3236 | if (!listbkmk(pBkmklist)) |
3232 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 3237 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3233 | } | 3238 | } |
3234 | 3239 | ||
3235 | void QTReaderApp::do_delmark() | 3240 | void QTReaderApp::do_delmark() |
3236 | { | 3241 | { |
3237 | m_nBkmkAction = cDelBkmk; | 3242 | m_nBkmkAction = cDelBkmk; |
3238 | if (!listbkmk(pBkmklist)) | 3243 | if (!listbkmk(pBkmklist)) |
3239 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 3244 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3240 | } | 3245 | } |
3241 | 3246 | ||
3242 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel) | 3247 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel) |
3243 | { | 3248 | { |
3244 | bkmkselector->clear(); | 3249 | bkmkselector->clear(); |
3245 | if (_lab.isEmpty()) | 3250 | if (_lab.isEmpty()) |
3246 | bkmkselector->setText("Cancel"); | 3251 | bkmkselector->setText("Cancel"); |
3247 | else | 3252 | else |
3248 | bkmkselector->setText(_lab); | 3253 | bkmkselector->setText(_lab); |
3249 | int cnt = 0; | 3254 | int cnt = 0; |
3250 | int slt = -1; | 3255 | int slt = -1; |
3251 | if (plist != NULL) | 3256 | if (plist != NULL) |
3252 | { | 3257 | { |
3253 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) | 3258 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
3254 | { | 3259 | { |
3255 | if (presel) | 3260 | if (presel) |
3256 | { | 3261 | { |
3257 | Bkmk* p = i.pContent(); | 3262 | Bkmk* p = i.pContent(); |