File indexing completed on 2024-05-05 04:49:22

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #include "PopupWidget.h"
0018 
0019 #include "MainWindow.h"
0020 
0021 #include "core/support/Debug.h"
0022 
0023 #include <QVBoxLayout>
0024 
0025 
0026 PopupWidget::PopupWidget( const QString &name )
0027     : BoxWidget( true )
0028 {
0029     Q_UNUSED( name );
0030 
0031     setBackgroundRole( QPalette::Window );
0032     setAutoFillBackground( true );
0033 
0034     setFrameStyle( QFrame::Box );
0035 
0036     setMinimumWidth( 26 );
0037     setMinimumHeight( 26 );
0038 
0039     setContentsMargins( 4, 4, 4, 4 );
0040     setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
0041 }
0042 
0043 PopupWidget::~PopupWidget()
0044 {
0045     DEBUG_BLOCK
0046 }
0047 
0048 void PopupWidget::reposition()
0049 {
0050     adjustSize();
0051 
0052     if( !The::mainWindow() )
0053         return;
0054 
0055     //HACK: put longmessage popup in the bottom right of the window.
0056     QPoint p;
0057     p.setX( The::mainWindow()->width() - width() );
0058     p.setY( The::mainWindow()->height() - height() );
0059     move( p );
0060 }