File indexing completed on 2025-01-05 03:53:30
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2013-11-18 0007 * Description : a tool to export items to Google web services 0008 * 0009 * SPDX-FileCopyrightText: 2013 by Pankaj Kumar <me at panks dot me> 0010 * SPDX-FileCopyrightText: 2013-2020 by Caulier Gilles <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "gswidget.h" 0017 0018 // Qt includes 0019 0020 #include <QLabel> 0021 #include <QSpinBox> 0022 #include <QCheckBox> 0023 #include <QGroupBox> 0024 #include <QRadioButton> 0025 #include <QButtonGroup> 0026 #include <QGridLayout> 0027 #include <QHBoxLayout> 0028 #include <QVBoxLayout> 0029 #include <QPushButton> 0030 #include <QApplication> 0031 #include <QComboBox> 0032 0033 // KDE includes 0034 0035 #include <klocalizedstring.h> 0036 0037 namespace DigikamGenericGoogleServicesPlugin 0038 { 0039 0040 GSWidget::GSWidget(QWidget* const parent, 0041 DInfoInterface* const iface, 0042 const GoogleService& service, 0043 const QString& serviceName) 0044 : WSSettingsWidget(parent, iface, serviceName), 0045 m_service (service), 0046 m_tagsBGrp (nullptr) 0047 { 0048 QGroupBox* const leafBox = new QGroupBox(QLatin1String(""), getSettingsBox()); 0049 0050 if (m_service == GoogleService::GPhotoExport) 0051 { 0052 QGridLayout* leafLayout = new QGridLayout(leafBox); 0053 m_tagsBGrp = new QButtonGroup(leafBox); 0054 QSpacerItem* const spacer = new QSpacerItem(1, 10, QSizePolicy::Expanding, QSizePolicy::Minimum); 0055 QLabel* const tagsLbl = new QLabel(i18n("Tag path behavior :"), leafBox); 0056 0057 QRadioButton* const leafTagsBtn = new QRadioButton(i18n("Leaf tags only"), leafBox); 0058 leafTagsBtn->setWhatsThis(i18n("Export only the leaf tags of tag hierarchies")); 0059 QRadioButton* const splitTagsBtn = new QRadioButton(i18n("Split tags"), leafBox); 0060 splitTagsBtn->setWhatsThis(i18n("Export the leaf tag and all ancestors as single tags.")); 0061 QRadioButton* const combinedTagsBtn = new QRadioButton(i18n("Combined String"), leafBox); 0062 combinedTagsBtn->setWhatsThis(i18n("Build a combined tag string.")); 0063 0064 m_tagsBGrp->addButton(leafTagsBtn, GPTagLeaf); 0065 m_tagsBGrp->addButton(splitTagsBtn, GPTagSplit); 0066 m_tagsBGrp->addButton(combinedTagsBtn, GPTagCombined); 0067 0068 leafLayout->addItem(spacer, 0, 1, 1, 1); 0069 leafLayout->addWidget(tagsLbl, 1, 1, 1, 1); 0070 leafLayout->addWidget(leafTagsBtn, 2, 1, 1, 1); 0071 leafLayout->addWidget(splitTagsBtn, 3, 1, 1, 1); 0072 leafLayout->addWidget(combinedTagsBtn, 4, 1, 1, 1); 0073 0074 addWidgetToSettingsBox(leafBox); 0075 } 0076 0077 switch (m_service) 0078 { 0079 case GoogleService::GPhotoImport: 0080 getNewAlbmBtn()->hide(); 0081 getOptionsBox()->hide(); 0082 imagesList()->hide(); 0083 leafBox->hide(); 0084 getSizeBox()->hide(); // (Trung) Hide this option temporary, until factorization 0085 break; 0086 0087 case GoogleService::GDrive: 0088 getOriginalCheckBox()->show(); 0089 getUploadBox()->hide(); 0090 getSizeBox()->hide(); 0091 leafBox->hide(); 0092 break; 0093 0094 default: 0095 getOriginalCheckBox()->show(); 0096 getUploadBox()->hide(); 0097 getSizeBox()->hide(); 0098 leafBox->hide(); // Google has removed this function in the current API V3. 0099 getPhotoIdCheckBox()->show(); 0100 break; 0101 } 0102 } 0103 0104 GSWidget::~GSWidget() 0105 { 0106 } 0107 0108 void GSWidget::updateLabels(const QString& name, const QString& url) 0109 { 0110 switch (m_service) 0111 { 0112 case GoogleService::GDrive: 0113 { 0114 QString web(QLatin1String("https://drive.google.com")); 0115 getHeaderLbl()->setText(QString::fromLatin1( 0116 "<b><h2><a href='%1'>" 0117 "<font color=\"#9ACD32\">Google Drive</font>" 0118 "</a></h2></b>").arg(web)); 0119 break; 0120 } 0121 0122 default: 0123 { 0124 getHeaderLbl()->setText(QString::fromLatin1( 0125 "<b><h2><a href='https://photos.google.com/%1'>" 0126 "<font color=\"#9ACD32\">Google Photos</font>" 0127 "</a></h2></b>").arg(url)); 0128 break; 0129 } 0130 } 0131 0132 if (name.isEmpty()) 0133 { 0134 getUserNameLabel()->clear(); 0135 } 0136 else 0137 { 0138 getUserNameLabel()->setText(QString::fromLatin1("<b>%1</b>").arg(name)); 0139 } 0140 } 0141 0142 } // namespace DigikamGenericGoogleServicesPlugin 0143 0144 #include "moc_gswidget.cpp"