File indexing completed on 2024-04-14 14:35:55
0001 /************************************************************************ 0002 * * 0003 * This file is part of Kooka, a scanning/OCR application using * 0004 * Qt <http://www.qt.io> and KDE Frameworks <http://www.kde.org>. * 0005 * * 0006 * Copyright (C) 2000-2016 Klaas Freitag <freitag@suse.de> * 0007 * Jonathan Marten <jjm@keelhaul.me.uk> * 0008 * * 0009 * Kooka is free software; you can redistribute it and/or modify it * 0010 * under the terms of the GNU Library General Public License as * 0011 * published by the Free Software Foundation and appearing in the * 0012 * file COPYING included in the packaging of this file; either * 0013 * version 2 of the License, or (at your option) any later version. * 0014 * * 0015 * As a special exception, permission is given to link this program * 0016 * with any version of the KADMOS OCR/ICR engine (a product of * 0017 * reRecognition GmbH, Kreuzlingen), and distribute the resulting * 0018 * executable without including the source code for KADMOS in the * 0019 * source distribution. * 0020 * * 0021 * This program is distributed in the hope that it will be useful, * 0022 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0024 * GNU General Public License for more details. * 0025 * * 0026 * You should have received a copy of the GNU General Public * 0027 * License along with this program; see the file COPYING. If * 0028 * not, see <http://www.gnu.org/licenses/>. * 0029 * * 0030 ************************************************************************/ 0031 0032 #include "kookagallery.h" 0033 0034 #include <qlayout.h> 0035 #include <qlabel.h> 0036 0037 #include <klocalizedstring.h> 0038 0039 #include "scangallery.h" 0040 #include "galleryhistory.h" 0041 #include "kookasettings.h" 0042 #include "kooka_logging.h" 0043 0044 0045 KookaGallery::KookaGallery(QWidget *parent) 0046 : QWidget(parent) 0047 { 0048 qCDebug(KOOKA_LOG); 0049 m_layout = new QGridLayout(this); 0050 m_layout->setMargin(0); 0051 0052 m_recentBox = new QWidget(this); 0053 QHBoxLayout *hbl = new QHBoxLayout(m_recentBox); 0054 hbl->setMargin(0); 0055 0056 QLabel *lab = new QLabel(i18n("Folder:"), m_recentBox); 0057 lab->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); 0058 hbl->addWidget(lab); 0059 0060 m_galleryRecent = new GalleryHistory(m_recentBox); 0061 lab->setBuddy(m_galleryRecent); 0062 hbl->addWidget(m_galleryRecent); 0063 0064 m_galleryTree = new ScanGallery(this); 0065 0066 readSettings(); 0067 } 0068 0069 void KookaGallery::readSettings() 0070 { 0071 m_galleryTree->setAllowRename(KookaSettings::galleryAllowRename()); 0072 setLayout(static_cast<KookaGallery::Layout>(KookaSettings::galleryLayout())); 0073 } 0074 0075 ScanGallery *KookaGallery::galleryTree() const 0076 { 0077 return (m_galleryTree); 0078 } 0079 0080 GalleryHistory *KookaGallery::galleryRecent() const 0081 { 0082 return (m_galleryRecent); 0083 } 0084 0085 void KookaGallery::setLayout(KookaGallery::Layout option) 0086 { 0087 m_layout->removeWidget(m_galleryTree); 0088 m_layout->removeWidget(m_recentBox); 0089 0090 switch (option) { 0091 case KookaGallery::RecentAtTop: 0092 m_layout->addWidget(m_recentBox, 0, 0); 0093 m_layout->addWidget(m_galleryTree, 1, 0); 0094 break; 0095 0096 case KookaGallery::RecentAtBottom: 0097 m_layout->addWidget(m_galleryTree, 0, 0); 0098 m_layout->addWidget(m_recentBox, 1, 0); 0099 break; 0100 0101 case KookaGallery::NoRecent: 0102 m_layout->addWidget(m_galleryTree, 0, 0); 0103 break; 0104 } 0105 }