mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 04:40:53 +00:00
Changed: #1307 Added documentation and minor fixes
--HG-- branch : gsoc2011-translationovqt
This commit is contained in:
parent
ec3fcf5ef3
commit
2a9293b72a
4 changed files with 75 additions and 59 deletions
|
@ -59,7 +59,7 @@ void CEditorWorksheet::open(QString filename)
|
||||||
} else {
|
} else {
|
||||||
QTableWidgetItem *col = new QTableWidgetItem();
|
QTableWidgetItem *col = new QTableWidgetItem();
|
||||||
ucstring col_name = wk_file.getData(0, i);
|
ucstring col_name = wk_file.getData(0, i);
|
||||||
col->setText(tr(col_name.toString().c_str()));
|
col->setText(QString(col_name.toString().c_str()));
|
||||||
if(hasHashValue)
|
if(hasHashValue)
|
||||||
{
|
{
|
||||||
table_editor->setHorizontalHeaderItem(i - 1, col);
|
table_editor->setHorizontalHeaderItem(i - 1, col);
|
||||||
|
@ -241,9 +241,9 @@ void CEditorWorksheet::extractBotNames(list<string> filters, string level_design
|
||||||
if(search_results.size() == 0)
|
if(search_results.size() == 0)
|
||||||
{
|
{
|
||||||
QList<QString> records;
|
QList<QString> records;
|
||||||
records.push_back(tr(it->first.c_str()));
|
records.push_back(QString(it->first.c_str()));
|
||||||
records.push_back(tr(it->first.c_str()));
|
records.push_back(QString(it->first.c_str()));
|
||||||
records.push_back(tr(it->second.SheetName.c_str()));
|
records.push_back(QString(it->second.SheetName.c_str()));
|
||||||
insertTableRecords(records, new_items);
|
insertTableRecords(records, new_items);
|
||||||
if(!modified) modified = true;
|
if(!modified) modified = true;
|
||||||
}
|
}
|
||||||
|
@ -261,8 +261,8 @@ void CEditorWorksheet::extractBotNames(list<string> filters, string level_design
|
||||||
if(search_results.size() == 0)
|
if(search_results.size() == 0)
|
||||||
{
|
{
|
||||||
QList<QString> records;
|
QList<QString> records;
|
||||||
records.push_back(tr((*it).c_str()));
|
records.push_back(QString((*it).c_str()));
|
||||||
records.push_back(tr(gnName.c_str()));
|
records.push_back(QString(gnName.c_str()));
|
||||||
records.push_back(" ");
|
records.push_back(" ");
|
||||||
insertTableRecords(records, new_items);
|
insertTableRecords(records, new_items);
|
||||||
if(!modified) modified = true;
|
if(!modified) modified = true;
|
||||||
|
@ -318,7 +318,7 @@ void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordLis
|
||||||
for(i = 0; i < allWords.size(); i++)
|
for(i = 0; i < allWords.size(); i++)
|
||||||
{
|
{
|
||||||
string keyName = allWords[i];
|
string keyName = allWords[i];
|
||||||
QList<QTableWidgetItem*> search_results = table_editor->findItems(tr(keyName.c_str()), Qt::MatchExactly);
|
QList<QTableWidgetItem*> search_results = table_editor->findItems(QString(keyName.c_str()), Qt::MatchExactly);
|
||||||
if(search_results.size() == 0)
|
if(search_results.size() == 0)
|
||||||
{
|
{
|
||||||
int knPos = 0, nPos = 0;
|
int knPos = 0, nPos = 0;
|
||||||
|
@ -332,8 +332,8 @@ void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordLis
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> records;
|
QList<QString> records;
|
||||||
records.push_back(tr(keyName.c_str()));
|
records.push_back(QString(keyName.c_str()));
|
||||||
records.push_back(QString("<GEN>") + tr(keyName.c_str()));
|
records.push_back(QString("<GEN>") + QString(keyName.c_str()));
|
||||||
insertTableRecords(records, new_items);
|
insertTableRecords(records, new_items);
|
||||||
if(!modified) modified = true;
|
if(!modified) modified = true;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ void CEditorWorksheet::mergeWorksheetFile(QString filename)
|
||||||
{
|
{
|
||||||
// search with the first column
|
// search with the first column
|
||||||
ucstring rowId = wk_file.getData(i,colIndex);
|
ucstring rowId = wk_file.getData(i,colIndex);
|
||||||
QList<QTableWidgetItem*> search_results = table_editor->findItems(tr(rowId.toString().c_str()), Qt::MatchExactly);
|
QList<QTableWidgetItem*> search_results = table_editor->findItems(QString(rowId.toString().c_str()), Qt::MatchExactly);
|
||||||
if(search_results.size() == 0)
|
if(search_results.size() == 0)
|
||||||
{
|
{
|
||||||
const int lastRow = table_editor->rowCount();
|
const int lastRow = table_editor->rowCount();
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace TranslationManager
|
||||||
status = false;
|
status = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connection with the FTP Server. We retrieve the file list.
|
||||||
void CFtpSelection::ConnectButtonClicked()
|
void CFtpSelection::ConnectButtonClicked()
|
||||||
{
|
{
|
||||||
conn = new QFtp(this);
|
conn = new QFtp(this);
|
||||||
|
@ -51,6 +52,7 @@ namespace TranslationManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the user action.
|
||||||
void CFtpSelection::FtpCommandFinished(int, bool error)
|
void CFtpSelection::FtpCommandFinished(int, bool error)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
|
@ -98,7 +100,7 @@ namespace TranslationManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Make the file list with directories and files
|
||||||
void CFtpSelection::AddToList(const QUrlInfo &urlInfo)
|
void CFtpSelection::AddToList(const QUrlInfo &urlInfo)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||||
|
@ -138,6 +140,7 @@ namespace TranslationManager
|
||||||
_ui.doneButton->setEnabled(true);
|
_ui.doneButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exit from a directory
|
||||||
void CFtpSelection::cdToParent()
|
void CFtpSelection::cdToParent()
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
|
@ -155,6 +158,7 @@ namespace TranslationManager
|
||||||
conn->list();
|
conn->list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Done action
|
||||||
void CFtpSelection::DoneButtonClicked()
|
void CFtpSelection::DoneButtonClicked()
|
||||||
{
|
{
|
||||||
QString fileName = _ui.fileList->currentItem()->text(0);
|
QString fileName = _ui.fileList->currentItem()->text(0);
|
||||||
|
|
|
@ -17,6 +17,7 @@ CSourceDialog::CSourceDialog(QWidget *parent): QDialog(parent)
|
||||||
_ui.listWidget->setSortingEnabled(false);
|
_ui.listWidget->setSortingEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert options in the source dialog. Options like: from FTP Server, from Local directory etc.
|
||||||
void CSourceDialog::setSourceOptions(map<QListWidgetItem*,int> options)
|
void CSourceDialog::setSourceOptions(map<QListWidgetItem*,int> options)
|
||||||
{
|
{
|
||||||
map<QListWidgetItem*,int>::iterator it;
|
map<QListWidgetItem*,int>::iterator it;
|
||||||
|
|
|
@ -52,7 +52,6 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||||
_ui.setupUi(this);
|
_ui.setupUi(this);
|
||||||
|
|
||||||
_ui.mdiArea->closeAllSubWindows();
|
_ui.mdiArea->closeAllSubWindows();
|
||||||
connect(_ui.mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),this, SLOT(activeSubWindowChanged()));
|
|
||||||
windowMapper = new QSignalMapper(this);
|
windowMapper = new QSignalMapper(this);
|
||||||
connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*)));
|
connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*)));
|
||||||
|
|
||||||
|
@ -66,6 +65,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Functions that will insert the plugin buttons
|
||||||
void CMainWindow::createToolbar()
|
void CMainWindow::createToolbar()
|
||||||
{
|
{
|
||||||
// File menu
|
// File menu
|
||||||
|
@ -96,27 +96,27 @@ void CMainWindow::createToolbar()
|
||||||
QAction *extractItemWordsAct = wordsExtractionMenu->addAction("&Extract item words...");
|
QAction *extractItemWordsAct = wordsExtractionMenu->addAction("&Extract item words...");
|
||||||
extractItemWordsAct->setStatusTip(tr("Extract item words"));
|
extractItemWordsAct->setStatusTip(tr("Extract item words"));
|
||||||
connect(extractItemWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
connect(extractItemWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
||||||
wordsExtractionMapper->setMapping(extractItemWordsAct, tr(Constants::WK_ITEM));
|
wordsExtractionMapper->setMapping(extractItemWordsAct, QString(Constants::WK_ITEM));
|
||||||
// extract creature words
|
// extract creature words
|
||||||
QAction *extractCreatureWordsAct = wordsExtractionMenu->addAction("&Extract creature words...");
|
QAction *extractCreatureWordsAct = wordsExtractionMenu->addAction("&Extract creature words...");
|
||||||
extractCreatureWordsAct->setStatusTip(tr("Extract creature words"));
|
extractCreatureWordsAct->setStatusTip(tr("Extract creature words"));
|
||||||
connect(extractCreatureWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
connect(extractCreatureWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
||||||
wordsExtractionMapper->setMapping(extractCreatureWordsAct, tr(Constants::WK_CREATURE));
|
wordsExtractionMapper->setMapping(extractCreatureWordsAct, QString(Constants::WK_CREATURE));
|
||||||
// extract sbrick words
|
// extract sbrick words
|
||||||
QAction *extractSbrickWordsAct = wordsExtractionMenu->addAction("&Extract sbrick words...");
|
QAction *extractSbrickWordsAct = wordsExtractionMenu->addAction("&Extract sbrick words...");
|
||||||
extractSbrickWordsAct->setStatusTip(tr("Extract sbrick words"));
|
extractSbrickWordsAct->setStatusTip(tr("Extract sbrick words"));
|
||||||
connect(extractSbrickWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
connect(extractSbrickWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
||||||
wordsExtractionMapper->setMapping(extractSbrickWordsAct, tr(Constants::WK_SBRICK));
|
wordsExtractionMapper->setMapping(extractSbrickWordsAct, QString(Constants::WK_SBRICK));
|
||||||
// extract sphrase words
|
// extract sphrase words
|
||||||
QAction *extractSphraseWordsAct = wordsExtractionMenu->addAction("&Extract sphrase words...");
|
QAction *extractSphraseWordsAct = wordsExtractionMenu->addAction("&Extract sphrase words...");
|
||||||
extractSphraseWordsAct->setStatusTip(tr("Extract sphrase words"));
|
extractSphraseWordsAct->setStatusTip(tr("Extract sphrase words"));
|
||||||
connect(extractSphraseWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
connect(extractSphraseWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
||||||
wordsExtractionMapper->setMapping(extractSphraseWordsAct, tr(Constants::WK_SPHRASE));
|
wordsExtractionMapper->setMapping(extractSphraseWordsAct, QString(Constants::WK_SPHRASE));
|
||||||
// extract place and region names
|
// extract place and region names
|
||||||
QAction *extractPlaceNamesAct = wordsExtractionMenu->addAction("&Extract place names...");
|
QAction *extractPlaceNamesAct = wordsExtractionMenu->addAction("&Extract place names...");
|
||||||
extractPlaceNamesAct->setStatusTip(tr("Extract place names from primitives"));
|
extractPlaceNamesAct->setStatusTip(tr("Extract place names from primitives"));
|
||||||
connect(extractPlaceNamesAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
connect(extractPlaceNamesAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
|
||||||
wordsExtractionMapper->setMapping(extractPlaceNamesAct, tr(Constants::WK_PLACE));
|
wordsExtractionMapper->setMapping(extractPlaceNamesAct, QString(Constants::WK_PLACE));
|
||||||
// Merge options
|
// Merge options
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
QAction *mergeSingleFileAct = wordsExtractionMenu->addAction("&Merge worksheet file...");
|
QAction *mergeSingleFileAct = wordsExtractionMenu->addAction("&Merge worksheet file...");
|
||||||
|
@ -140,24 +140,23 @@ void CMainWindow::createToolbar()
|
||||||
_ui.toolBar->addAction(redoAction);
|
_ui.toolBar->addAction(redoAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the toolbar if the editor is worksheet
|
||||||
void CMainWindow::updateToolbar(QMdiSubWindow *window)
|
void CMainWindow::updateToolbar(QMdiSubWindow *window)
|
||||||
{
|
{
|
||||||
if(_ui.mdiArea->subWindowList().size() > 0)
|
if(_ui.mdiArea->subWindowList().size() > 0)
|
||||||
if(QString(window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
|
if(QString(window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
|
||||||
{
|
{
|
||||||
//setContextMenuPolicy(Qt::ActionsContextMenu);
|
|
||||||
QAction *insertRowAct = new QAction(tr("Insert new row"), this);
|
QAction *insertRowAct = new QAction(tr("Insert new row"), this);
|
||||||
connect(insertRowAct, SIGNAL(triggered()), window, SLOT(insertRow()));
|
connect(insertRowAct, SIGNAL(triggered()), window, SLOT(insertRow()));
|
||||||
//addAction(insertRowAct);
|
|
||||||
windowMenu->addAction(insertRowAct);
|
windowMenu->addAction(insertRowAct);
|
||||||
QAction *deleteRowAct = new QAction(tr("Delete row"), this);
|
QAction *deleteRowAct = new QAction(tr("Delete row"), this);
|
||||||
connect(deleteRowAct, SIGNAL(triggered()), window, SLOT(deleteRow()));
|
connect(deleteRowAct, SIGNAL(triggered()), window, SLOT(deleteRow()));
|
||||||
//addAction(deleteRowAct);
|
|
||||||
windowMenu->addAction(deleteRowAct);
|
windowMenu->addAction(deleteRowAct);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the active subwindow
|
||||||
void CMainWindow::setActiveSubWindow(QWidget* window)
|
void CMainWindow::setActiveSubWindow(QWidget* window)
|
||||||
{
|
{
|
||||||
if (!window)
|
if (!window)
|
||||||
|
@ -168,13 +167,11 @@ void CMainWindow::setActiveSubWindow(QWidget* window)
|
||||||
_ui.mdiArea->setActiveSubWindow(cwindow);
|
_ui.mdiArea->setActiveSubWindow(cwindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::activeSubWindowChanged()
|
// Functions for updating the windows list
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMainWindow::updateWindowsList()
|
void CMainWindow::updateWindowsList()
|
||||||
{
|
{
|
||||||
|
if(_ui.mdiArea->activeSubWindow())
|
||||||
|
{
|
||||||
windowMenu->clear();
|
windowMenu->clear();
|
||||||
QMdiSubWindow *current_window = _ui.mdiArea->activeSubWindow();
|
QMdiSubWindow *current_window = _ui.mdiArea->activeSubWindow();
|
||||||
QList<QMdiSubWindow*> subWindows = _ui.mdiArea->subWindowList();
|
QList<QMdiSubWindow*> subWindows = _ui.mdiArea->subWindowList();
|
||||||
|
@ -186,9 +183,9 @@ void CMainWindow::updateWindowsList()
|
||||||
QString window_file = QFileInfo(subWindows.at(i)->windowFilePath()).fileName();
|
QString window_file = QFileInfo(subWindows.at(i)->windowFilePath()).fileName();
|
||||||
QString action_text;
|
QString action_text;
|
||||||
if (i < 9) {
|
if (i < 9) {
|
||||||
action_text = tr("&%1 %2").arg(i + 1).arg(window_file);
|
action_text = QString("&%1 %2").arg(i + 1).arg(window_file);
|
||||||
} else {
|
} else {
|
||||||
action_text = tr("%1 %2").arg(i + 1).arg(window_file);
|
action_text = QString("%1 %2").arg(i + 1).arg(window_file);
|
||||||
}
|
}
|
||||||
QAction *action = new QAction(action_text, this);
|
QAction *action = new QAction(action_text, this);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
|
@ -197,8 +194,11 @@ void CMainWindow::updateWindowsList()
|
||||||
windowMenu->addAction(action);
|
windowMenu->addAction(action);
|
||||||
windowMapper->setMapping(action, subWindows.at(i));
|
windowMapper->setMapping(action, subWindows.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open signal
|
||||||
void CMainWindow::open()
|
void CMainWindow::open()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
@ -243,6 +243,7 @@ void CMainWindow::open()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open a work file. You can set the directory for work file in the settings dialog
|
||||||
void CMainWindow::openWorkFile(QString file)
|
void CMainWindow::openWorkFile(QString file)
|
||||||
{
|
{
|
||||||
QFileInfo* file_path = new QFileInfo(QString("%1/%2").arg(work_path).arg(file));
|
QFileInfo* file_path = new QFileInfo(QString("%1/%2").arg(work_path).arg(file));
|
||||||
|
@ -262,6 +263,7 @@ void CMainWindow::openWorkFile(QString file)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save signal
|
||||||
void CMainWindow::save()
|
void CMainWindow::save()
|
||||||
{
|
{
|
||||||
if(_ui.mdiArea->subWindowList().size() > 0)
|
if(_ui.mdiArea->subWindowList().size() > 0)
|
||||||
|
@ -277,6 +279,7 @@ void CMainWindow::save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save as signal
|
||||||
void CMainWindow::saveAs()
|
void CMainWindow::saveAs()
|
||||||
{
|
{
|
||||||
QString file_name;
|
QString file_name;
|
||||||
|
@ -298,6 +301,7 @@ void CMainWindow::saveAs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function is needed by extraction.
|
||||||
void CMainWindow::initializeSettings(bool georges = false)
|
void CMainWindow::initializeSettings(bool georges = false)
|
||||||
{
|
{
|
||||||
if(georges == true && initialize_settings["georges"] == false)
|
if(georges == true && initialize_settings["georges"] == false)
|
||||||
|
@ -327,6 +331,7 @@ void CMainWindow::initializeSettings(bool georges = false)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extracting words
|
||||||
void CMainWindow::extractWords(QString typeq)
|
void CMainWindow::extractWords(QString typeq)
|
||||||
{
|
{
|
||||||
if(verifySettings() == true)
|
if(verifySettings() == true)
|
||||||
|
@ -396,6 +401,7 @@ void CMainWindow::extractWords(QString typeq)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract bot names from primitives
|
||||||
void CMainWindow::extractBotNames()
|
void CMainWindow::extractBotNames()
|
||||||
{
|
{
|
||||||
if(verifySettings() == true)
|
if(verifySettings() == true)
|
||||||
|
@ -425,6 +431,7 @@ void CMainWindow::extractBotNames()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merge the content for 2 worksheet files
|
||||||
void CMainWindow::mergeSingleFile()
|
void CMainWindow::mergeSingleFile()
|
||||||
{
|
{
|
||||||
CEditor* editor_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
|
CEditor* editor_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
|
||||||
|
@ -485,7 +492,7 @@ void CMainWindow::mergeSingleFile()
|
||||||
current_window->mergeWorksheetFile(file_name);
|
current_window->mergeWorksheetFile(file_name);
|
||||||
} else {
|
} else {
|
||||||
QErrorMessage error;
|
QErrorMessage error;
|
||||||
error.showMessage(QString("The file: %1 has different columns from the current file in editor.").arg(file_name));
|
error.showMessage(tr("The file: %1 has different columns from the current file in editor.").arg(file_name));
|
||||||
error.exec();
|
error.exec();
|
||||||
}
|
}
|
||||||
if(dialog->selected_item == ftp_item)
|
if(dialog->selected_item == ftp_item)
|
||||||
|
@ -493,13 +500,14 @@ void CMainWindow::mergeSingleFile()
|
||||||
if(!ftp_dialog->file->remove())
|
if(!ftp_dialog->file->remove())
|
||||||
{
|
{
|
||||||
QErrorMessage error;
|
QErrorMessage error;
|
||||||
error.showMessage(QString("Please remove the file from ftp server manually. The file is located on the same directory with OVQT application."));
|
error.showMessage(tr("Please remove the file from ftp server manually. The file is located on the same directory with OVQT application."));
|
||||||
error.exec();
|
error.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read the settings from QSettings
|
||||||
void CMainWindow::readSettings()
|
void CMainWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
@ -517,6 +525,7 @@ void CMainWindow::readSettings()
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify the settings
|
||||||
bool CMainWindow::verifySettings()
|
bool CMainWindow::verifySettings()
|
||||||
{
|
{
|
||||||
bool count_errors = false;
|
bool count_errors = false;
|
||||||
|
@ -533,6 +542,36 @@ bool CMainWindow::verifySettings()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCoreListener::closeMainWindow() const
|
||||||
|
{
|
||||||
|
bool okToClose = true;
|
||||||
|
Q_FOREACH(QMdiSubWindow *subWindow, m_MainWindow->_ui.mdiArea->subWindowList())
|
||||||
|
{
|
||||||
|
CEditor *currentEditor = qobject_cast<CEditor*>(subWindow);
|
||||||
|
if(subWindow->isWindowModified())
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(tr("The document has been modified ( %1 ).").arg(currentEditor->windowFilePath()));
|
||||||
|
msgBox.setInformativeText("Do you want to save your changes?");
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Save);
|
||||||
|
int ret = msgBox.exec();
|
||||||
|
if(ret == QMessageBox::Save)
|
||||||
|
{
|
||||||
|
currentEditor->save();
|
||||||
|
}
|
||||||
|
else if(ret == QMessageBox::Cancel)
|
||||||
|
{
|
||||||
|
okToClose = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return okToClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Helper functions
|
||||||
CEditor *CMainWindow::getEditorByWindowFilePath(const QString &fileName)
|
CEditor *CMainWindow::getEditorByWindowFilePath(const QString &fileName)
|
||||||
{
|
{
|
||||||
Q_FOREACH(QMdiSubWindow *subWindow, _ui.mdiArea->subWindowList())
|
Q_FOREACH(QMdiSubWindow *subWindow, _ui.mdiArea->subWindowList())
|
||||||
|
@ -604,34 +643,6 @@ bool CMainWindow::isPhraseEditor(QString filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCoreListener::closeMainWindow() const
|
|
||||||
{
|
|
||||||
bool okToClose = true;
|
|
||||||
Q_FOREACH(QMdiSubWindow *subWindow, m_MainWindow->_ui.mdiArea->subWindowList())
|
|
||||||
{
|
|
||||||
CEditor *currentEditor = qobject_cast<CEditor*>(subWindow);
|
|
||||||
if(subWindow->isWindowModified())
|
|
||||||
{
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setText(tr("The document has been modified ( %1 ).").arg(currentEditor->windowFilePath()));
|
|
||||||
msgBox.setInformativeText("Do you want to save your changes?");
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
|
||||||
msgBox.setDefaultButton(QMessageBox::Save);
|
|
||||||
int ret = msgBox.exec();
|
|
||||||
if(ret == QMessageBox::Save)
|
|
||||||
{
|
|
||||||
currentEditor->save();
|
|
||||||
}
|
|
||||||
else if(ret == QMessageBox::Cancel)
|
|
||||||
{
|
|
||||||
okToClose = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return okToClose;
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* namespace Plugin */
|
} /* namespace Plugin */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue