~arcachofo/simulide/1.1.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/***************************************************************************
 *   Copyright (C) 2012 by Santiago González                               *
 *                                                                         *
 ***( see copyright.txt file at root folder )*******************************/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDir>

class ComponentSelector;
class CircuitWidget;
class EditorWindow;
class FileWidget;
class QVBoxLayout;
class QLineEdit;
class QSplitter;
class QSettings;

enum Langs {
    English = 0,
    Chinese,
    Czech,
    Dutch,
    French,
    German,
    Italian,
    Russian,
    Spanish,
    Portuguese,
    Pt_Brasil,
    Slovak,
    Turkish
};

class MainWindow : public QMainWindow
{
    Q_OBJECT

    public:
        MainWindow();
        ~MainWindow();

 static MainWindow* self() { return m_pSelf; }

        QSettings* settings();
        QSettings* compSettings();
        
        void readSettings();
        
        void setFile( QString file );
        void setState( QString state );

        QString loc();
        void setLoc( QString loc );

        Langs lang() { return m_lang; }
        void setLang( Langs lang );

        void setDefaultFontName( const QString& fontName );
        QString defaultFontName() { return m_fontName; }
        
        float fontScale() { return m_fontScale; }
        void setFontScale( float scale )  { m_fontScale = scale; }

        int autoBck() { return m_autoBck; }
        void setAutoBck( int secs ) { m_autoBck = secs; }

        int revision() { return m_revision; }

        QString getHelp( QString name, bool save=true );

        QString getFilePath( QString file );              // Get file path in SimulIDE folders
        QString getConfigPath( QString file );            // Get file path in config folder
        QString getDataFilePath( QString file );          // Get file path in data folder, first user folder, if not SimulIDE folder
        QString getUserFilePath( QString f );             // Get file path in user folder
        QString userPath() { return m_userDir; }          // User folder path
        void setUserPath( QString p );
        void getUserPath();                               // File open Dialog
        
        QTabWidget* m_sidepanel;

    protected:
        void closeEvent( QCloseEvent* event );

    private slots:
        void searchChanged();

    private:
 static MainWindow* m_pSelf;

        Langs m_lang;

        bool m_blocked;

        void createWidgets();
        void createMenus();
        void createToolBars();
        void writeSettings();
        
        QString m_fontName;
        float m_fontScale;
        int m_autoBck;
        
        QDir m_filesDir;
        QDir m_configDir;

        QSettings* m_settings;
        QSettings* m_compSettings;
        
        int m_revision;
        QString m_version;
        QString m_styleSheet;
        QString m_state;
        QString m_file;
        QString m_userDir;

        QHash<QString, QString> m_help;
        
        CircuitWidget* m_circuit;
        ComponentSelector* m_components;
        QWidget*      m_componentWidget;
        QVBoxLayout*  m_componentWidgetLayout;
        QLineEdit*    m_searchComponent;
        EditorWindow* m_editor;
        
        QSplitter*  m_Centralsplitter;
        FileWidget* m_fileSystemTree;
};

#endif