mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-24 01:48:44 +00:00
Changed: #1307 Added some features and making little modifications
--HG-- branch : gsoc2011-translationovqt
This commit is contained in:
parent
23f1309995
commit
44804ea770
7 changed files with 681 additions and 613 deletions
|
@ -80,37 +80,37 @@ void CEditorPhrase::saveAs(QString filename)
|
|||
setCurrentFile(current_file);
|
||||
}
|
||||
|
||||
void CEditorPhrase::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if(isWindowModified())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("The document has been modified.");
|
||||
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();
|
||||
switch (ret)
|
||||
{
|
||||
case QMessageBox::Save:
|
||||
save();
|
||||
event->accept();
|
||||
close();
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
event->accept();
|
||||
close();
|
||||
break;
|
||||
case QMessageBox::Cancel:
|
||||
event->ignore();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
event->accept();
|
||||
close();
|
||||
}
|
||||
void CEditorPhrase::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if(isWindowModified())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("The document has been modified.");
|
||||
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();
|
||||
switch (ret)
|
||||
{
|
||||
case QMessageBox::Save:
|
||||
save();
|
||||
event->accept();
|
||||
close();
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
event->accept();
|
||||
close();
|
||||
break;
|
||||
case QMessageBox::Cancel:
|
||||
event->ignore();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
event->accept();
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -65,6 +65,7 @@ private Q_SLOTS:
|
|||
void worksheetEditorChanged(QTableWidgetItem * item);
|
||||
void insertRow();
|
||||
void deleteRow();
|
||||
void contextMenuEvent(QContextMenuEvent *e);
|
||||
|
||||
};
|
||||
|
||||
|
@ -123,6 +124,7 @@ public:
|
|||
{
|
||||
QTableWidgetItem* item = new QTableWidgetItem();
|
||||
m_table->setItem(m_rowID, j, item);
|
||||
m_table->scrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
|
||||
|
@ -123,16 +124,14 @@ void CMainWindow::createToolbar()
|
|||
mergeSingleFileAct->setStatusTip(tr("Merge worksheet file from local or remote directory"));
|
||||
connect(mergeSingleFileAct, SIGNAL(triggered()), this, SLOT(mergeSingleFile()));
|
||||
// Windows menu
|
||||
windowMenu = new QMenu(tr("&Windows..."), _ui.toolBar);
|
||||
windowMenu->setIcon(QIcon(Core::Constants::ICON_PILL));
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
Core::IMenuManager *menuManager = core->menuManager();
|
||||
windowMenu = menuManager->menuBar()->addMenu("Window");
|
||||
updateWindowsList();
|
||||
_ui.toolBar->addAction(windowMenu->menuAction());
|
||||
connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowsList()));
|
||||
|
||||
// Undo, Redo actions
|
||||
// -----------------------------
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
Core::IMenuManager *menuManager = core->menuManager();
|
||||
QAction* undoAction = menuManager->action(Core::Constants::UNDO);
|
||||
if (undoAction != 0)
|
||||
_ui.toolBar->addAction(undoAction);
|
||||
|
@ -147,10 +146,15 @@ void CMainWindow::updateToolbar(QMdiSubWindow *window)
|
|||
if(_ui.mdiArea->subWindowList().size() > 0)
|
||||
if(QString(window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
|
||||
{
|
||||
QAction *insertRowAct = windowMenu->addAction("Insert new row");
|
||||
connect(insertRowAct, SIGNAL(triggered()), window, SLOT(insertRow()));
|
||||
QAction *deleteRowAct = windowMenu->addAction("Delete row");
|
||||
//setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
QAction *insertRowAct = new QAction("Insert new row", this);
|
||||
connect(insertRowAct, SIGNAL(triggered()), window, SLOT(insertRow()));
|
||||
//addAction(insertRowAct);
|
||||
windowMenu->addAction(insertRowAct);
|
||||
QAction *deleteRowAct = new QAction("Delete row", this);
|
||||
connect(deleteRowAct, SIGNAL(triggered()), window, SLOT(deleteRow()));
|
||||
//addAction(deleteRowAct);
|
||||
windowMenu->addAction(deleteRowAct);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +171,7 @@ void CMainWindow::setActiveSubWindow(QWidget* window)
|
|||
|
||||
void CMainWindow::activeSubWindowChanged()
|
||||
{
|
||||
//TODO: nothing to be done here atm
|
||||
|
||||
}
|
||||
|
||||
void CMainWindow::updateWindowsList()
|
||||
|
@ -187,10 +191,11 @@ void CMainWindow::updateWindowsList()
|
|||
} else {
|
||||
action_text = tr("%1 %2").arg(i + 1).arg(window_file);
|
||||
}
|
||||
QAction *action = windowMenu->addAction(action_text);
|
||||
QAction *action = new QAction(action_text, this);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(subWindows.at(i) == current_window);
|
||||
connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
|
||||
connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
|
||||
windowMenu->addAction(action);
|
||||
windowMapper->setMapping(action, subWindows.at(i));
|
||||
}
|
||||
}
|
||||
|
@ -589,7 +594,35 @@ bool CMainWindow::isPhraseEditor(QString filename)
|
|||
|
||||
bool CCoreListener::closeMainWindow() const
|
||||
{
|
||||
return 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();
|
||||
switch (ret)
|
||||
{
|
||||
case QMessageBox::Save:
|
||||
currentEditor->save();
|
||||
return true;
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
return true;
|
||||
break;
|
||||
case QMessageBox::Cancel:
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace Plugin */
|
||||
|
|
|
@ -62,8 +62,9 @@ public:
|
|||
CMainWindow(QWidget *parent = 0);
|
||||
virtual ~CMainWindow() {}
|
||||
QUndoStack *m_undoStack;
|
||||
private:
|
||||
Ui::CMainWindow _ui;
|
||||
public:
|
||||
Ui::CMainWindow _ui;
|
||||
private:
|
||||
// actions
|
||||
QAction *openAct;
|
||||
QAction *saveAct;
|
||||
|
@ -111,13 +112,20 @@ class CCoreListener : public Core::ICoreListener
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CCoreListener(QObject *parent = 0): ICoreListener(parent) {}
|
||||
virtual ~CCoreListener() {}
|
||||
CCoreListener(CMainWindow* mainWindow, QObject *parent = 0): ICoreListener(parent)
|
||||
{
|
||||
m_MainWindow = mainWindow;
|
||||
}
|
||||
|
||||
virtual ~CCoreListener() {}
|
||||
virtual bool closeMainWindow() const;
|
||||
|
||||
public:
|
||||
CMainWindow *m_MainWindow;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Plugin
|
||||
|
||||
|
||||
|
|
|
@ -53,10 +53,12 @@ bool TranslationManagerPlugin::initialize(ExtensionSystem::IPluginManager *plugi
|
|||
{
|
||||
Q_UNUSED(errorString);
|
||||
_plugMan = pluginManager;
|
||||
// create the mainwindow
|
||||
CMainWindow *mainWindow = new CMainWindow();
|
||||
|
||||
addAutoReleasedObject(new CTranslationManagerSettingsPage(this));
|
||||
addAutoReleasedObject(new CTranslationManagerContext(this));
|
||||
addAutoReleasedObject(new CCoreListener(this));
|
||||
addAutoReleasedObject(new CTranslationManagerContext(mainWindow, this));
|
||||
addAutoReleasedObject(new CCoreListener(mainWindow, this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -75,6 +77,8 @@ void TranslationManagerPlugin::extensionsInitialized()
|
|||
helpMenu->insertAction(aboutQtAction, aboutTManPlugin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TranslationManagerPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
|
|
|
@ -82,9 +82,9 @@ class CTranslationManagerContext: public Core::IContext
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CTranslationManagerContext(QObject *parent = 0): IContext(parent)
|
||||
CTranslationManagerContext(CMainWindow* mainWindow, QObject *parent = 0): IContext(parent)
|
||||
{
|
||||
m_MainWindow = new CMainWindow();
|
||||
m_MainWindow = mainWindow;
|
||||
}
|
||||
|
||||
virtual ~CTranslationManagerContext() {}
|
||||
|
|
Loading…
Reference in a new issue