File indexing completed on 2019-07-28 10:35:11

0001 /*
0002     This file is part of Choqok, the KDE micro-blogging client
0003 
0004     Copyright (C) 2008-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
0005 
0006     This program is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU General Public License as
0008     published by the Free Software Foundation; either version 2 of
0009     the License or (at your option) version 3 or any later version
0010     accepted by the membership of KDE e.V. (or its successor approved
0011     by the membership of KDE e.V.), which shall act as a proxy
0012     defined in Section 14 of version 3 of the license.
0013 
0014     This program is distributed in the hope that it will be useful,
0015     but WITHOUT ANY WARRANTY; without even the implied warranty of
0016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0017     GNU General Public License for more details.
0018 
0019     You should have received a copy of the GNU General Public License
0020     along with this program; if not, see http://www.gnu.org/licenses/
0021 
0022 */
0023 #ifndef QUICKPOST_H
0024 #define QUICKPOST_H
0025 
0026 #include <QDialog>
0027 
0028 #include "account.h"
0029 #include "choqoktypes.h"
0030 #include "microblog.h"
0031 
0032 namespace Choqok
0033 {
0034 namespace UI
0035 {
0036 
0037 /**
0038 Widget for Quick posting
0039 
0040     @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\>
0041 */
0042 class CHOQOK_EXPORT QuickPost : public QDialog
0043 {
0044     Q_OBJECT
0045 public:
0046     QuickPost(QWidget *parent = nullptr);
0047     virtual ~QuickPost();
0048 
0049 public Q_SLOTS:
0050     void show();
0051     void submitPost(const QString &newStatus);
0052     void setText(const QString &text);
0053     void appendText(const QString &text);
0054 
0055 Q_SIGNALS:
0056     /**
0057     Emitted when a new post submitted. @p postText is the text that submitted,
0058     @p postText will be empty on failure!
0059 
0060     @param result Result of posting, Could be Success or Fail
0061     */
0062     void newPostSubmitted(Choqok::JobResult result, Choqok::Post *newPost = nullptr);
0063 
0064 protected:
0065     void loadAccounts();
0066 
0067 protected Q_SLOTS:
0068     void slotAttachMedium();
0069     void slotCurrentAccountChanged(int);
0070     void checkAll(bool isAll);
0071     virtual void accept() override;
0072     void addAccount(Choqok::Account *account);
0073     void removeAccount(const QString &alias);
0074     void accountModified(Choqok::Account *theAccount);
0075     virtual void slotSubmitPost(Choqok::Account *theAccount, Choqok::Post *post);
0076     void postError(Choqok::Account *theAccount, Choqok::Post *post,
0077                    Choqok::MicroBlog::ErrorType error, const QString &errorMessage);
0078 
0079 private:
0080     void setupUi();
0081     class Private;
0082     Private *const d;
0083 };
0084 
0085 }
0086 
0087 }
0088 #endif