From 2103ebd7e8cd726ed8c067cf65db0f926b16131d Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 15 May 2018 11:35:02 +0200 Subject: [PATCH] Some refactoring, will publish 0.9.5. --- resources/text/CHANGELOG | 3 +-- .../saurus/gui/dialogs/formmain.cpp | 3 +++ .../saurus/gui/dialogs/formmain.h | 2 -- .../saurus/miscellaneous/textapplication.cpp | 10 ++++++++++ .../saurus/miscellaneous/textapplication.h | 1 + .../saurus/plugin-system/pluginfactory.cpp | 1 + src/textosaurus/main.cpp | 18 ++++-------------- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index dd487644..77f64a8a 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -6,8 +6,7 @@ Microsoft Visual C++ redistributable must be installed. It is bundled in Textosa Added: * Macros sidebar which allows to record, play and save macros. -* Experimental Mac OS X build. -* Updates are checked automatically. +* Experimental Mac OS X build. There was some effor to make good DMG bundles but I failed. Therefore "app dir" is generated instead and Textosaurus core library is placed in the same folder as main Textosaurus executable. Changed: * Application is now split into two modules (executable + core library). diff --git a/src/libtextosaurus/saurus/gui/dialogs/formmain.cpp b/src/libtextosaurus/saurus/gui/dialogs/formmain.cpp index 56dd3ecd..aa7f4a33 100644 --- a/src/libtextosaurus/saurus/gui/dialogs/formmain.cpp +++ b/src/libtextosaurus/saurus/gui/dialogs/formmain.cpp @@ -55,6 +55,9 @@ FormMain::FormMain(QWidget* parent) : QMainWindow(parent), m_statusBar() { FormAbout(this).exec(); }); } + + // Display main window. + qDebug("Showing the main window when the application is starting."); } TabWidget* FormMain::tabWidget() const { diff --git a/src/libtextosaurus/saurus/gui/dialogs/formmain.h b/src/libtextosaurus/saurus/gui/dialogs/formmain.h index ae4970f2..b8502d12 100644 --- a/src/libtextosaurus/saurus/gui/dialogs/formmain.h +++ b/src/libtextosaurus/saurus/gui/dialogs/formmain.h @@ -21,8 +21,6 @@ class TEXTOSAURUS_DLLSPEC FormMain : public QMainWindow { friend class TextApplication; public: - - // Constructors and destructors. explicit FormMain(QWidget* parent = nullptr); virtual ~FormMain() = default; diff --git a/src/libtextosaurus/saurus/miscellaneous/textapplication.cpp b/src/libtextosaurus/saurus/miscellaneous/textapplication.cpp index 2abcb9db..9e435d5d 100644 --- a/src/libtextosaurus/saurus/miscellaneous/textapplication.cpp +++ b/src/libtextosaurus/saurus/miscellaneous/textapplication.cpp @@ -103,6 +103,16 @@ void TextApplication::attachTextEditor(TextEditor* editor) { connect(editor, &TextEditor::readOnlyChanged, this, &TextApplication::onEditorReadOnlyChanged); } +void TextApplication::openPassedFilesOrNewDocument() { + // We load any documents passed as parameters. + if (qApp->arguments().size() > 1) { + loadFilesFromArgs(qApp->arguments().mid(1)); + } + else if (tabWidget()->count() == 0) { + newFile(); + } +} + void TextApplication::saveCurrentEditor() { TextEditor* editor = tabWidget()->currentEditor(); diff --git a/src/libtextosaurus/saurus/miscellaneous/textapplication.h b/src/libtextosaurus/saurus/miscellaneous/textapplication.h index a409bdb3..2c06c72d 100644 --- a/src/libtextosaurus/saurus/miscellaneous/textapplication.h +++ b/src/libtextosaurus/saurus/miscellaneous/textapplication.h @@ -51,6 +51,7 @@ class TEXTOSAURUS_DLLSPEC TextApplication : public QObject { void attachTextEditor(TextEditor* editor); // Load/save/new files. + void openPassedFilesOrNewDocument(); void newFile(); void reopenTextFile(QAction* action); void openTextFile(QAction* action = nullptr); diff --git a/src/libtextosaurus/saurus/plugin-system/pluginfactory.cpp b/src/libtextosaurus/saurus/plugin-system/pluginfactory.cpp index 4fee97d9..dd2af4ae 100644 --- a/src/libtextosaurus/saurus/plugin-system/pluginfactory.cpp +++ b/src/libtextosaurus/saurus/plugin-system/pluginfactory.cpp @@ -39,6 +39,7 @@ void PluginFactory::loadPlugins(TextApplication* text_app) { // TODO: doladit, protože když se to volá tady, // tak část property v text_app ani icons() není inicializovany, // asi dát do hookPluginsIntoApplication + // A CELKOVE VYRESIT PORADI inicializace různých komponent plugin->setTextApp(text_app, qApp->settings(), qApp->icons()); auto plugin_sidebars = plugin->sidebars(); diff --git a/src/textosaurus/main.cpp b/src/textosaurus/main.cpp index fb61acce..c850fe74 100644 --- a/src/textosaurus/main.cpp +++ b/src/textosaurus/main.cpp @@ -68,29 +68,19 @@ int main(int argc, char* argv[]) { // Set correct information for main window. main_window.setWindowTitle(APP_LONG_NAME); - - // Display main window. - qDebug("Showing the main window when the application is starting."); main_window.show(); qApp->textApplication()->restoreSession(); - - // We load any documents passed as parameters. - if (application.arguments().size() > 1) { - qApp->textApplication()->loadFilesFromArgs(application.arguments().mid(1)); - } - else if (qApp->textApplication()->tabWidget()->count() == 0) { - qApp->textApplication()->newFile(); - } - - // Now is a good time to initialize dynamic keyboard shortcuts. - DynamicShortcuts::load(qApp->userActions()); + qApp->textApplication()->openPassedFilesOrNewDocument(); // Display tray icon if it is enabled and available. if (SystemTrayIcon::isSystemTrayActivated()) { qApp->showTrayIcon(); } + // Now is a good time to initialize dynamic keyboard shortcuts. + DynamicShortcuts::load(qApp->userActions()); + // Enter global event loop. return Application::exec(); }