[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/krdc
From:       Tony Murray <murraytony () gmail ! com>
Date:       2011-02-02 16:21:01
Message-ID: 20110202162101.74F22AC8BE () svn ! kde ! org
[Download RAW message or body]

SVN commit 1218506 by murrant:

Uses the main window when going fullscreen.  Hides menubar and toolbar when entering \
fullscreen.  To avoid leaving the menubar and toolbar hidden, we disable  saving of \
window settings when we go fullscreen and re-enable it after.



 M  +3 -3      krdcui.rc  
 M  +56 -82    mainwindow.cpp  
 M  +8 -5      mainwindow.h  


--- trunk/KDE/kdenetwork/krdc/krdcui.rc #1218505:1218506
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="krdc" version="8">
+<gui name="krdc" version="9">
 <MenuBar>
     <Menu name="file">
         <Action name="new_connection" />
     </Menu>
     <Menu noMerge="1" name="session"><text>&amp;Session</text>
-        <Action name="switch_fullscreen" />
+        <Action name="fullscreen" />
         <Action name="take_screenshot" />
         <Action name="view_only" />
         <Action name="show_local_cursor" />
@@ -22,7 +22,7 @@
 <ToolBar fullWidth="false" name="krdc_remote_view_toolbar" \
newline="false"><text>Remote View Toolbar</text>  <Action name="new_connection" />
     <Separator />
-    <Action name="switch_fullscreen" />
+    <Action name="fullscreen" />
     <Action name="take_screenshot" />
     <Action name="view_only" />
     <Action name="show_local_cursor" />
--- trunk/KDE/kdenetwork/krdc/mainwindow.cpp #1218505:1218506
@@ -58,6 +58,7 @@
 #include <KStatusBar>
 #include <KToggleAction>
 #include <KToggleFullScreenAction>
+#include <KToolBar>
 #include <KServiceTypeTrader>
 
 #include <QClipboard>
@@ -77,7 +78,6 @@
 
 MainWindow::MainWindow(QWidget *parent)
         : KXmlGuiWindow(parent),
-        m_fullscreenWindow(0),
         m_protocolInput(0),
         m_addressInput(0),
         m_toolBar(0),
@@ -122,7 +122,6 @@
 
     if (Settings::systemTrayIcon()) {
         m_systemTrayIcon = new SystemTrayIcon(this);
-        if(m_fullscreenWindow) \
m_systemTrayIcon->setAssociatedWidget(m_fullscreenWindow);  }
 
     connect(m_tabWidget, SIGNAL(currentChanged(int)), SLOT(tabChanged(int)));
@@ -136,6 +135,7 @@
         m_tabWidget->addTab(newConnectionWidget(), i18n("New Connection"));
 
     setAutoSaveSettings(); // e.g toolbar position, mainwindow size, ...
+    m_saveSettingsDisabled = false;
 
     if (Settings::rememberSessions()) // give some time to create and show the \
window first  QTimer::singleShot(100, this, SLOT(restoreOpenSessions()));
@@ -158,13 +158,6 @@
     screenshotAction->setIcon(KIcon("ksnapshot"));
     connect(screenshotAction, SIGNAL(triggered()), SLOT(takeScreenshot()));
 
-    KAction *fullscreenAction = actionCollection()->addAction("switch_fullscreen"); \
// note: please do not switch to KStandardShortcut unless you know what you are doing \
                (see history of this file)
-    fullscreenAction->setText(i18n("Switch to Full Screen Mode"));
-    fullscreenAction->setIconText(i18n("Full Screen"));
-    fullscreenAction->setIcon(KIcon("view-fullscreen"));
-    fullscreenAction->setShortcut(KStandardShortcut::fullScreen());
-    connect(fullscreenAction, SIGNAL(triggered()), SLOT(switchFullscreen()));
-
     QAction *viewOnlyAction = actionCollection()->addAction("view_only");
     viewOnlyAction->setCheckable(true);
     viewOnlyAction->setText(i18n("View Only"));
@@ -198,6 +191,9 @@
     scaleAction->setIconText(i18n("Scale"));
     connect(scaleAction, SIGNAL(triggered(bool)), SLOT(scale(bool)));
 
+    installEventFilter(this);
+
+    KStandardAction::fullScreen(this,SLOT(switchFullScreen(bool)),this, \
actionCollection());  KStandardAction::quit(this, SLOT(quit()), actionCollection());
     KStandardAction::preferences(this, SLOT(preferences()), actionCollection());
     KStandardAction::configureToolbars(this, SLOT(configureToolbars()), \
actionCollection()); @@ -397,7 +393,7 @@
 void MainWindow::resizeTabWidget(int w, int h)
 {
     kDebug(5010) << "tabwidget resize, view size: w: " << w << ", h: " << h;
-    if (m_fullscreenWindow) {
+    if (isFullScreen()) {
         kDebug(5010) << "in fullscreen mode, refusing to resize";
         return;
     }
@@ -411,7 +407,7 @@
 
         if (screenSize == viewSize) {
             kDebug(5010) << "screen size equal to target view size -> switch to \
                fullscreen mode";
-            switchFullscreen();
+            switchFullScreen(true);
             return;
         }
     }
@@ -466,7 +462,7 @@
         // when started with command line fullscreen argument
         if (m_switchFullscreenWhenConnected) {
             m_switchFullscreenWhenConnected = false;
-            switchFullscreen();
+            switchFullScreen(true);
         }
 
         if (Settings::rememberHistory()) {
@@ -490,71 +486,52 @@
     QApplication::clipboard()->setPixmap(snapshot);
 }
 
-void MainWindow::switchFullscreen()
+void MainWindow::switchFullScreen(bool makeFullScreen)
 {
-    kDebug(5010);
+    // save widget visibility if we aren't fullscreen
+    if (!m_saveSettingsDisabled) {
+        saveMainWindowSettings(KConfigGroup(KGlobal::config(), "MainWindow"));
+    }
+    KToggleFullScreenAction::setFullScreen(this, makeFullScreen);
+}
 
-    if (m_fullscreenWindow) {
-        // Leaving full screen mode
-        m_fullscreenWindow->setWindowState(0);
-        m_fullscreenWindow->hide();
+void MainWindow::fullScreenChanged()
+{
+    // hide/show widgets as needed for fullscreen
+    if (isFullScreen()) {
+        kDebug(5010) << "Entering full screen mode";
+        resetAutoSaveSettings(); //stop window/toolbar settings from being saved \
while in FS mode. +        m_saveSettingsDisabled = true;
+        menuBar()->hide();
+        toolBar("krdc_remote_view_toolbar")->hide();
+        actionCollection()->action("remote_desktop_dockwidget")->parentWidget()->hide();
 +        statusBar()->hide();
+        m_tabWidget->setTabBarHidden(true);
+        m_tabWidget->setDocumentMode(true);
+        foreach (RemoteView *currentView, m_remoteViewList) {
+            currentView->enableScaling(currentView->hostPreferences()->fullscreenScale());
 +        }
 
+        MinimizePixel *minimizePixel = new MinimizePixel(m_tabWidget);
+        //minimizePixel->winId(); // force it to be a native widget (prevents \
problem with QX11EmbedContainer) +        connect(minimizePixel, \
SIGNAL(rightClicked()), this, SLOT(showMinimized())); +        \
showRemoteViewToolbar(); +    } else {
+        kDebug(5010) << "Leaving full screen mode";
+        applyMainWindowSettings(KConfigGroup(KGlobal::config(), "MainWindow"));
+        m_saveSettingsDisabled = false;
+        setAutoSaveSettings(); // Allow settings to be saved again.
         m_tabWidget->setTabBarHidden(m_tabWidget->count() <= 1 && \
!Settings::showTabBar());  m_tabWidget->setDocumentMode(false);
-        setCentralWidget(m_tabWidget);
-
-        show();
-        restoreGeometry(m_mainWindowGeometry);
-        if (m_systemTrayIcon) m_systemTrayIcon->setAssociatedWidget(this);
-
         foreach(RemoteView *currentView, m_remoteViewList) {
             currentView->enableScaling(currentView->hostPreferences()->windowedScale());
  }
-
         if (m_toolBar) {
             m_toolBar->hideAndDestroy();
             m_toolBar->deleteLater();
             m_toolBar = 0;
         }
-
-        actionCollection()->action("switch_fullscreen")->setIcon(KIcon("view-fullscreen"));
                
-        actionCollection()->action("switch_fullscreen")->setText(i18n("Switch to \
                Full Screen Mode"));
-        actionCollection()->action("switch_fullscreen")->setIconText(i18n("Full \
                Screen"));
-
-        m_fullscreenWindow->deleteLater();
-        m_fullscreenWindow = 0;
-    } else {
-        // Entering full screen mode
-        m_fullscreenWindow = new QWidget(this, Qt::Window);
-        m_fullscreenWindow->setWindowTitle(i18nc("window title when in full screen \
                mode (for example displayed in tasklist)",
-                                           "KDE Remote Desktop Client (Full \
                Screen)"));
-
-        m_mainWindowGeometry = saveGeometry();
-
-        m_tabWidget->setTabBarHidden(true);
-        m_tabWidget->setDocumentMode(true);
-
-        foreach(RemoteView *currentView, m_remoteViewList) {
-            currentView->enableScaling(currentView->hostPreferences()->fullscreenScale());
  }
-
-        QVBoxLayout *fullscreenLayout = new QVBoxLayout(m_fullscreenWindow);
-        fullscreenLayout->setContentsMargins(QMargins(0, 0, 0, 0));
-        fullscreenLayout->addWidget(m_tabWidget);
-
-        KToggleFullScreenAction::setFullScreen(m_fullscreenWindow, true);
-
-        MinimizePixel *minimizePixel = new MinimizePixel(m_fullscreenWindow);
-        minimizePixel->winId(); // force it to be a native widget (prevents problem \
                with QX11EmbedContainer)
-        connect(minimizePixel, SIGNAL(rightClicked()), m_fullscreenWindow, \
                SLOT(showMinimized()));
-        m_fullscreenWindow->installEventFilter(this);
-
-        m_fullscreenWindow->show();
-        hide();  // hide after showing the new window so it stays on the same screen
-
-        if (m_systemTrayIcon) \
                m_systemTrayIcon->setAssociatedWidget(m_fullscreenWindow);
-        showRemoteViewToolbar();
-    }
     if (m_tabWidget->currentWidget() == m_newConnectionWidget) {
         m_addressInput->setFocus();
     }
@@ -608,8 +585,8 @@
     }
 
     // if the newConnectionWidget is the only tab and we are fullscreen, switch to \
                window mode
-    if (m_fullscreenWindow && m_tabWidget->count() == 1  && \
                m_tabWidget->currentWidget() == m_newConnectionWidget) {
-        switchFullscreen();
+    if (isFullScreen() && m_tabWidget->count() == 1  && m_tabWidget->currentWidget() \
== m_newConnectionWidget) { +        switchFullScreen(false);
     }
 }
 
@@ -637,8 +614,8 @@
     }
 
     // if the newConnectionWidget is the only tab and we are fullscreen, switch to \
                window mode
-    if (m_fullscreenWindow && m_tabWidget->count() == 1  && \
                m_tabWidget->currentWidget() == m_newConnectionWidget) {
-        switchFullscreen();
+    if (isFullScreen() && m_tabWidget->count() == 1  && m_tabWidget->currentWidget() \
== m_newConnectionWidget) { +        switchFullScreen(false);
     }
 }
 
@@ -794,7 +771,7 @@
 
     RemoteView* view = m_remoteViewList.at(m_currentRemoteView);
     view->enableScaling(scale);
-    if (m_fullscreenWindow)
+    if (isFullScreen())
         view->hostPreferences()->setFullscreenScale(scale);
     else
         view->hostPreferences()->setWindowedScale(scale);
@@ -807,11 +784,7 @@
     kDebug(5010);
 
     if (!m_toolBar) {
-        actionCollection()->action("switch_fullscreen")->setIcon(KIcon("view-restore"));
                
-        actionCollection()->action("switch_fullscreen")->setText(i18n("Switch to \
                Window Mode"));
-        actionCollection()->action("switch_fullscreen")->setIconText(i18n("Window \
                Mode"));
-
-        m_toolBar = new FloatingToolBar(m_fullscreenWindow, m_fullscreenWindow);
+        m_toolBar = new FloatingToolBar(m_tabWidget, this);
         m_toolBar->winId(); // force it to be a native widget (prevents problem with \
QX11EmbedContainer)  m_toolBar->setSide(FloatingToolBar::Top);
 
@@ -827,12 +800,12 @@
         QToolBar *buttonBox = new QToolBar(m_toolBar);
 
         buttonBox->addAction(actionCollection()->action("new_connection"));
-        buttonBox->addAction(actionCollection()->action("switch_fullscreen"));
+        buttonBox->addAction(actionCollection()->action("fullscreen"));
 
         QAction *minimizeAction = new QAction(m_toolBar);
         minimizeAction->setIcon(KIcon("go-down"));
         minimizeAction->setText(i18n("Minimize Full Screen Window"));
-        connect(minimizeAction, SIGNAL(triggered()), m_fullscreenWindow, \
SLOT(showMinimized())); +        connect(minimizeAction, SIGNAL(triggered()), this, \
SLOT(showMinimized()));  buttonBox->addAction(minimizeAction);
 
         buttonBox->addAction(actionCollection()->action("take_screenshot"));
@@ -923,7 +896,7 @@
     else
         statusBar()->showMessage(""); // force creation of statusbar
 
-    m_tabWidget->setTabBarHidden((m_tabWidget->count() <= 1 && \
!Settings::showTabBar()) || m_fullscreenWindow); +    \
m_tabWidget->setTabBarHidden((m_tabWidget->count() <= 1 && !Settings::showTabBar()) \
                || isFullScreen());
     m_tabWidget->setTabPosition((KTabWidget::TabPosition) Settings::tabPosition());
 #if QT_VERSION >= 0x040500
     m_tabWidget->setTabsClosable(Settings::tabCloseButton());
@@ -936,7 +909,6 @@
 
     if (Settings::systemTrayIcon() && !m_systemTrayIcon) {
         m_systemTrayIcon = new SystemTrayIcon(this);
-        if(m_fullscreenWindow) \
m_systemTrayIcon->setAssociatedWidget(m_fullscreenWindow);  } else if \
(m_systemTrayIcon) {  delete m_systemTrayIcon;
         m_systemTrayIcon = 0;
@@ -1009,11 +981,13 @@
 
 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
 {
-    // check for close events from the fullscreen window.
-    if (obj == m_fullscreenWindow && event->type() == QEvent::Close) {
-        quit(true);
+    // catch fullscreen events, but only the ones switching between modes
+    if (event->type() == QEvent::WindowStateChange) {
+        QWindowStateChangeEvent *wscEvent = static_cast<QWindowStateChangeEvent \
*>(event); +        if (isFullScreen() ^ (wscEvent->oldState() == \
Qt::WindowFullScreen)) { +            fullScreenChanged();
     }
-    // allow other events to pass through.
+    }
     return QObject::eventFilter(obj, event);
 }
 
@@ -1059,7 +1033,7 @@
 {
     kDebug(5010) << index;
 
-    m_tabWidget->setTabBarHidden((m_tabWidget->count() <= 1 && \
!Settings::showTabBar()) || m_fullscreenWindow); +    \
m_tabWidget->setTabBarHidden((m_tabWidget->count() <= 1 && !Settings::showTabBar()) \
|| isFullScreen());  
     m_currentRemoteView = index;
 
--- trunk/KDE/kdenetwork/krdc/mainwindow.h #1218505:1218506
@@ -73,7 +73,7 @@
 
 protected:
     virtual void closeEvent(QCloseEvent *event);
-    bool eventFilter(QObject *obj, QEvent *event); // checks for close events on fs \
window +    bool eventFilter(QObject *obj, QEvent *event); // checks for WM \
fullscreen events  virtual void saveProperties(KConfigGroup &group);
     void saveHostPrefs(RemoteView *view = 0);
 
@@ -89,7 +89,8 @@
     void statusChanged(RemoteView::RemoteStatus status);
     void showRemoteViewToolbar();
     void takeScreenshot();
-    void switchFullscreen();
+    void switchFullScreen(bool makeFullScreen);
+    void fullScreenChanged();
     void disconnectHost();
     void closeTab(QWidget *widget);
     void openTabSettings(QWidget *widget);
@@ -116,8 +117,7 @@
     QScrollArea *createScrollArea(QWidget *parent, RemoteView *remoteView);
     KUrl getInputUrl();
 
-    QWidget *m_fullscreenWindow;
-    QByteArray m_mainWindowGeometry;
+    bool m_saveSettingsDisabled;
 
     KToggleAction *m_menubarAction;
     TabbedViewWidget *m_tabWidget;
@@ -148,6 +148,7 @@
 #include <QApplication>
 #include <QDesktopWidget>
 #include <QMouseEvent>
+#include <KDebug>
 
 class MinimizePixel : public QWidget
 {
@@ -156,7 +157,9 @@
     MinimizePixel(QWidget *parent)
             : QWidget(parent) {
         setFixedSize(1, 1);
-        move(QApplication::desktop()->screenGeometry().width() - 1, 0);
+        move(0, 0);
+        kDebug(5010) << parent->width() << parent->x() << parent->y();
+//        move(QApplication::desktop()->screenGeometry().width() - 1, 0);
     }
 
 signals:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic