[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/graphics/UNNAMED_READER
From: Stefan Kebekus <kebekus () kde ! org>
Date: 2006-12-26 15:00:28
Message-ID: 1167145228.866762.7745.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 616716 by kebekus:
drag-and-drop support I: documents can be dragged into the UNNAMED_READER
M +1 -0 UNNAMED_READER/CMakeLists.txt
M +3 -6 UNNAMED_READER/TODO
M +33 -4 UNNAMED_READER/autoHideTabWidget.cpp
M +8 -6 UNNAMED_READER/autoHideTabWidget.h
A UNNAMED_READER/dropArea.cpp [License: GPL (v2+) (wrong address)]
A UNNAMED_READER/dropArea.h [License: GPL (v2+) (wrong address)]
M +10 -8 UNNAMED_READER/mainWindow.cpp
M +5 -5 UNNAMED_READER/mainWindow.h
M +4 -0 UNNAMED_READER/tips
M +2 -1 corelibrary/CMakeLists.txt
A corelibrary/dropObserver.cpp [License: GPL (v2+) (wrong address)]
A corelibrary/dropObserver.h [License: GPL (v2+) (wrong address)]
A corelibrary/fileFormats.cpp [License: GPL (v2+) (wrong address)]
A corelibrary/fileFormats.h [License: GPL (v2+) (wrong address)]
M +3 -3 corelibrary/fullScreenWidget.h
M +3 -0 corelibrary/length.cpp
M +3 -3 corelibrary/presentationWidget.h
M +1 -1 corelibrary/readerWidget.cpp
M +4 -1 corelibrary/readerWidget.h
--- trunk/playground/graphics/UNNAMED_READER/UNNAMED_READER/CMakeLists.txt \
#616715:616716 @@ -7,6 +7,7 @@
set(UNNAMED_READER_SRCS
autoHideTabWidget.cpp
+ dropArea.cpp
main.cpp
mainWindow.cpp
UNNAMED_READER_adaptor.cpp
--- trunk/playground/graphics/UNNAMED_READER/UNNAMED_READER/TODO #616715:616716
@@ -1,14 +1,11 @@
-- drag and drop to and from UNNAMED_READER
+- drag from UNNAMED_READER
-- fullscreen and presentation modi: user handling; how should the viewer behave when \
the user tab-cycles?
-
- preferences, "hide tabBar automatically"
-- tip of the day does not show on startup
-
- add images to the tips
- mimetype handling
-- toolbar dialog does not work right now
+- window menu
+- Two tabs open, but only one readerWindow, then context menu on tabbar is nonsense
\ No newline at end of file
--- trunk/playground/graphics/UNNAMED_READER/UNNAMED_READER/autoHideTabWidget.cpp \
#616715:616716 @@ -18,6 +18,7 @@
***************************************************************************/
#include "autoHideTabWidget.h"
+#include "dropArea.h"
#include "mainWindow.h"
#include "readerWidget.h"
#include "UNNAMED_READER_debug.h"
@@ -36,7 +37,7 @@
autoHideTabWidget::autoHideTabWidget(QWidget *parent)
- : KTabWidget(parent)
+ : KTabWidget(parent), dropObserver(this)
{
kDebug(UNNAMED_READER_DEBUG, shell) << "autoHideTabWidget::autoHideTabWidget(...)" \
<< endl;
@@ -56,6 +57,8 @@
connect(tabBar(), SIGNAL(customContextMenuRequested(const QPoint &)), this, \
SLOT(showPopupMenu(const QPoint &)));
setTabReorderingEnabled( true );
+
+ addTab(new dropArea(this), QString::null);
}
@@ -91,7 +94,7 @@
connect((readerWidget *)wdg, SIGNAL(documentFullyLoaded(readerWidget *)), this, \
SLOT(setTabNameAndToolTip(readerWidget *))); }
- setTabBarShown();
+ checkGUI();
emit nrOfChilrendChanged();
}
@@ -100,7 +103,7 @@
{
kDebug(UNNAMED_READER_DEBUG, shell) << "autoHideTabWidget::tabRemoved(int)" << \
endl;
- setTabBarShown();
+ checkGUI();
emit nrOfChilrendChanged();
}
@@ -262,8 +265,34 @@
}
-void autoHideTabWidget::setTabBarShown()
+void autoHideTabWidget::checkGUI()
{
+ kDebug(UNNAMED_READER_DEBUG, shell) << "autoHideTabWidget::checkGUI()" << endl;
+
+ // We never want 0 widgets. If the last widget is gone, add a
+ // dropArea. This method will be called again immediately, and the
+ // TabBar visibility will be set in the next call of this method.
+ if (count() == 0) {
+ addTab(new dropArea(this), QString::null);
+ return;
+ }
+
+ // If there is more than one widget, we don't want a
+ // dropArea. Remove it. This method will be called again
+ // immediately, so there is no need to look for more than one
+ // dropArea. The TabBar visibility will be set in the next call of
+ // this method.
+ if (count() > 1) {
+ for(int i=0; i<count(); i++) {
+ QWidget *wdg = widget(i);
+ if ((wdg == 0) || (!wdg->inherits("UNNAMED_READER::dropArea")))
+ continue;
+ delete wdg;
+ return;
+ }
+ } // If count() > 1
+
+ // Show or hide the tabBar
if (count() < 2) {
tabBar()->hide();
tabBar()->setContextMenuPolicy(Qt::PreventContextMenu);
--- trunk/playground/graphics/UNNAMED_READER/UNNAMED_READER/autoHideTabWidget.h \
#616715:616716 @@ -21,10 +21,10 @@
#ifndef _AUTOHIDETABWIDGET_H_
#define _AUTOHIDETABWIDGET_H_
+#include "dropObserver.h"
+
#include <ktabwidget.h>
-
-
namespace UNNAMED_READER {
class readerWidget;
@@ -43,9 +43,10 @@
*
* @author Stefan Kebekus <kebekus@kde.org>
*/
-class autoHideTabWidget : public KTabWidget
+class autoHideTabWidget : public KTabWidget, public dropObserver
{
Q_OBJECT
+ DROPOBSERVER
public:
/**
@@ -105,10 +106,11 @@
private:
/**
- * This method will show the tabBar if at least two tabs are there,
- * and hide it otherwise.
+ * This method will make the necessary changes to the GUI when the
+ * number of children chenges. For instance, it will show the tabBar
+ * if at least two tabs are there, and hide it otherwise.
*/
- void setTabBarShown();
+ void checkGUI();
};
--- trunk/playground/graphics/UNNAMED_READER/UNNAMED_READER/mainWindow.cpp \
#616715:616716 @@ -18,12 +18,12 @@
***************************************************************************/
#include "autoHideTabWidget.h"
+#include "fileFormats.h"
#include "mainWindow.h"
#include "readerWidget.h"
#include "UNNAMED_READER_debug.h"
#include "UNNAMED_READER_adaptor.h"
-
#include <kapplication.h>
#include <kfiledialog.h>
#include <kicon.h>
@@ -37,24 +37,27 @@
#include <kurlrequesterdlg.h>
#include <QDBusConnection>
#include <QFile>
-#include <QWorkspace>
+#include <Qt>
namespace UNNAMED_READER {
#define UNNAMED_READER_DEBUG 0
-#warning TODO support DRAG-AND-DROP
+#warning TODO support DRAG
mainWindow::mainWindow()
- : KMainWindow( 0, "UNNAMED_READER main window" )
+ : KMainWindow( 0, "UNNAMED_READER main window" ), dropObserver(this)
{
// Set up the DBus interface
new UNNAMED_READERAdaptor(this);
QDBusConnection session = QDBusConnection::sessionBus();
session.registerObject("/UNNAMED_READER", this);
+ // Accept drops
+ setAcceptDrops(true);
+
// construct the workspace
workspace = new autoHideTabWidget(this);
connect(workspace, SIGNAL(nrOfChilrendChanged()), this, SLOT(checkActions()));
@@ -93,7 +96,6 @@
action_reload->setEnabled(workspace->currentReader() != 0);
action_fullScreen->setEnabled(workspace->currentReader() != 0);
action_presentation->setEnabled(workspace->currentReader() != 0);
- action_reenablewarnings->setEnabled(KGlobal::config()->hasGroup("Notification \
Messages")); }
@@ -153,7 +155,7 @@
void mainWindow::reenableAllWarnings()
{
- kDebug() << "mainWindow::reenableAllWarnings()" << endl;
+ kDebug(UNNAMED_READER_DEBUG, shell) << "mainWindow::reenableAllWarnings()" << \
endl;
KMessageBox::information(this,
i18n("<qt>All message-- and warning dialogs that were switched off using the "
@@ -238,8 +240,8 @@
// *** SETTINGS MENU ***
// Re-enable all warnings
- action_reenablewarnings = new KAction(i18n("Re-enable all warnings"), \
actionCollection(), "reenablewarnings");
- connect(action_reenablewarnings, SIGNAL(triggered()), this, \
SLOT(reenableAllWarnings())); + act = new KAction(i18n("Re-enable all warnings"), \
actionCollection(), "reenablewarnings"); + connect(act, SIGNAL(triggered()), this, \
SLOT(reenableAllWarnings()));
// *** HELP MENU ***
// Tip of day
--- trunk/playground/graphics/UNNAMED_READER/UNNAMED_READER/mainWindow.h \
#616715:616716 @@ -26,6 +26,7 @@
#endif
#include "autoHideTabWidget.h"
+#include "dropObserver.h"
#include "readerWidget.h"
#include <kmainwindow.h>
@@ -43,10 +44,11 @@
* @author Stefan Kebekus <kebekus@kde.org>
* @version 0.1
*/
-class mainWindow : public KMainWindow
+ class mainWindow : public KMainWindow, public dropObserver
{
Q_OBJECT
-
+ DROPOBSERVER
+
public:
/**
* Default Constructor
@@ -58,7 +60,6 @@
*/
virtual ~mainWindow();
-
public slots:
/**
* Opens a document
@@ -99,7 +100,7 @@
* @returns 'true' if the document is opened, and 'false' otherwise
*/
bool bringToFront(KUrl url);
-
+
private slots:
// Enables and disables the actions
void checkActions();
@@ -147,7 +148,6 @@
KAction *action_close;
KAction *action_fullScreen;
KAction *action_presentation;
- KAction *action_reenablewarnings;
};
--- trunk/playground/graphics/UNNAMED_READER/UNNAMED_READER/tips #616715:616716
@@ -2,3 +2,7 @@
document tabs are open in UNNAMED_READER, then a right-click on the
tab bar opens a menu with useful navigation functionality.</p> </html>
</tip>
+
+<tip category="UNNAMED_READER|General"> <html> <p>To open a document,
+simply drag its icon into the UNNAMED_READER window.</p> </html>
+</tip>
--- trunk/playground/graphics/UNNAMED_READER/corelibrary/CMakeLists.txt \
#616715:616716 @@ -2,12 +2,13 @@
########### UNNAMED_READERcore ############
set(UNNAMED_READERcore_LIB_SRCS
+ dropObserver.cpp
+ fileFormats.cpp
fullScreenWidget.cpp
length.cpp
presentationWidget.cpp
readerWidget.cpp )
-
kde4_automoc(${UNNAMED_READERcore_LIB_SRCS})
kde4_add_ui_files(UNNAMED_READERcore_LIB_SRCS
--- trunk/playground/graphics/UNNAMED_READER/corelibrary/fullScreenWidget.h \
#616715:616716 @@ -67,11 +67,11 @@
virtual ~fullScreenWidget();
protected:
- // Closes the widget when 'ESC' is pressed
+ /** Closes the widget when 'ESC' is pressed */
virtual void keyPressEvent(QKeyEvent *event);
- // Pointer to the class created by the Qt designer this sets up the
- // GUI
+ /** Pointer to the class created by the Qt designer this sets up the
+ GUI */
Ui_fullScreenWidget *dlg;
};
--- trunk/playground/graphics/UNNAMED_READER/corelibrary/length.cpp #616715:616716
@@ -33,7 +33,10 @@
class unitOfDistance
{
public:
+ /** milimeters per unit */
float mmPerUnit;
+
+ /** name of the unit */
const char* name;
};
--- trunk/playground/graphics/UNNAMED_READER/corelibrary/presentationWidget.h \
#616715:616716 @@ -66,11 +66,11 @@
virtual ~presentationWidget();
protected:
- // Closes the widget when 'ESC' is pressed
+ /** Closes the widget when 'ESC' is pressed */
virtual void keyPressEvent(QKeyEvent *event);
- // Pointer to the class created by the Qt designer this sets up the
- // GUI
+ /** Pointer to the class created by the Qt designer this sets up the
+ GUI */
Ui_presentationWidget *dlg;
};
--- trunk/playground/graphics/UNNAMED_READER/corelibrary/readerWidget.cpp \
#616715:616716 @@ -32,7 +32,7 @@
readerWidget::readerWidget(QWidget *parent, KUrl url, bool *ok)
- : QWidget(parent)
+ : QWidget(parent), dropObserver(this)
{
if (ok != 0)
*ok = false;
--- trunk/playground/graphics/UNNAMED_READER/corelibrary/readerWidget.h \
#616715:616716 @@ -21,6 +21,8 @@
#ifndef _READERWIDGET_H_
#define _READERWIDGET_H_
+#include "dropObserver.h"
+
#include <KUrl>
#include <QTimer>
#include <QWidget>
@@ -47,9 +49,10 @@
*
* @author Stefan Kebekus <kebekus@kde.org>
*/
-class KDE_EXPORT readerWidget : public QWidget
+class KDE_EXPORT readerWidget : public QWidget, public dropObserver
{
Q_OBJECT
+ DROPOBSERVER
public:
/**
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic