diff --git a/TODO.md b/TODO.md index e2aee1b..107873a 100644 --- a/TODO.md +++ b/TODO.md @@ -80,7 +80,7 @@ Tasks for v0.0.1 1. ~~Quick jump inside open files~~ 1. ~~Save zoom level per document~~ 1. ~~File watcher on created file not stopped while saving~~ -1. Control+N should open a new tab. +1. ~~Control+N should open a new tab.~~ 1. ~~Line ending on save (Unix/Windows/Keep original)~~~ 1. ~~Trim spaces on save (edit?)~~ 1. ~~Add line/column to margin display~~ diff --git a/src/main.cpp b/src/main.cpp index 861f5ec..3ace4dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "pluginmanager.h" #include "plugins/ProjectManager/ProjectManagerPlg.h" @@ -69,10 +70,13 @@ int main(int argc, char *argv[]) { auto filePath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); auto iniFilePath = filePath + "/qtedit4.ini"; auto windowIcon = QIcon(":qtedit4.ico"); + + auto textEditorPlugin = new TextEditorPlugin; + pluginManager.setWindowTitle("qtedit4"); pluginManager.setWindowIcon(windowIcon); pluginManager.setFileSettingsManager(iniFilePath); - pluginManager.addPlugin(new TextEditorPlugin); + pluginManager.addPlugin(textEditorPlugin); pluginManager.addPlugin(new FileSystemBrowserPlugin); pluginManager.addPlugin(new HelpPlugin); pluginManager.addPlugin(new ProjectManagerPlugin); @@ -83,6 +87,9 @@ int main(int argc, char *argv[]) { pluginManager.restoreSettings(); pluginManager.show(); + pluginManager.connect(&pluginManager, &PluginManager::newFileRequested, + [textEditorPlugin]() { textEditorPlugin->fileNew(); }); + pluginManager.openFiles(parser.positionalArguments()); return app.exec(); } diff --git a/src/plugins/texteditor/texteditor_plg.cpp b/src/plugins/texteditor/texteditor_plg.cpp index d2e2215..9037386 100644 --- a/src/plugins/texteditor/texteditor_plg.cpp +++ b/src/plugins/texteditor/texteditor_plg.cpp @@ -45,14 +45,6 @@ TextEditorPlugin::TextEditorPlugin() { autoEnabled = true; alwaysEnabled = false; - actionNewFile = new QAction(tr("New blank file"), this); - actionNewCPP = new QAction(tr("New source"), this); - actionNewHeader = new QAction(tr("New header"), this); - myNewActions = new QActionGroup(this); - myNewActions->addAction(actionNewFile); - myNewActions->addAction(actionNewCPP); - myNewActions->addAction(actionNewHeader); - /* #if defined(WIN32) auto installPrefix = QCoreApplication::applicationDirPath(); @@ -61,10 +53,8 @@ TextEditorPlugin::TextEditorPlugin() { #endif */ - connect(myNewActions, &QActionGroup::triggered, this, &TextEditorPlugin::fileNew); - - config.pluginName = "Text editor"; - config.description = "Default text editor, based on QutePart"; + config.pluginName = tr("Text editor"); + config.description = tr("Default text editor, based on QutePart"); config.configItems.push_back(qmdiConfigItem::Builder() .setDisplayName(tr("Trim spaces")) .setDescription(tr("Remove spaces from end of lines, on save")) @@ -144,8 +134,6 @@ void TextEditorPlugin::showAbout() { "This plugin gives a QtSourceView based text editor"); } -QActionGroup *TextEditorPlugin::newFileActions() { return myNewActions; } - QStringList TextEditorPlugin::myExtensions() { auto s = QStringList(); s << tr("Sources", "EditorPlugin::myExtensions") + " (*.c *.cpp *.cxx *.h *.hpp *.hxx *.inc)"; @@ -157,6 +145,9 @@ QStringList TextEditorPlugin::myExtensions() { } int TextEditorPlugin::canOpenFile(const QString fileName) { + if (fileName.isEmpty()) { + return 5; + } auto u = QUrl(fileName); // if the scheme is a single line, lets assume this is a windows drive @@ -260,7 +251,7 @@ void TextEditorPlugin::configurationHasBeenModified() { } } -void TextEditorPlugin::fileNew(QAction *) { +void TextEditorPlugin::fileNew() { auto editor = new qmdiEditor(dynamic_cast(mdiServer)); mdiServer->addClient(editor); } diff --git a/src/plugins/texteditor/texteditor_plg.h b/src/plugins/texteditor/texteditor_plg.h index 9821481..0174814 100644 --- a/src/plugins/texteditor/texteditor_plg.h +++ b/src/plugins/texteditor/texteditor_plg.h @@ -11,10 +11,7 @@ #include "endlinestyle.h" #include "iplugin.h" -class QsvColorDefFactory; - class TextEditorPlugin : public IPlugin { - struct Config { CONFIG_DEFINE(TrimSpaces, bool) CONFIG_DEFINE(SmartHome, bool) @@ -40,7 +37,6 @@ class TextEditorPlugin : public IPlugin { ~TextEditorPlugin(); void showAbout() override; - QActionGroup *newFileActions() override; QStringList myExtensions() override; int canOpenFile(const QString fileName) override; bool openFile(const QString fileName, int x = -1, int y = -1, int z = -1) override; @@ -49,13 +45,5 @@ class TextEditorPlugin : public IPlugin { public slots: virtual void configurationHasBeenModified() override; - void fileNew(QAction *); - - private: - QActionGroup *myNewActions; - QAction *actionNewFile; - QAction *actionNewCPP; - QAction *actionNewHeader; - - QsvColorDefFactory *editorColors; + void fileNew(); };