some more close options

This commit is contained in:
nemu 2009-05-16 09:18:22 +00:00
parent 3dd8b3e73f
commit cb56ae9c8a
2 changed files with 69 additions and 0 deletions

View File

@ -189,9 +189,17 @@ void PTextEdit::setupFileActions()
connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
a->addTo( tb );
a->addTo( menu );
menu->insertSeparator();
a = new QAction( tr( "&Close" ), CTRL + Key_W, this, "fileClose" );
connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) );
a->addTo( menu );
a = new QAction( tr( "Close &All" ), 0, this, "fileCloseAll" );
connect( a, SIGNAL( activated() ), this, SLOT( fileCloseAll() ) );
a->addTo( menu );
a = new QAction( tr( "Clo&se All Others" ), 0, this, "fileCloseAllOthers" );
connect( a, SIGNAL( activated() ), this, SLOT( fileCloseAllOthers() ) );
a->addTo( menu );
menu->insertSeparator();
a = new QAction( tr( "E&xit" ), CTRL + Key_Q, this, "fileExit" );
connect( a, SIGNAL( activated() ), this, SLOT( fileExit() ) );
a->addTo( menu );
@ -625,6 +633,65 @@ void PTextEdit::fileClose(const bool check)
currentEditor()->viewport()->setFocus();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PTextEdit::fileCloseAll()
{
// check if any editor tab is present, if not: get out of here
if ( !currentEditor() )
return;
int result = QMessageBox::warning(this, "**WARNING**",
"Do you really want to close all files.\nChanges of unsaved files will be lost",
"Close", "Cancel");
if (result == 1) // Cancel
return;
// close all editor tabs
do {
delete currentEditor();
if ( currentEditor() )
currentEditor()->viewport()->setFocus();
} while ( currentEditor() );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PTextEdit::fileCloseAllOthers()
{
// check if any editor tab is present, if not: get out of here
if ( !currentEditor() )
return;
int result = QMessageBox::warning(this, "**WARNING**",
"Do you really want to close all files.\nChanges of unsaved files will be lost",
"Close", "Cancel");
if (result == 1) // Cancel
return;
// keep label of the current editor
QString label = fTabWidget->label(fTabWidget->currentPageIndex());
// check if only the current editor is present. If yes: nothing to be done
if (fTabWidget->count() == 1)
return;
// close all editor tabs
int i=0;
do {
if (fTabWidget->label(i) != label)
delete fTabWidget->page(i);
else
i++;
} while ( fTabWidget->count() > 1 );
currentEditor()->viewport()->setFocus();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>

View File

@ -75,6 +75,8 @@ private slots:
void fileSaveAs();
void filePrint();
void fileClose( const bool check = true );
void fileCloseAll();
void fileCloseAllOthers();
void fileExit();
void editUndo();