File indexing completed on 2024-05-05 04:47:21
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 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 "BookmarkManager.h" 0018 0019 #include "core/support/Amarok.h" 0020 0021 #include <QApplication> 0022 #include <QDialog> 0023 #include <QHBoxLayout> 0024 0025 #include <KConfigGroup> 0026 #include <KLocalizedString> 0027 0028 BookmarkManager * BookmarkManager::s_instance = nullptr; 0029 0030 BookmarkManager::BookmarkManager( QWidget* parent ) 0031 : QDialog( parent ) 0032 { 0033 // Sets caption and icon correctly (needed e.g. for GNOME) 0034 //kapp->setTopWidget( this ); 0035 setWindowTitle( i18n("Bookmark Manager") ); 0036 setAttribute( Qt::WA_DeleteOnClose ); 0037 setObjectName( QStringLiteral("BookmarkManager") ); 0038 0039 QHBoxLayout *layout = new QHBoxLayout( this ); 0040 m_widget = new BookmarkManagerWidget( this ); 0041 layout->addWidget( m_widget ); 0042 layout->setContentsMargins( 0, 0, 0, 0 ); 0043 0044 const QSize winSize = Amarok::config( QStringLiteral("Bookmark Manager") ).readEntry( "Window Size", QSize( 600, 400 ) ); 0045 resize( winSize ); 0046 } 0047 0048 BookmarkManager::~BookmarkManager() 0049 { 0050 Amarok::config( QStringLiteral("Bookmark Manager") ).writeEntry( "Window Size", size() ); 0051 s_instance = nullptr; 0052 } 0053 0054 void BookmarkManager::showOnce( QWidget* parent ) 0055 { 0056 if( s_instance == nullptr ) 0057 s_instance = new BookmarkManager( parent ); 0058 0059 s_instance->activateWindow(); 0060 s_instance->show(); 0061 s_instance->raise(); 0062 } 0063