Commit 5c665ccc authored by Stefan Derkits's avatar Stefan Derkits

[blogilo] Move Close Button to Tabs

In the Main Window each Tab could be
closed via a Close Button in the top
right corner.

This commit removes this widget and
adds close Buttons to each Tab to
make the UI look more modern.
parent e8b49962
......@@ -71,6 +71,7 @@ MainWindow::MainWindow()
tabPosts = new KTabWidget( this );
tabPosts->setElideMode( Qt::ElideRight );
tabPosts->setTabsClosable( true );
// #if KDE_IS_VERSION( 4, 5, 80 )
/// does not build with KDE 4.5.80: Compile Error: ‘QTabBar* QTabWidget::tabBar() const’ is protected
// tabPosts->tabBar()->setSelectionBehaviorOnRemove( QTabBar::SelectPreviousTab );
......@@ -78,6 +79,7 @@ MainWindow::MainWindow()
tabPosts->setTabCloseActivatePrevious( true );
// #endif
tabPosts->setDocumentMode(true);
connect( tabPosts, SIGNAL( tabCloseRequested( int ) ), this, SLOT( slotRemovePostEntry( int ) ) );
setCentralWidget( tabPosts );
// this->setDockOptions( QMainWindow::ForceTabbedDocks);
......@@ -90,11 +92,11 @@ MainWindow::MainWindow()
toolboxDock->setWidget( toolbox );
this->addDockWidget( Qt::RightDockWidgetArea, toolboxDock );
btnRemovePost = new QToolButton( tabPosts );
btnRemovePost->setIcon( KIcon( "tab-close" ) );
btnRemovePost->setToolTip( i18n( "Close tab" ) );
tabPosts->setCornerWidget( btnRemovePost, Qt::TopRightCorner );
connect( btnRemovePost, SIGNAL( clicked( bool ) ), this, SLOT( slotRemovePostEntry() ) );
//btnRemovePost = new QToolButton( tabPosts );
//btnRemovePost->setIcon( KIcon( "tab-close" ) );
//btnRemovePost->setToolTip( i18n( "Close tab" ) );
//tabPosts->setCornerWidget( btnRemovePost, Qt::TopRightCorner );
//connect( btnRemovePost, SIGNAL( clicked( bool ) ), this, SLOT( slotRemovePostEntry() ) );
// then, setup our actions
setupActions();
......@@ -470,9 +472,12 @@ void MainWindow::slotPublishPost()
activePost->submitPost( mCurrentBlogId, *activePost->currentPost() );
}
void MainWindow::slotRemovePostEntry( PostEntry *widget )
void MainWindow::slotRemovePostEntry( int pos )
{
kDebug();
PostEntry *widget = qobject_cast<PostEntry*>( tabPosts->widget( pos ) );
if( !widget ) {
if( activePost )
widget = activePost;
......@@ -553,7 +558,7 @@ void MainWindow::keyPressEvent( QKeyEvent * event )
toolbox->setCurrentPage( 4 );
break;
case Qt::Key_W:
slotRemovePostEntry();
slotRemovePostEntry( tabPosts->currentIndex() );
break;
default:
KXmlGuiWindow::keyPressEvent( event );
......@@ -571,7 +576,7 @@ void MainWindow::postManipulationDone( bool isError, const QString &customMessag
PostEntry *entry = qobject_cast<PostEntry*>(sender());
if(entry && KMessageBox::questionYesNo(this, i18n("%1\nDo you want to keep the post open?", customMessage),
QString(), KStandardGuiItem::yes(), KStandardGuiItem::no(), "KeepPostOpen") == KMessageBox::No ) {
slotRemovePostEntry(entry);
slotRemovePostEntry( tabPosts->indexOf( entry ) );
} else {
toolbox->setFieldsValue(entry->currentPost());
}
......
......@@ -73,9 +73,9 @@ protected slots:
void slotPublishPost();
/**
* Remove @p widget from main tab wigdet (if it's NULL current Post entry will be removed)
* Remove widget at position @p pos from main tab wigdet
*/
void slotRemovePostEntry( PostEntry *widget=0 );
void slotRemovePostEntry( int post );
void slotSavePostLocally();
// void slotSaveAsDraft();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment