Subversion Repositories Scribus

Rev

Rev 24515 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5715 tsoots 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
7
// kk2006
8
 
10182 jghali 9
#include <QObject>
10
#include <QHBoxLayout>
5715 tsoots 11
 
24670 craig 12
#include "scgtplugin.h"
5715 tsoots 13
 
23210 craig 14
ScGTPluginManager* ScGTPluginManager::m_instance = nullptr; // init static variables
5715 tsoots 15
 
23210 craig 16
ScGTPluginManager::ScGTPluginManager() = default;
5715 tsoots 17
 
18
ScGTPluginManager* ScGTPluginManager::instance()
19
{
23210 craig 20
        if (!ScGTPluginManager::m_instance)
21
                m_instance = new ScGTPluginManager();
5715 tsoots 22
 
23210 craig 23
        return m_instance;
5715 tsoots 24
}
25
 
26
void ScGTPluginManager::deleteInstance()
27
{
23210 craig 28
        delete m_instance;
29
        m_instance = nullptr;
5715 tsoots 30
}
31
 
32
void ScGTPluginManager::registerGTPlugin(ScGTPlugin *plugin)
33
{
34
        if (plugin)
23210 craig 35
                m_plugins.append(plugin);
5715 tsoots 36
}
37
 
38
void ScGTPluginManager::unRegisterGTPlugin(ScGTPlugin *plugin)
39
{
23210 craig 40
        m_plugins.removeAll(plugin);
5715 tsoots 41
}
42
 
43
void ScGTPluginManager::run()
44
{
45
        // TODO prefs
22607 craig 46
        ScGTFileDialog *dia = new ScGTFileDialog(".", fileFilter(), nullptr, "dia");
5715 tsoots 47
        if (dia->exec())
48
        {
49
 
50
        }
51
        delete dia;
52
}
53
 
54
QString ScGTPluginManager::fileFilter()
55
{
23210 craig 56
        QString filters;
5715 tsoots 57
        QString allSupported = QObject::tr("All Supported Formats") + " (";
23210 craig 58
        for (int i = 0; i < m_plugins.count(); ++i)
5715 tsoots 59
        {
23210 craig 60
                if (m_plugins.at(i)->fileExtensions().count() != 0)
5715 tsoots 61
                {
23210 craig 62
                        filters += m_plugins.at(i)->fileFormatName() + " (";
63
                        QStringList fileExtensions = m_plugins.at(i)->fileExtensions();
8545 cbradney 64
                        for (int j = 0; j < fileExtensions.count(); ++j)
5715 tsoots 65
                        {
66
                                filters += "*." + fileExtensions[j] + " ";
67
                                allSupported += "*." + fileExtensions[j] + " ";
68
                        }
10394 cbradney 69
                        filters = filters.trimmed();
5715 tsoots 70
                        filters += ");;";
71
                }
72
        }
10394 cbradney 73
        allSupported = allSupported.trimmed();
5715 tsoots 74
        allSupported += ");;";
75
        filters = allSupported + filters;
76
        filters += QObject::tr("All Files (*)");
77
 
78
        return filters;
79
}
80
 
81
void ScGTPluginManager::options()
82
{
83
 
84
}
85
 
23210 craig 86
ScGTPluginManager::~ScGTPluginManager() = default;
5715 tsoots 87
 
88
/***************************************************************************************/
89
/***************************************************************************************/
90
 
23210 craig 91
ScGTFileDialog::ScGTFileDialog(const QString& dirName,
92
                                                           const QString& filters,
5715 tsoots 93
                               QWidget * parent, const char * name)
5867 tsoots 94
: CustomFDialog(parent, dirName, tr("Select a file to import"), filters)
5715 tsoots 95
{
96
        customize();
97
}
98
 
99
bool ScGTFileDialog::showOptions() const
100
{
23210 craig 101
        return m_showOptionsBox->isChecked();
5715 tsoots 102
}
103
 
5867 tsoots 104
bool ScGTFileDialog::append() const
105
{
23210 craig 106
        return m_appendBox->isChecked();
5867 tsoots 107
}
108
 
5715 tsoots 109
void ScGTFileDialog::customize()
110
{
23210 craig 111
        m_diaExtension = new QWidget(this);
112
        m_diaExtension->setObjectName("diaExtension_");
5867 tsoots 113
 
23210 craig 114
        m_appendBox = new QCheckBox( tr("Append"), m_diaExtension);
115
        m_appendBox->setObjectName("appendBox_");
116
        m_showOptionsBox = new QCheckBox( tr("Show options"), m_diaExtension);
117
        m_showOptionsBox->setObjectName("showOptionsBox_");
5867 tsoots 118
 
10182 jghali 119
        QHBoxLayout *layout = new QHBoxLayout;
24515 jghali 120
        layout->setSpacing(6);
23210 craig 121
        layout->addWidget(m_appendBox);
122
        layout->addWidget(m_showOptionsBox);
10182 jghali 123
 
23210 craig 124
        m_diaExtension->setLayout(layout);
10182 jghali 125
 
23210 craig 126
        addWidgets(m_diaExtension);
5715 tsoots 127
}
128
 
129
ScGTFileDialog::~ScGTFileDialog()
130
{
23210 craig 131
        delete m_showOptionsBox;
132
        delete m_appendBox;
133
        delete m_diaExtension;
5715 tsoots 134
}
135
 
136
/***************************************************************************************/
137
/***************************************************************************************/
138
 
139
 
140