1 //=========================================== 2 // Lumina-DE source code 3 // Copyright (c) 2014, Ken Moore 4 // Available under the 3-clause BSD license 5 // See the LICENSE file for full details 6 //=========================================== 7 // This plugin is a simple text editor for notes on the desktop 8 //=========================================== 9 #ifndef _LUMINA_DESKTOP_NOTEPAD_PLUGIN_H 10 #define _LUMINA_DESKTOP_NOTEPAD_PLUGIN_H 11 12 #include <QPlainTextEdit> 13 #include <QToolButton> 14 #include <QComboBox> 15 #include <QVBoxLayout> 16 #include <QTimer> 17 #include <QFileSystemWatcher> 18 #include "../LDPlugin.h" 19 20 class NotePadPlugin : public LDPlugin{ 21 Q_OBJECT 22 public: 23 NotePadPlugin(QWidget* parent, QString ID); 24 ~NotePadPlugin(); 25 defaultPluginSize()26 virtual QSize defaultPluginSize(){ 27 // The returned QSize is in grid points (typically 100 or 200 pixels square) 28 return QSize(3,3); 29 } 30 private: 31 QPlainTextEdit *edit; 32 QToolButton *config; // *open, *add, *rem; 33 QComboBox *cnote; 34 QFrame *frame; 35 QFileSystemWatcher *watcher; 36 bool updating; 37 QTimer *typeTimer; 38 39 void openNote(); 40 QString newNoteName(QString oldname = "", bool tryagain = false); 41 42 private slots: 43 void updateConfigMenu(); 44 45 void openNoteClicked(); 46 void newNoteClicked(); 47 void remNote(); 48 void renameNote(); 49 void newTextAvailable(); 50 void updateContents(); 51 52 void notesDirChanged(); 53 void noteChanged(); 54 55 void loadIcons(); 56 void showContextMenuForEdit(const QPoint &pos); 57 void resetContextMenu(); 58 59 public slots: LocaleChange()60 void LocaleChange(){ 61 QTimer::singleShot(0,this, SLOT(noteChanged())); 62 } ThemeChange()63 void ThemeChange(){ 64 QTimer::singleShot(0,this, SLOT(loadIcons())); 65 } 66 67 }; 68 #endif 69