Changeset 561 for trunk/tools/linguist/linguist/mainwindow.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/linguist/linguist/mainwindow.cpp
r511 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the Qt Linguist of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 51 51 #include "finddialog.h" 52 52 #include "formpreviewview.h" 53 #include "globals.h" 53 54 #include "messageeditor.h" 54 55 #include "messagemodel.h" … … 82 83 #include <QMessageBox> 83 84 #include <QPrintDialog> 85 #include <QPrinter> 84 86 #include <QProcess> 85 87 #include <QRegExp> … … 97 99 static const int MessageMS = 2500; 98 100 99 const QString &settingsPrefix()100 {101 static QString prefix = QString(QLatin1String("%1.%2/"))102 .arg((QT_VERSION >> 16) & 0xff)103 .arg((QT_VERSION >> 8) & 0xff);104 return prefix;105 }106 107 101 enum Ending { 108 102 End_None, … … 122 116 { 123 117 str = str.simplified(); 124 int ch = 0; 125 if (!str.isEmpty()) 126 ch = str.right(1)[0].unicode(); 127 128 switch (ch) { 118 if (str.isEmpty()) 119 return End_None; 120 121 switch (str.at(str.length() - 1).unicode()) { 129 122 case 0x002e: // full stop 130 if (str.endsWith(Q String(QLatin1String("..."))))123 if (str.endsWith(QLatin1String("..."))) 131 124 return End_Ellipsis; 132 125 else … … 266 259 : QMainWindow(0, Qt::Window), 267 260 m_assistantProcess(0), 261 m_printer(0), 268 262 m_findMatchCase(Qt::CaseInsensitive), 269 263 m_findIgnoreAccelerators(true), … … 276 270 m_statistics(0) 277 271 { 272 setUnifiedTitleAndToolBarOnMac(true); 278 273 m_ui.setupUi(this); 279 274 … … 311 306 m_contextView->header()->setMovable(false); 312 307 m_contextView->setColumnHidden(0, true); 313 m_contextView->header()->setResizeMode(1, QHeaderView::Stretch);314 m_contextView->header()->setResizeMode(2, QHeaderView::ResizeToContents);315 308 m_contextView->header()->setStretchLastSection(false); 316 309 … … 341 334 m_messageView->header()->setMovable(false); 342 335 m_messageView->setColumnHidden(0, true); 343 m_messageView->setColumnHidden(2, true);344 // last visible column auto-stretches345 336 346 337 m_messagesDock->setWidget(m_messageView); … … 449 440 450 441 modelCountChanged(); 442 initViewHeaders(); 451 443 resetSorting(); 452 444 … … 479 471 connect(m_findDialog, SIGNAL(findNext(QString,DataModel::FindLocation,bool,bool)), 480 472 this, SLOT(findNext(QString,DataModel::FindLocation,bool,bool))); 481 connect(m_translateDialog, SIGNAL(requestMatchUpdate(bool &)), SLOT(updateTranslateHit(bool&)));473 connect(m_translateDialog, SIGNAL(requestMatchUpdate(bool&)), SLOT(updateTranslateHit(bool&))); 482 474 connect(m_translateDialog, SIGNAL(activated(int)), SLOT(translate(int))); 483 475 … … 488 480 readConfig(); 489 481 m_statistics = 0; 482 483 connect(m_ui.actionLengthVariants, SIGNAL(toggled(bool)), 484 m_messageEditor, SLOT(setLengthVariants(bool))); 485 m_messageEditor->setLengthVariants(m_ui.actionLengthVariants->isChecked()); 490 486 491 487 m_focusWatcher = new FocusWatcher(m_messageEditor, this); … … 508 504 delete m_dataModel; 509 505 delete m_statistics; 506 delete m_printer; 507 } 508 509 void MainWindow::initViewHeaders() 510 { 511 m_contextView->header()->setResizeMode(1, QHeaderView::Stretch); 512 m_contextView->header()->setResizeMode(2, QHeaderView::ResizeToContents); 513 m_messageView->setColumnHidden(2, true); 514 // last visible column auto-stretches 510 515 } 511 516 … … 741 746 m_dataModel->closeAll(); 742 747 modelCountChanged(); 748 initViewHeaders(); 743 749 recentFiles().closeGroup(); 744 750 return true; … … 875 881 } 876 882 883 QPrinter *MainWindow::printer() 884 { 885 if (!m_printer) 886 m_printer = new QPrinter; 887 return m_printer; 888 } 889 877 890 void MainWindow::print() 878 891 { 879 892 #ifndef QT_NO_PRINTER 880 893 int pageNum = 0; 881 QPrintDialog dlg( &m_printer, this);894 QPrintDialog dlg(printer(), this); 882 895 if (dlg.exec()) { 883 896 QApplication::setOverrideCursor(Qt::WaitCursor); 884 m_printer.setDocName(m_dataModel->condensedSrcFileNames(true));897 printer()->setDocName(m_dataModel->condensedSrcFileNames(true)); 885 898 statusBar()->showMessage(tr("Printing...")); 886 PrintOut pout( &m_printer);899 PrintOut pout(printer()); 887 900 888 901 for (int i = 0; i < m_dataModel->contextCount(); ++i) { … … 1237 1250 int pageNum = 0; 1238 1251 1239 QPrintDialog dlg( &m_printer, this);1252 QPrintDialog dlg(printer(), this); 1240 1253 if (dlg.exec()) { 1241 m_printer.setDocName(phraseBook->fileName());1254 printer()->setDocName(phraseBook->fileName()); 1242 1255 statusBar()->showMessage(tr("Printing...")); 1243 PrintOut pout( &m_printer);1256 PrintOut pout(printer()); 1244 1257 pout.setRule(PrintOut::ThinRule); 1245 1258 foreach (const Phrase *p, phraseBook->phrases()) { … … 1347 1360 version = version.arg(QLatin1String(QT_VERSION_STR)); 1348 1361 1349 // TODO: Remove this variable for 4.6.0. Must keep this way for 4.5.x due to string freeze.1350 QString edition;1351 1352 1362 box.setText(tr("<center><img src=\":/images/splash.png\"/></img><p>%1</p></center>" 1353 1363 "<p>Qt Linguist is a tool for adding translations to Qt " 1354 1364 "applications.</p>" 1355 "<p>%2</p>"1356 1365 "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)." 1357 "</p><p>The program is provided AS IS with NO WARRANTY OF ANY KIND," 1358 " INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A" 1359 " PARTICULAR PURPOSE.</p>").arg(version).arg(edition)); 1366 ).arg(version)); 1360 1367 1361 1368 box.setWindowTitle(QApplication::translate("AboutDialog", "Qt Linguist")); … … 2352 2359 } 2353 2360 2361 static bool haveMnemonic(const QString &str) 2362 { 2363 QString mnemonic = QKeySequence::mnemonic(str); 2364 if (mnemonic == QLatin1String("Alt+Space")) { 2365 // "Nobody" ever really uses these, and they are highly annoying 2366 // because we get a lot of false positives. 2367 return false; 2368 } 2369 return !mnemonic.isEmpty(); 2370 } 2371 2354 2372 void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) 2355 2373 { … … 2375 2393 QStringList translations = m->translations(); 2376 2394 2395 // Truncated variants are permitted to be "denormalized" 2396 for (int i = 0; i < translations.count(); ++i) { 2397 int sep = translations.at(i).indexOf(QChar(Translator::BinaryVariantSeparator)); 2398 if (sep >= 0) 2399 translations[i].truncate(sep); 2400 } 2401 2377 2402 if (m_ui.actionAccelerators->isChecked()) { 2378 bool sk = !QKeySequence::mnemonic(source).isEmpty();2403 bool sk = haveMnemonic(source); 2379 2404 bool tk = true; 2380 2405 for (int i = 0; i < translations.count() && tk; ++i) { 2381 tk &= !QKeySequence::mnemonic(translations[i]).isEmpty();2406 tk &= haveMnemonic(translations[i]); 2382 2407 } 2383 2408 … … 2503 2528 void MainWindow::readConfig() 2504 2529 { 2505 QString keybase = settingsPrefix();2506 2530 QSettings config; 2507 2531 2508 2532 QRect r(pos(), size()); 2509 restoreGeometry(config.value( keybase + QLatin1String("Geometry/WindowGeometry")).toByteArray());2510 restoreState(config.value( keybase + QLatin1String("MainWindowState")).toByteArray());2533 restoreGeometry(config.value(settingPath("Geometry/WindowGeometry")).toByteArray()); 2534 restoreState(config.value(settingPath("MainWindowState")).toByteArray()); 2511 2535 2512 2536 m_ui.actionAccelerators->setChecked( 2513 config.value( keybase + QLatin1String("Validators/Accelerator"), true).toBool());2537 config.value(settingPath("Validators/Accelerator"), true).toBool()); 2514 2538 m_ui.actionEndingPunctuation->setChecked( 2515 config.value( keybase + QLatin1String("Validators/EndingPunctuation"), true).toBool());2539 config.value(settingPath("Validators/EndingPunctuation"), true).toBool()); 2516 2540 m_ui.actionPhraseMatches->setChecked( 2517 config.value( keybase + QLatin1String("Validators/PhraseMatch"), true).toBool());2541 config.value(settingPath("Validators/PhraseMatch"), true).toBool()); 2518 2542 m_ui.actionPlaceMarkerMatches->setChecked( 2519 config.value(keybase + QLatin1String("Validators/PlaceMarkers"), true).toBool()); 2543 config.value(settingPath("Validators/PlaceMarkers"), true).toBool()); 2544 m_ui.actionLengthVariants->setChecked( 2545 config.value(settingPath("Options/LengthVariants"), false).toBool()); 2520 2546 2521 2547 recentFiles().readConfig(); 2522 2548 2523 int size = config.beginReadArray( keybase + QLatin1String("OpenedPhraseBooks"));2549 int size = config.beginReadArray(settingPath("OpenedPhraseBooks")); 2524 2550 for (int i = 0; i < size; ++i) { 2525 2551 config.setArrayIndex(i); … … 2531 2557 void MainWindow::writeConfig() 2532 2558 { 2533 QString keybase = settingsPrefix();2534 2559 QSettings config; 2535 config.setValue( keybase + QLatin1String("Geometry/WindowGeometry"),2560 config.setValue(settingPath("Geometry/WindowGeometry"), 2536 2561 saveGeometry()); 2537 config.setValue( keybase + QLatin1String("Validators/Accelerator"),2562 config.setValue(settingPath("Validators/Accelerator"), 2538 2563 m_ui.actionAccelerators->isChecked()); 2539 config.setValue( keybase + QLatin1String("Validators/EndingPunctuation"),2564 config.setValue(settingPath("Validators/EndingPunctuation"), 2540 2565 m_ui.actionEndingPunctuation->isChecked()); 2541 config.setValue( keybase + QLatin1String("Validators/PhraseMatch"),2566 config.setValue(settingPath("Validators/PhraseMatch"), 2542 2567 m_ui.actionPhraseMatches->isChecked()); 2543 config.setValue( keybase + QLatin1String("Validators/PlaceMarkers"),2568 config.setValue(settingPath("Validators/PlaceMarkers"), 2544 2569 m_ui.actionPlaceMarkerMatches->isChecked()); 2545 config.setValue(keybase + QLatin1String("MainWindowState"), 2570 config.setValue(settingPath("Options/LengthVariants"), 2571 m_ui.actionLengthVariants->isChecked()); 2572 config.setValue(settingPath("MainWindowState"), 2546 2573 saveState()); 2547 2574 recentFiles().writeConfig(); 2548 2575 2549 config.beginWriteArray( keybase + QLatin1String("OpenedPhraseBooks"),2576 config.beginWriteArray(settingPath("OpenedPhraseBooks"), 2550 2577 m_phraseBooks.size()); 2551 2578 for (int i = 0; i < m_phraseBooks.size(); ++i) {
Note:
See TracChangeset
for help on using the changeset viewer.