[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasmate/terietor/konsolepreviewer] /: Initial commit for konsole previewer
From: Giorgos Tsiapaliwkas <terietor () gmail ! com>
Date: 2012-07-10 14:58:20
Message-ID: 20120710145820.2EC07A6094 () git ! kde ! org
[Download RAW message or body]
Git commit ae1acefa96b171d6e856c4f283f79d3f09d429a9 by Giorgos Tsiapaliwkas.
Committed on 07/06/2012 at 08:58.
Pushed by tsiapaliwkas into branch 'terietor/konsolepreviewer'.
Initial commit for konsole previewer
M +1 -0 CMakeLists.txt
M +31 -0 main.cpp
M +27 -1 mainwindow.cpp
M +4 -1 mainwindow.h
M +11 -0 previewer/plasmoid/plasmoidpreviewer.cpp
M +1 -0 previewer/plasmoid/plasmoidpreviewer.h
M +1 -0 previewer/plasmoid/plasmoidview.cpp
M +7 -0 previewer/plasmoid/previewcontainment.cpp
M +1 -0 previewer/plasmoid/previewcontainment.h
M +6 -1 previewer/previewer.cpp
M +13 -0 previewer/previewer.h
M +7 -1 previewer/runner/runnerpreviewer.cpp
M +1 -0 previewer/runner/runnerpreviewer.h
http://commits.kde.org/plasmate/ae1acefa96b171d6e856c4f283f79d3f09d429a9
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12f8a3a..18d91ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,6 +54,7 @@ set (PlasMate_SRC
publisher/signingwidget.cpp
publisher/signingdialog.cpp
publisher/publisher.cpp
+ konsole/konsolepreviewer.cpp
docbrowser/docbrowser.cpp
projectmanager/projectmanager.cpp
)
diff --git a/main.cpp b/main.cpp
index 1c5ea19..e986417 100644
--- a/main.cpp
+++ b/main.cpp
@@ -15,15 +15,46 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <iostream>
+
#include <KApplication>
#include <KAboutData>
#include <KLocale>
#include <KCmdLineArgs>
+#include <QFile>
+#include <QTextStream>
+
#include "mainwindow.h"
+void customMessageHandler(QtMsgType type, const char *msg)
+{
+ QString txt;
+ switch (type) {
+ case QtDebugMsg:
+ txt = QString("Debug: %1").arg(msg);
+ break;
+ case QtWarningMsg:
+ txt = QString("Warning: %1").arg(msg);
+ break;
+ case QtCriticalMsg:
+ txt = QString("Critical: %1").arg(msg);
+ break;
+ case QtFatalMsg:
+ txt = QString("Fatal: %1").arg(msg);
+ abort();
+ }
+ QFile outFile("/var/tmp/plasmatepreviewerlog.txt");
+ outFile.open(QIODevice::WriteOnly | QIODevice::Append);
+ QTextStream ts(&outFile);
+ ts << txt << endl;
+ std::cout << txt.toLocal8Bit().constData() << std::endl;
+}
+
int main(int argc, char *argv[])
{
+ qInstallMsgHandler(customMessageHandler);
+
KAboutData aboutData("plasmate", 0, ki18n("Plasmate"),
"0.1alpha3", ki18n("Plasma Add-Ons Creator"),
KAboutData::License_GPL,
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 6f72624..a864f30 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -55,6 +55,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "packagemodel.h"
#include "sidebar.h"
#include "startpage.h"
+#include "konsole/konsolepreviewer.h"
#include "previewer/plasmoid/plasmoidpreviewer.h"
#include "previewer/runner/runnerpreviewer.h"
#include "publisher/publisher.h"
@@ -609,7 +610,6 @@ void MainWindow::updateSideBar()
m_oldTab = EditTab;
}
-
void MainWindow::loadImageViewer(const KUrl& target)
{
saveEditorData();
@@ -623,6 +623,21 @@ void MainWindow::loadImageViewer(const KUrl& target)
updateSideBar();
}
+void MainWindow::showKonsolePreviewer()
+{
+ if(m_konsole->isVisible()) {
+ m_konsole->setVisible(false);
+ } else {
+ m_konsole->setVisible(true);
+ }
+}
+
+void MainWindow::reloadKonsolePreviewer()
+{
+ if (m_konsole && m_previewerWidget) {
+ m_konsole->setOutput(m_previewerWidget->takeOutput());
+ }
+}
void MainWindow::loadMetaDataEditor(KUrl target)
{
@@ -754,6 +769,10 @@ void MainWindow::loadProject(const QString &path)
refreshNotes();
}
+
+ //initialize the konsole previewer
+ m_konsole = new KonsolePreviewer(i18n("Previewer Output"), this);
+
// initialize previewer
delete m_previewerWidget;
m_previewerWidget = createPreviewerFor(actualType);
@@ -762,6 +781,12 @@ void MainWindow::loadProject(const QString &path)
addDockWidget(Qt::LeftDockWidgetArea, m_previewerWidget);
m_previewerWidget->showPreview(packagePath);
m_previewerWidget->setVisible(showPreview);
+
+ //now do the relative stuff for the konsole
+ m_konsole->setOutput(m_previewerWidget->takeOutput());
+ m_konsole->setObjectName("Previewer Output");
+ connect(m_previewerWidget, SIGNAL(showKonsole()), this, SLOT(showKonsolePreviewer()));
+ addDockWidget(Qt::BottomDockWidgetArea, m_konsole);
}
restoreState(state, STATE_VERSION);
@@ -877,6 +902,7 @@ Previewer* MainWindow::createPreviewerFor(const QString& projectType)
if (ret) {
ret->setObjectName("preview");
connect(ret, SIGNAL(refreshRequested()), this, SLOT(saveAndRefresh()));
+ connect(ret, SIGNAL(refreshRequested()), this, SLOT(reloadKonsolePreviewer()));
connect(ret, SIGNAL(visibilityChanged(bool)), this, SLOT(updateActions()));
}
diff --git a/mainwindow.h b/mainwindow.h
index 520c26c..d187296 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -44,6 +44,7 @@ class TimeLine;
class MetaDataEditor;
class ImageViewer;
class TextEditor;
+class KonsolePreviewer;
// our own previewer
class Previewer;
@@ -107,6 +108,8 @@ private Q_SLOTS:
void toggleNotes();
void toggleFileList();
void installPackage();
+ void showKonsolePreviewer();
+ void reloadKonsolePreviewer();
// refreshes editor, killing all local changes
void editorDestructiveRefresh();
@@ -156,7 +159,7 @@ private:
Publisher *m_publisher;
DocBrowser *m_browser;
TextEditor *m_textEditor;
-
+ KonsolePreviewer *m_konsole;
QDockWidget *m_filelist;
EditPage *m_editPage;
diff --git a/previewer/plasmoid/plasmoidpreviewer.cpp b/previewer/plasmoid/plasmoidpreviewer.cpp
index 29853db..478b498 100644
--- a/previewer/plasmoid/plasmoidpreviewer.cpp
+++ b/previewer/plasmoid/plasmoidpreviewer.cpp
@@ -10,6 +10,8 @@
#include "plasmoidpreviewer.h"
+#include <QFile>
+
PlasmoidPreviewer::PlasmoidPreviewer(const QString & title, QWidget * parent, Qt::WindowFlags flags)
: Previewer(title, parent, flags)
{
@@ -27,3 +29,12 @@ void PlasmoidPreviewer::refreshPreview()
emit refreshView();
}
+QString PlasmoidPreviewer::takeOutput() const
+{
+ QFile file("/var/tmp/plasmatepreviewerlog.txt");
+ if (file.open(QIODevice::ReadOnly)) {
+ return file.readAll();
+ }
+
+ return QString();
+}
diff --git a/previewer/plasmoid/plasmoidpreviewer.h b/previewer/plasmoid/plasmoidpreviewer.h
index 9cad9e4..2a247dd 100644
--- a/previewer/plasmoid/plasmoidpreviewer.h
+++ b/previewer/plasmoid/plasmoidpreviewer.h
@@ -35,6 +35,7 @@ public:
PlasmoidPreviewer(const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
void showPreview(const QString &packagePath);
void refreshPreview();
+ QString takeOutput() const;
private:
PlasmoidView* m_view;
diff --git a/previewer/plasmoid/plasmoidview.cpp b/previewer/plasmoid/plasmoidview.cpp
index 3d40d48..7a50e02 100644
--- a/previewer/plasmoid/plasmoidview.cpp
+++ b/previewer/plasmoid/plasmoidview.cpp
@@ -54,6 +54,7 @@ PlasmoidView::PlasmoidView(QWidget *parent)
// we do a two-way connect here to allow the previewer containment
// and main window to tell each other to save/refresh
connect(m_containment, SIGNAL(refreshClicked()), parent, SLOT(emitRefreshRequest()));
+ connect(m_containment, SIGNAL(showKonsole()), parent, SLOT(emitShowKonsole()));
connect(parent, SIGNAL(refreshView()), m_containment, SLOT(refreshApplet()));
setScene(&m_corona);
diff --git a/previewer/plasmoid/previewcontainment.cpp b/previewer/plasmoid/previewcontainment.cpp
index 42b6af7..c081294 100644
--- a/previewer/plasmoid/previewcontainment.cpp
+++ b/previewer/plasmoid/previewcontainment.cpp
@@ -27,6 +27,7 @@
#include <QGraphicsLayoutItem>
#include <KAction>
+#include <KConfigGroup>
#include <KIcon>
#include <KMenu>
@@ -84,6 +85,7 @@ void PreviewContainment::setupHeader()
Plasma::IconWidget *refresh = new Plasma::IconWidget(this);
Plasma::IconWidget *location = new Plasma::IconWidget(this);
Plasma::IconWidget *wallpaper = new Plasma::IconWidget(this);
+ Plasma::IconWidget *konsole = new Plasma::IconWidget(this);
// add actions
KAction *action0 = new KAction(KIcon("user-desktop"), "", this);
@@ -102,11 +104,16 @@ void PreviewContainment::setupHeader()
connect(action3, SIGNAL(triggered()), this, SLOT(refreshAndEmit()));
refresh->setAction(action3);
+ KAction *action4 = new KAction(KIcon("konsole"), "", this);
+ connect(action4, SIGNAL(triggered()), this, SIGNAL(showKonsole()));
+ konsole->setAction(action4);
+
// add the toolboxes
m_header->addItem(refresh);
m_header->addItem(form);
m_header->addItem(location);
m_header->addItem(wallpaper);
+ m_header->addItem(konsole);
}
// Fixme(?): Does not currently respect arguments passed in during
diff --git a/previewer/plasmoid/previewcontainment.h b/previewer/plasmoid/previewcontainment.h
index fb10941..34dfb52 100644
--- a/previewer/plasmoid/previewcontainment.h
+++ b/previewer/plasmoid/previewcontainment.h
@@ -47,6 +47,7 @@ public slots:
signals:
void refreshClicked();
+ void showKonsole();
protected slots:
void refreshAndEmit();
diff --git a/previewer/previewer.cpp b/previewer/previewer.cpp
index c9d7479..0521cfc 100644
--- a/previewer/previewer.cpp
+++ b/previewer/previewer.cpp
@@ -30,4 +30,9 @@ Previewer::Previewer(QWidget * parent, Qt::WindowFlags flags)
void Previewer::emitRefreshRequest()
{
emit refreshRequested();
-}
\ No newline at end of file
+}
+
+void Previewer::emitShowKonsole()
+{
+ emit showKonsole();
+}
diff --git a/previewer/previewer.h b/previewer/previewer.h
index 2907598..3712b61 100644
--- a/previewer/previewer.h
+++ b/previewer/previewer.h
@@ -29,6 +29,7 @@ class Previewer : public QDockWidget {
signals:
void refreshRequested();
+ void showKonsole();
public:
Previewer(const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
@@ -37,6 +38,13 @@ public:
* Subclasses should override this method with actual previewing code
*/
virtual void showPreview(const QString &packagePath) = 0;
+
+ /**
+ * Subclasses should override this method with the actual code which
+ * will take the output
+ **/
+ virtual QString takeOutput() const = 0;
+
/**
* Subclasses should override this method with code that refreshes the preview
*/
@@ -50,6 +58,11 @@ public slots:
*/
void emitRefreshRequest();
+ /**
+ * Emits showKonsole(), which will show the konsole. All subclasses should call/connect
+ * to this when the user requests a to see the konsole.
+ **/
+ virtual void emitShowKonsole();
};
#endif // PREVIEWER_H
\ No newline at end of file
diff --git a/previewer/runner/runnerpreviewer.cpp b/previewer/runner/runnerpreviewer.cpp
index 5c8dc6d..c1c5b47 100644
--- a/previewer/runner/runnerpreviewer.cpp
+++ b/previewer/runner/runnerpreviewer.cpp
@@ -77,4 +77,10 @@ void RunnerPreviewer::doQuery()
if (m_runner) {
m_runner->launchQuery(m_edit->text());
}
-}
\ No newline at end of file
+}
+
+QString RunnerPreviewer::takeOutput() const
+{
+ //TODO add support for a runner previewer
+ return QString();
+}
diff --git a/previewer/runner/runnerpreviewer.h b/previewer/runner/runnerpreviewer.h
index 054c58d..2ac687e 100644
--- a/previewer/runner/runnerpreviewer.h
+++ b/previewer/runner/runnerpreviewer.h
@@ -30,6 +30,7 @@ public:
~RunnerPreviewer();
void showPreview(const QString &packagePath);
void refreshPreview();
+ QString takeOutput() const;
public slots:
void doQuery();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic