Working "add" dialog.
This commit is contained in:
		
							parent
							
								
									45ea9a68be
								
							
						
					
					
						commit
						5b0735bd68
					
				
					 16 changed files with 243 additions and 39 deletions
				
			
		|  | @ -335,7 +335,8 @@ HEADERS +=  src/core/feeddownloader.h \ | |||
|             src/services/inoreader/definitions.h \ | ||||
|             src/services/inoreader/inoreaderentrypoint.h \ | ||||
|             src/services/inoreader/network/inoreadernetworkfactory.h \ | ||||
|     src/services/inoreader/inoreaderserviceroot.h | ||||
|     src/services/inoreader/inoreaderserviceroot.h \ | ||||
|     src/services/inoreader/gui/formeditinoreaderaccount.h | ||||
| 
 | ||||
| SOURCES +=  src/core/feeddownloader.cpp \ | ||||
|             src/core/feedsmodel.cpp \ | ||||
|  | @ -460,7 +461,8 @@ SOURCES +=  src/core/feeddownloader.cpp \ | |||
|             src/miscellaneous/externaltool.cpp \ | ||||
|             src/services/inoreader/inoreaderentrypoint.cpp \ | ||||
|             src/services/inoreader/network/inoreadernetworkfactory.cpp \ | ||||
|     src/services/inoreader/inoreaderserviceroot.cpp | ||||
|     src/services/inoreader/inoreaderserviceroot.cpp \ | ||||
|     src/services/inoreader/gui/formeditinoreaderaccount.cpp | ||||
| 
 | ||||
| OBJECTIVE_SOURCES += src/miscellaneous/disablewindowtabbing.mm | ||||
| 
 | ||||
|  | @ -487,7 +489,8 @@ FORMS +=    src/gui/toolbareditor.ui \ | |||
|             src/gui/settings/settingsbrowsermail.ui \ | ||||
|             src/gui/settings/settingsfeedsmessages.ui \ | ||||
|             src/gui/settings/settingsdownloads.ui \ | ||||
|             src/services/tt-rss/gui/formeditttrssaccount.ui | ||||
|             src/services/tt-rss/gui/formeditttrssaccount.ui \ | ||||
|     src/services/inoreader/gui/formeditinoreaderaccount.ui | ||||
| 
 | ||||
| equals(USE_WEBENGINE, true) { | ||||
|   HEADERS +=    src/gui/locationlineedit.h \ | ||||
|  |  | |||
|  | @ -53,7 +53,7 @@ void FormAddAccount::addSelectedAccount() { | |||
|     m_model->addServiceAccount(new_root, true); | ||||
|   } | ||||
|   else { | ||||
|     qCritical("Cannot create new account."); | ||||
|     qWarning("Cannot create new account."); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										67
									
								
								src/services/inoreader/gui/formeditinoreaderaccount.cpp
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										67
									
								
								src/services/inoreader/gui/formeditinoreaderaccount.cpp
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,67 @@ | |||
| // This file is part of RSS Guard.
 | ||||
| 
 | ||||
| //
 | ||||
| // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
 | ||||
| //
 | ||||
| // RSS Guard is free software: you can redistribute it and/or modify
 | ||||
| // it under the terms of the GNU General Public License as published by
 | ||||
| // the Free Software Foundation, either version 3 of the License, or
 | ||||
| // (at your option) any later version.
 | ||||
| //
 | ||||
| // RSS Guard is distributed in the hope that it will be useful,
 | ||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | ||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | ||||
| // GNU General Public License for more details.
 | ||||
| //
 | ||||
| // You should have received a copy of the GNU General Public License
 | ||||
| // along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
 | ||||
| 
 | ||||
| #include "services/inoreader/gui/formeditinoreaderaccount.h" | ||||
| 
 | ||||
| #include "gui/guiutilities.h" | ||||
| #include "miscellaneous/application.h" | ||||
| #include "miscellaneous/iconfactory.h" | ||||
| #include "services/inoreader/inoreaderserviceroot.h" | ||||
| 
 | ||||
| FormEditInoreaderAccount::FormEditInoreaderAccount(QWidget* parent) : QDialog(parent), m_editableRoot(nullptr) { | ||||
|   m_ui.setupUi(this); | ||||
|   GuiUtilities::applyDialogProperties(*this, qApp->icons()->miscIcon(QSL("inoreader"))); | ||||
|   m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information, | ||||
|                                   tr("Not tested yet."), | ||||
|                                   tr("Not tested yet.")); | ||||
|   m_ui.m_lblTestResult->label()->setWordWrap(true); | ||||
| 
 | ||||
|   connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditInoreaderAccount::testSetup); | ||||
|   connect(&m_network, &InoreaderNetworkFactory::accessGranted, [this]() { | ||||
|     m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok, | ||||
|                                     tr("Tested successfully. You may be prompted to login once more."), | ||||
|                                     tr("Your access was approved.")); | ||||
|   }); | ||||
|   connect(&m_network, &InoreaderNetworkFactory::error, [this](const QString& err) { | ||||
|     m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error, | ||||
|                                     tr("There is error. %1").arg(err), | ||||
|                                     tr("There was error during testing.")); | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| FormEditInoreaderAccount::~FormEditInoreaderAccount() {} | ||||
| 
 | ||||
| void FormEditInoreaderAccount::testSetup() { | ||||
|   if (m_network.isLoggedIn()) { | ||||
|     m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information, | ||||
|                                     tr("Access granted successfully."), | ||||
|                                     tr("Access granted successfully.")); | ||||
|   } | ||||
|   else { | ||||
|     m_network.logIn(); | ||||
|     m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Progress, | ||||
|                                     tr("Requested access approval. Respond to it, please."), | ||||
|                                     tr("Access approval was requested via OAuth 2.0 protocol.")); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| InoreaderServiceRoot* FormEditInoreaderAccount::execForCreate() { | ||||
|   setWindowTitle(tr("Add new Inoreader account")); | ||||
|   exec(); | ||||
|   return m_editableRoot; | ||||
| } | ||||
							
								
								
									
										52
									
								
								src/services/inoreader/gui/formeditinoreaderaccount.h
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										52
									
								
								src/services/inoreader/gui/formeditinoreaderaccount.h
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,52 @@ | |||
| // This file is part of RSS Guard.
 | ||||
| 
 | ||||
| //
 | ||||
| // Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
 | ||||
| //
 | ||||
| // RSS Guard is free software: you can redistribute it and/or modify
 | ||||
| // it under the terms of the GNU General Public License as published by
 | ||||
| // the Free Software Foundation, either version 3 of the License, or
 | ||||
| // (at your option) any later version.
 | ||||
| //
 | ||||
| // RSS Guard is distributed in the hope that it will be useful,
 | ||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | ||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | ||||
| // GNU General Public License for more details.
 | ||||
| //
 | ||||
| // You should have received a copy of the GNU General Public License
 | ||||
| // along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
 | ||||
| 
 | ||||
| #ifndef FORMEDITINOREADERACCOUNT_H | ||||
| #define FORMEDITINOREADERACCOUNT_H | ||||
| 
 | ||||
| #include <QDialog> | ||||
| 
 | ||||
| #include "ui_formeditinoreaderaccount.h" | ||||
| 
 | ||||
| #include "services/inoreader/network/inoreadernetworkfactory.h" | ||||
| 
 | ||||
| namespace Ui { | ||||
|   class FormEditInoreaderAccount; | ||||
| } | ||||
| 
 | ||||
| class InoreaderServiceRoot; | ||||
| 
 | ||||
| class FormEditInoreaderAccount : public QDialog { | ||||
|   Q_OBJECT | ||||
| 
 | ||||
|   public: | ||||
|     explicit FormEditInoreaderAccount(QWidget* parent = 0); | ||||
|     virtual ~FormEditInoreaderAccount(); | ||||
| 
 | ||||
|     InoreaderServiceRoot* execForCreate(); | ||||
| 
 | ||||
|   private slots: | ||||
|     void testSetup(); | ||||
| 
 | ||||
|   private: | ||||
|     Ui::FormEditInoreaderAccount m_ui; | ||||
|     InoreaderNetworkFactory m_network; | ||||
|     InoreaderServiceRoot* m_editableRoot; | ||||
| }; | ||||
| 
 | ||||
| #endif // FORMEDITINOREADERACCOUNT_H
 | ||||
							
								
								
									
										99
									
								
								src/services/inoreader/gui/formeditinoreaderaccount.ui
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										99
									
								
								src/services/inoreader/gui/formeditinoreaderaccount.ui
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,99 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>FormEditInoreaderAccount</class> | ||||
|  <widget class="QDialog" name="FormEditInoreaderAccount"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>400</width> | ||||
|     <height>157</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
|    <string>Dialog</string> | ||||
|   </property> | ||||
|   <layout class="QGridLayout" name="gridLayout"> | ||||
|    <item row="1" column="0"> | ||||
|     <widget class="QDialogButtonBox" name="m_buttonBox"> | ||||
|      <property name="orientation"> | ||||
|       <enum>Qt::Horizontal</enum> | ||||
|      </property> | ||||
|      <property name="standardButtons"> | ||||
|       <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item row="0" column="0"> | ||||
|     <layout class="QFormLayout" name="formLayout"> | ||||
|      <item row="0" column="0"> | ||||
|       <widget class="QPushButton" name="m_btnTestSetup"> | ||||
|        <property name="text"> | ||||
|         <string>&Test login</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item row="0" column="1"> | ||||
|       <widget class="LabelWithStatus" name="m_lblTestResult" native="true"> | ||||
|        <property name="sizePolicy"> | ||||
|         <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> | ||||
|          <horstretch>0</horstretch> | ||||
|          <verstretch>0</verstretch> | ||||
|         </sizepolicy> | ||||
|        </property> | ||||
|        <property name="layoutDirection"> | ||||
|         <enum>Qt::RightToLeft</enum> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|   </layout> | ||||
|  </widget> | ||||
|  <customwidgets> | ||||
|   <customwidget> | ||||
|    <class>LabelWithStatus</class> | ||||
|    <extends>QWidget</extends> | ||||
|    <header>labelwithstatus.h</header> | ||||
|    <container>1</container> | ||||
|   </customwidget> | ||||
|  </customwidgets> | ||||
|  <tabstops> | ||||
|   <tabstop>m_btnTestSetup</tabstop> | ||||
|  </tabstops> | ||||
|  <resources/> | ||||
|  <connections> | ||||
|   <connection> | ||||
|    <sender>m_buttonBox</sender> | ||||
|    <signal>accepted()</signal> | ||||
|    <receiver>FormEditInoreaderAccount</receiver> | ||||
|    <slot>accept()</slot> | ||||
|    <hints> | ||||
|     <hint type="sourcelabel"> | ||||
|      <x>248</x> | ||||
|      <y>254</y> | ||||
|     </hint> | ||||
|     <hint type="destinationlabel"> | ||||
|      <x>157</x> | ||||
|      <y>274</y> | ||||
|     </hint> | ||||
|    </hints> | ||||
|   </connection> | ||||
|   <connection> | ||||
|    <sender>m_buttonBox</sender> | ||||
|    <signal>rejected()</signal> | ||||
|    <receiver>FormEditInoreaderAccount</receiver> | ||||
|    <slot>reject()</slot> | ||||
|    <hints> | ||||
|     <hint type="sourcelabel"> | ||||
|      <x>316</x> | ||||
|      <y>260</y> | ||||
|     </hint> | ||||
|     <hint type="destinationlabel"> | ||||
|      <x>286</x> | ||||
|      <y>274</y> | ||||
|     </hint> | ||||
|    </hints> | ||||
|   </connection> | ||||
|  </connections> | ||||
| </ui> | ||||
|  | @ -23,14 +23,14 @@ | |||
| #include "miscellaneous/databasequeries.h" | ||||
| #include "miscellaneous/iconfactory.h" | ||||
| #include "services/inoreader/definitions.h" | ||||
| #include "services/inoreader/gui/formeditinoreaderaccount.h" | ||||
| #include "services/inoreader/inoreaderserviceroot.h" | ||||
| #include "services/inoreader/network/inoreadernetworkfactory.h" | ||||
| 
 | ||||
| InoreaderEntryPoint::InoreaderEntryPoint() {} | ||||
| 
 | ||||
| InoreaderEntryPoint::~InoreaderEntryPoint() {} | ||||
| 
 | ||||
| ServiceRoot* InoreaderEntryPoint::createNewRoot() const { | ||||
|   return nullptr; | ||||
|   FormEditInoreaderAccount form_acc(qApp->mainFormWidget()); | ||||
| 
 | ||||
|   return form_acc.execForCreate(); | ||||
| } | ||||
| 
 | ||||
| QList<ServiceRoot*> InoreaderEntryPoint::initializeSubtree() const { | ||||
|  |  | |||
|  | @ -23,9 +23,6 @@ | |||
| 
 | ||||
| class InoreaderEntryPoint : public ServiceEntryPoint { | ||||
|   public: | ||||
|     explicit InoreaderEntryPoint(); | ||||
|     virtual ~InoreaderEntryPoint(); | ||||
| 
 | ||||
|     ServiceRoot* createNewRoot() const; | ||||
| 
 | ||||
|     QList<ServiceRoot*> initializeSubtree() const; | ||||
|  |  | |||
|  | @ -76,12 +76,14 @@ void InoreaderNetworkFactory::initializeOauth() { | |||
|   }); | ||||
|   connect(&m_oauth2, &QOAuth2AuthorizationCodeFlow::granted, [=]() { | ||||
|     qDebug("Inoreader: Oauth2 granted."); | ||||
|     emit accessGranted(); | ||||
|   }); | ||||
|   connect(&m_oauth2, &QOAuth2AuthorizationCodeFlow::error, [](const QString& error, const QString& error_description, const QUrl& uri) { | ||||
|     Q_UNUSED(error) | ||||
|   connect(&m_oauth2, &QOAuth2AuthorizationCodeFlow::error, [=](QString err, QString error_description, QUrl uri) { | ||||
|     Q_UNUSED(err) | ||||
|     Q_UNUSED(uri) | ||||
| 
 | ||||
|     qCritical("Inoreader: We have error: '%s'.", qPrintable(error_description)); | ||||
|     emit error(error_description); | ||||
|   }); | ||||
|   connect(&m_oauth2, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, [](const QUrl& url) { | ||||
|     qApp->web()->openUrlInExternalBrowser(url.toString()); | ||||
|  |  | |||
|  | @ -35,6 +35,10 @@ class InoreaderNetworkFactory : public QObject { | |||
|     void logIn(); | ||||
|     void logInIfNeeded(); | ||||
| 
 | ||||
|   signals: | ||||
|     void accessGranted(); | ||||
|     void error(QString& description); | ||||
| 
 | ||||
|   private: | ||||
|     void initializeOauth(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -95,12 +95,14 @@ OwnCloudServiceRoot* FormEditOwnCloudAccount::execForCreate() { | |||
| 
 | ||||
| void FormEditOwnCloudAccount::execForEdit(OwnCloudServiceRoot* existing_root) { | ||||
|   setWindowTitle(tr("Edit existing ownCloud News account")); | ||||
| 
 | ||||
|   m_editableRoot = existing_root; | ||||
|   m_ui->m_txtUsername->lineEdit()->setText(existing_root->network()->authUsername()); | ||||
|   m_ui->m_txtPassword->lineEdit()->setText(existing_root->network()->authPassword()); | ||||
|   m_ui->m_txtUrl->lineEdit()->setText(existing_root->network()->url()); | ||||
|   m_ui->m_checkServerSideUpdate->setChecked(existing_root->network()->forceServerSideUpdate()); | ||||
|   m_ui->m_spinLimitMessages->setValue(existing_root->network()->batchSize()); | ||||
| 
 | ||||
|   exec(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -26,10 +26,6 @@ | |||
| #include "services/owncloud/gui/formeditowncloudaccount.h" | ||||
| #include "services/owncloud/owncloudserviceroot.h" | ||||
| 
 | ||||
| OwnCloudServiceEntryPoint::OwnCloudServiceEntryPoint() {} | ||||
| 
 | ||||
| OwnCloudServiceEntryPoint::~OwnCloudServiceEntryPoint() {} | ||||
| 
 | ||||
| ServiceRoot* OwnCloudServiceEntryPoint::createNewRoot() const { | ||||
|   FormEditOwnCloudAccount form_acc(qApp->mainFormWidget()); | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,9 +23,6 @@ | |||
| 
 | ||||
| class OwnCloudServiceEntryPoint : public ServiceEntryPoint { | ||||
|   public: | ||||
|     explicit OwnCloudServiceEntryPoint(); | ||||
|     virtual ~OwnCloudServiceEntryPoint(); | ||||
| 
 | ||||
|     ServiceRoot* createNewRoot() const; | ||||
| 
 | ||||
|     QList<ServiceRoot*> initializeSubtree() const; | ||||
|  |  | |||
|  | @ -23,10 +23,6 @@ | |||
| #include "miscellaneous/databasequeries.h" | ||||
| #include "services/standard/standardserviceroot.h" | ||||
| 
 | ||||
| StandardServiceEntryPoint::StandardServiceEntryPoint() {} | ||||
| 
 | ||||
| StandardServiceEntryPoint::~StandardServiceEntryPoint() {} | ||||
| 
 | ||||
| bool StandardServiceEntryPoint::isSingleInstanceService() const { | ||||
|   return true; | ||||
| } | ||||
|  |  | |||
|  | @ -23,9 +23,6 @@ | |||
| 
 | ||||
| class StandardServiceEntryPoint : public ServiceEntryPoint { | ||||
|   public: | ||||
|     explicit StandardServiceEntryPoint(); | ||||
|     virtual ~StandardServiceEntryPoint(); | ||||
| 
 | ||||
|     bool isSingleInstanceService() const; | ||||
|     QString name() const; | ||||
|     QString description() const; | ||||
|  |  | |||
|  | @ -25,12 +25,6 @@ | |||
| #include "services/tt-rss/gui/formeditttrssaccount.h" | ||||
| #include "services/tt-rss/ttrssserviceroot.h" | ||||
| 
 | ||||
| #include <QPointer> | ||||
| 
 | ||||
| TtRssServiceEntryPoint::TtRssServiceEntryPoint() {} | ||||
| 
 | ||||
| TtRssServiceEntryPoint::~TtRssServiceEntryPoint() {} | ||||
| 
 | ||||
| bool TtRssServiceEntryPoint::isSingleInstanceService() const { | ||||
|   return false; | ||||
| } | ||||
|  | @ -59,8 +53,9 @@ QString TtRssServiceEntryPoint::code() const { | |||
| } | ||||
| 
 | ||||
| ServiceRoot* TtRssServiceEntryPoint::createNewRoot() const { | ||||
|   QScopedPointer<FormEditTtRssAccount> form_acc(new FormEditTtRssAccount(qApp->mainFormWidget())); | ||||
|   return form_acc->execForCreate(); | ||||
|   FormEditTtRssAccount form_acc(qApp->mainFormWidget()); | ||||
| 
 | ||||
|   return form_acc.execForCreate(); | ||||
| } | ||||
| 
 | ||||
| QList<ServiceRoot*> TtRssServiceEntryPoint::initializeSubtree() const { | ||||
|  |  | |||
|  | @ -23,9 +23,6 @@ | |||
| 
 | ||||
| class TtRssServiceEntryPoint : public ServiceEntryPoint { | ||||
|   public: | ||||
|     explicit TtRssServiceEntryPoint(); | ||||
|     virtual ~TtRssServiceEntryPoint(); | ||||
| 
 | ||||
|     bool isSingleInstanceService() const; | ||||
|     QString name() const; | ||||
|     QString description() const; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue