summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Humpula <michal.humpula@seznam.cz>2014-01-20 20:58:07 (GMT)
committerMichal Humpula <michal.humpula@seznam.cz>2014-01-21 13:24:54 (GMT)
commit25c484af021e62d010b92c882029bb2d01ea2b5f (patch)
tree5a1d94427d1e78588e1a25b46064af49d6e41b7b
parentf5cae065eee28c0dd9ae8446ab92d750bb077b17 (diff)
add MainWindow::closeView/splitView and Application::quit methods
REVIEW: 115160
-rw-r--r--src/include/ktexteditor/application.h8
-rw-r--r--src/include/ktexteditor/mainwindow.h13
-rw-r--r--src/utils/application.cpp21
-rw-r--r--src/utils/mainwindow.cpp39
4 files changed, 81 insertions, 0 deletions
diff --git a/src/include/ktexteditor/application.h b/src/include/ktexteditor/application.h
index 882349c..56a8d4a 100644
--- a/src/include/ktexteditor/application.h
+++ b/src/include/ktexteditor/application.h
@@ -66,6 +66,14 @@ public:
*/
virtual ~Application();
+ /**
+ * Ask app to quit. The app might interact with the user and decide that
+ * quiting is not possible and return false.
+ *
+ * \return true if the app could quit
+ */
+ bool quit();
+
//
// MainWindow related accessors
//
diff --git a/src/include/ktexteditor/mainwindow.h b/src/include/ktexteditor/mainwindow.h
index 0d3df01..fda80a2 100644
--- a/src/include/ktexteditor/mainwindow.h
+++ b/src/include/ktexteditor/mainwindow.h
@@ -135,6 +135,19 @@ public:
*/
KTextEditor::View *openUrl(const QUrl &url, const QString &encoding = QString());
+ /**
+ * Close selected view
+ * \param view the view
+ * \return true if view was closed
+ */
+ bool closeView(KTextEditor::View *view);
+
+ /**
+ * Split current view space according to @orientation
+ * \param orientation in which line split the view
+ */
+ void splitView(Qt::Orientation orientation);
+
//
// Signals related to view handling
//
diff --git a/src/utils/application.cpp b/src/utils/application.cpp
index d93398e..b6a2921 100644
--- a/src/utils/application.cpp
+++ b/src/utils/application.cpp
@@ -35,6 +35,27 @@ Application::~Application()
{
}
+bool Application::quit()
+{
+ /**
+ * null check
+ */
+ if (!this) {
+ return false;
+ }
+
+ /**
+ * dispatch to parent
+ */
+ bool success = false;
+ QMetaObject::invokeMethod(parent()
+ , "quit"
+ , Qt::DirectConnection
+ , Q_RETURN_ARG(bool, success));
+
+ return success;
+}
+
QList<KTextEditor::MainWindow *> Application::mainWindows()
{
/**
diff --git a/src/utils/mainwindow.cpp b/src/utils/mainwindow.cpp
index f8a58eb..1231f9a 100644
--- a/src/utils/mainwindow.cpp
+++ b/src/utils/mainwindow.cpp
@@ -160,6 +160,45 @@ KTextEditor::View *MainWindow::openUrl(const QUrl &url, const QString &encoding)
return view;
}
+bool MainWindow::closeView(KTextEditor::View *view)
+{
+ /**
+ * null check
+ */
+ if (!this) {
+ return false;
+ }
+
+ /**
+ * dispatch to parent
+ */
+ bool success = false;
+ QMetaObject::invokeMethod(parent()
+ , "closeView"
+ , Qt::DirectConnection
+ , Q_RETURN_ARG(bool, success)
+ , Q_ARG(KTextEditor::View *, view));
+ return success;
+}
+
+void MainWindow::splitView(Qt::Orientation orientation)
+{
+ /**
+ * null check
+ */
+ if (!this) {
+ return;
+ }
+
+ /**
+ * dispatch to parent
+ */
+ QMetaObject::invokeMethod(parent()
+ , "splitView"
+ , Qt::DirectConnection
+ , Q_ARG(Qt::Orientation, orientation));
+}
+
QWidget *MainWindow::createViewBar(KTextEditor::View *view)
{
/**