| 1 |
/* |
| 2 |
* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd. |
| 3 |
* |
| 4 |
* Author: ZhangYong <[email protected]> |
| 5 |
* |
| 6 |
* Maintainer: ZhangYong <[email protected]> |
| 7 |
* |
| 8 |
* This program is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
#ifndef CEXPORTIMAGEDIALOG_H |
| 22 |
#define CEXPORTIMAGEDIALOG_H |
| 23 |
|
| 24 |
|
| 25 |
#include <DWidget> |
| 26 |
#include <DDialog> |
| 27 |
#include <DLineEdit> |
| 28 |
#include <DComboBox> |
| 29 |
#include <DLabel> |
| 30 |
#include <DSlider> |
| 31 |
|
| 32 |
#include "controller/signalmanager.h" |
| 33 |
#include "application.h" |
| 34 |
|
| 35 |
DWIDGET_USE_NAMESPACE |
| 36 |
|
| 37 |
class CExportImageDialog : public DDialog |
| 38 |
{ |
| 39 |
Q_OBJECT |
| 40 |
public: |
| 41 |
enum ESaveFormat { |
| 42 |
JPG, |
| 43 |
JPEG, |
| 44 |
PNG, |
| 45 |
BMP, |
| 46 |
PGM, |
| 47 |
XBM, |
| 48 |
XPM |
| 49 |
}; |
| 50 |
enum ESavePath { |
| 51 |
Pictures, |
| 52 |
Documents, |
| 53 |
Downloads, |
| 54 |
Desktop, |
| 55 |
Videos, |
| 56 |
Music, |
| 57 |
UsrSelect, |
| 58 |
Other |
| 59 |
}; |
| 60 |
|
| 61 |
public: |
| 62 |
explicit CExportImageDialog(DWidget *parent = nullptr); |
| 63 |
~CExportImageDialog() override; |
| 64 |
void showMe(const QPixmap &pixmap); |
| 65 |
// int getImageType() const; |
| 66 |
// QString getSavePath() const; |
| 67 |
// QString getImageFormate() const; |
| 68 |
// int getQuality() const; |
| 69 |
void setPicFileName(QString strFileName); |
| 70 |
void setGifType(const QString &strFilePath); |
| 71 |
void removeGifType(); |
| 72 |
void showEvent(QShowEvent *evet) override; |
| 73 |
void keyPressEvent(QKeyEvent *e) override; |
| 74 |
void showQuestionDialog(const QString &path, const QString &srcpath = ""); |
| 75 |
void showDirChoseDialog(); |
| 76 |
void showEmptyWarningDialog(); |
| 77 |
private slots: |
| 78 |
void slotOnSavePathChange(int index); |
| 79 |
void slotOnFormatChange(int index); |
| 80 |
void slotOnDialogButtonClick(int index, const QString &text); |
| 81 |
void slotOnQuestionDialogButtonClick(int index, const QString &text); |
| 82 |
void slotOnEmptyWarningDialogButtonClick(int, const QString &); |
| 83 |
void slotOnQualityChanged(int value); |
| 84 |
|
| 85 |
private: |
| 86 |
DLineEdit *m_fileNameEdit; |
| 87 |
DComboBox *m_savePathCombox; |
| 88 |
DComboBox *m_formatCombox; |
| 89 |
DSlider *m_qualitySlider; |
| 90 |
DLabel *m_qualityLabel; |
| 91 |
|
| 92 |
// QString m_fileName; |
| 93 |
QString m_savePath; |
| 94 |
QString m_saveFormat; |
| 95 |
int m_quality; |
| 96 |
|
| 97 |
DDialog *m_questionDialog; |
| 98 |
DDialog *m_emptyWarningDialog; |
| 99 |
QPixmap m_saveImage; |
| 100 |
QString gifpath; |
| 101 |
|
| 102 |
private: |
| 103 |
void initUI(); |
| 104 |
void initConnection(); |
| 105 |
bool doSave(); |
| 106 |
}; |
| 107 |
|
| 108 |
#endif // CEXPORTIMAGEDIALOG_H |