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

List:       kde-commits
Subject:    extragear/utils/yakuake
From:       Eike Hein <hein () kde ! org>
Date:       2009-12-30 17:48:14
Message-ID: 1262195294.733254.5183.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1067826 by hein:

Show an appropriate icon on the labels of tabs with Prevent
Closing enabled. Patch by Gustavo Ribeiro Croscato and me.


 M  +5 -1      ChangeLog  
 M  +2 -0      app/main.cpp  
 M  +7 -1      app/mainwindow.cpp  
 M  +40 -16    app/skin.cpp  
 M  +18 -3     app/skin.h  
 M  +18 -0     app/tabbar.cpp  
 M  +1 -0      skins/default/CMakeLists.txt  
 M  +2 -1      skins/default/tabs.skin  
 AM            skins/default/tabs/lock.png  
 M  +1 -0      skins/plastik_dark/CMakeLists.txt  
 M  +2 -1      skins/plastik_dark/tabs.skin  
 AM            skins/plastik_dark/tabs/lock.png  
 M  +1 -0      skins/plastik_light/CMakeLists.txt  
 M  +2 -1      skins/plastik_light/tabs.skin  
 AM            skins/plastik_light/tabs/lock.png  


--- trunk/extragear/utils/yakuake/ChangeLog #1067825:1067826
@@ -1,7 +1,11 @@
 Changes since 2.9.6:
 * Fixed compilation with gcc 4.4 (missing cstdio include).
-* Fixed quit acction bypassing the "Confirm quit when more than one session
+* Fixed quit action bypassing the "Confirm quit when more than one session
   is open" setting.
+* When "Prevent Closing" is toggled for a tab an appropriate icon will now
+  be shown on the tab label. The icon can be provided by the skin, or, if
+  the skin does not provide one, it will be procured from the system icon
+  theme.
 
 
 Changes in 2.9.6:
--- trunk/extragear/utils/yakuake/app/main.cpp #1067825:1067826
@@ -62,6 +62,8 @@
         ki18nc("@info:credit", "Plastik skin"), "dd@accentsolution.com");
     aboutData.addCredit(ki18nc("@info:credit", "Juan Carlos Torres"),
         ki18nc("@info:credit", "Tab bar drag and drop support, Prevent Closing \
toggle"), "carlosdgtorres@gmail.com"); +    \
aboutData.addCredit(ki18nc("@info:credit", "Gustavo Ribeiro Croscato"), +        \
ki18nc("@info:credit", "Icon on tabs with Prevent Closing enabled"), \
"croscato@gmail.com");  
     KCmdLineArgs::init(argc, argv, &aboutData);
 
--- trunk/extragear/utils/yakuake/app/mainwindow.cpp #1067825:1067826
@@ -41,6 +41,7 @@
 #include <KStandardAction>
 #include <KToggleFullScreenAction>
 #include <KVBox>
+#include <KGlobalSettings>
 
 #include <QDesktopWidget>
 #include <QPainter>
@@ -378,8 +379,13 @@
     if (action == actionCollection()->action("toggle-session-keyboard-input"))
         m_sessionStack->setSessionKeyboardInputEnabled(sessionId, !checked);
 
-    if (action == actionCollection()->action("toggle-session-prevent-closing"))
+    if (action == actionCollection()->action("toggle-session-prevent-closing")) {
         m_sessionStack->setSessionClosable(sessionId, !checked);
+
+        // Repaint the tab bar when the Prevent Closing action is toggled
+        // so the lock icon is added to or removed from the tab label.
+        m_tabBar->repaint();
+    }
 }
 
 void MainWindow::setContextDependentActionsQuiet(bool quiet)
--- trunk/extragear/utils/yakuake/app/skin.cpp #1067825:1067826
@@ -6,7 +6,7 @@
   published by the Free Software Foundation; either version 2 of
   the License or (at your option) version 3 or any later version
   accepted by the membership of KDE e.V. (or its successor appro-
-  ved by the membership of KDE e.V.), which shall act as a proxy 
+  ved by the membership of KDE e.V.), which shall act as a proxy
   defined in Section 14 of version 3 of the license.
 
   This program is distributed in the hope that it will be useful,
@@ -23,13 +23,15 @@
 
 #include <KConfig>
 #include <KConfigGroup>
+#include <KIcon>
+#include <KGlobalSettings>
 #include <KStandardDirs>
 
 #include <QFileInfo>
 #include <QUrl>
 
 
-Skin::Skin() 
+Skin::Skin()
 {
 }
 
@@ -45,6 +47,9 @@
     if (!QFile::exists(titlePath) || !QFile::exists(tabPath))
         return false;
 
+    connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)), this, \
SLOT(systemIconsChanged(int)), +        Qt::UniqueConnection);
+
     QString titleDir(QFileInfo(titlePath).absolutePath());
     QString tabDir(QFileInfo(tabPath).absolutePath());
 
@@ -54,8 +59,8 @@
 
     KConfigGroup border = titleConfig.group("Border");
 
-    m_borderColor = QColor(border.readEntry("red", 0), 
-                           border.readEntry("green", 0), 
+    m_borderColor = QColor(border.readEntry("red", 0),
+                           border.readEntry("green", 0),
                            border.readEntry("blue", 0));
 
     m_borderWidth = border.readEntry("width", 1);
@@ -71,7 +76,7 @@
     KConfigGroup titleBarFocusButton = titleConfig.group("FocusButton");
 
     m_titleBarFocusButtonPosition.setX(titleBarFocusButton.readEntry("x", 0));
-    m_titleBarFocusButtonPosition.setY(titleBarFocusButton.readEntry("y", 0));  
+    m_titleBarFocusButtonPosition.setY(titleBarFocusButton.readEntry("y", 0));
 
     m_titleBarFocusButtonStyleSheet = buttonStyleSheet(titleDir + \
                titleBarFocusButton.readEntry("up_image", ""),
                                                        titleDir + \
titleBarFocusButton.readEntry("over_image", ""), @@ -81,7 +86,7 @@
     KConfigGroup titleBarMenuButton = titleConfig.group("ConfigButton");
 
     m_titleBarMenuButtonPosition.setX(titleBarMenuButton.readEntry("x", 0));
-    m_titleBarMenuButtonPosition.setY(titleBarMenuButton.readEntry("y", 0));  
+    m_titleBarMenuButtonPosition.setY(titleBarMenuButton.readEntry("y", 0));
 
     m_titleBarMenuButtonStyleSheet = buttonStyleSheet(titleDir + \
                titleBarMenuButton.readEntry("up_image", ""),
                                                         titleDir + \
titleBarMenuButton.readEntry("over_image", ""), @@ -91,7 +96,7 @@
     KConfigGroup titleBarQuitButton = titleConfig.group("QuitButton");
 
     m_titleBarQuitButtonPosition.setX(titleBarQuitButton.readEntry("x", 0));
-    m_titleBarQuitButtonPosition.setY(titleBarQuitButton.readEntry("y", 0));  
+    m_titleBarQuitButtonPosition.setY(titleBarQuitButton.readEntry("y", 0));
 
     m_titleBarQuitButtonStyleSheet = buttonStyleSheet(titleDir + \
                titleBarQuitButton.readEntry("up_image", ""),
                                                       titleDir + \
titleBarQuitButton.readEntry("over_image", ""), @@ -103,10 +108,10 @@
     m_titleBarText = titleBarText.readEntry("text", "");
 
     m_titleBarTextPosition.setX(titleBarText.readEntry("x", 0));
-    m_titleBarTextPosition.setY(titleBarText.readEntry("y", 0));  
+    m_titleBarTextPosition.setY(titleBarText.readEntry("y", 0));
 
-    m_titleBarTextColor = QColor(titleBarText.readEntry("red", 0), 
-                                 titleBarText.readEntry("green", 0), 
+    m_titleBarTextColor = QColor(titleBarText.readEntry("red", 0),
+                                 titleBarText.readEntry("green", 0),
                                  titleBarText.readEntry("blue", 0));
 
 
@@ -114,10 +119,10 @@
     KConfigGroup tabBar = tabConfig.group("Tabs");
 
     m_tabBarPosition.setX(tabBar.readEntry("x", 0));
-    m_tabBarPosition.setY(tabBar.readEntry("y", 0)); 
+    m_tabBarPosition.setY(tabBar.readEntry("y", 0));
 
-    m_tabBarTextColor = QColor(tabBar.readEntry("red", 0), 
-                               tabBar.readEntry("green", 0), 
+    m_tabBarTextColor = QColor(tabBar.readEntry("red", 0),
+                               tabBar.readEntry("green", 0),
                                tabBar.readEntry("blue", 0));
 
     m_tabBarSeparatorImage.load(tabDir + tabBar.readEntry("separator_image", ""));
@@ -126,7 +131,9 @@
     m_tabBarSelectedLeftCornerImage.load(tabDir + \
                tabBar.readEntry("selected_left_corner", ""));
     m_tabBarSelectedRightCornerImage.load(tabDir + \
tabBar.readEntry("selected_right_corner", ""));  
+    m_tabBarPreventClosingImage.load(tabDir + \
tabBar.readEntry("prevent_closing_image", ""));  
+
     KConfigGroup tabBarBackground = tabConfig.group("Background");
 
     m_tabBarBackgroundImage.load(tabDir + tabBarBackground.readEntry("back_image", \
"")); @@ -137,7 +144,7 @@
     KConfigGroup tabBarNewTabButton = tabConfig.group("PlusButton");
 
     m_tabBarNewTabButtonPosition.setX(tabBarNewTabButton.readEntry("x", 0));
-    m_tabBarNewTabButtonPosition.setY(tabBarNewTabButton.readEntry("y", 0));  
+    m_tabBarNewTabButtonPosition.setY(tabBarNewTabButton.readEntry("y", 0));
 
     m_tabBarNewTabButtonStyleSheet = buttonStyleSheet(tabDir + \
                tabBarNewTabButton.readEntry("up_image", ""),
                                                       tabDir + \
tabBarNewTabButton.readEntry("over_image", ""), @@ -147,13 +154,12 @@
     KConfigGroup tabBarCloseTabButton = tabConfig.group("MinusButton");
 
     m_tabBarCloseTabButtonPosition.setX(tabBarCloseTabButton.readEntry("x", 0));
-    m_tabBarCloseTabButtonPosition.setY(tabBarCloseTabButton.readEntry("y", 0));  
+    m_tabBarCloseTabButtonPosition.setY(tabBarCloseTabButton.readEntry("y", 0));
 
     m_tabBarCloseTabButtonStyleSheet = buttonStyleSheet(tabDir + \
                tabBarCloseTabButton.readEntry("up_image", ""),
                                                         tabDir + \
                tabBarCloseTabButton.readEntry("over_image", ""),
                                                         tabDir + \
tabBarCloseTabButton.readEntry("down_image", ""));  
-
     return true;
 }
 
@@ -185,3 +191,21 @@
 
     return styleSheet;
 }
+
+const QPixmap Skin::tabBarPreventClosingImage()
+{
+    // If the skin. doesn't provide a Prevent Closing image, procure one
+    // from the system icon theme.
+    if (m_tabBarPreventClosingImage.isNull())
+        return KIcon("object-locked.png").pixmap(QSize(32, 32));
+
+    return m_tabBarPreventClosingImage;
+}
+
+void Skin::systemIconsChanged(int group)
+{
+    Q_UNUSED(group);
+
+    if (m_tabBarPreventClosingImage.isNull())
+        emit iconChanged();
+}
--- trunk/extragear/utils/yakuake/app/skin.h #1067825:1067826
@@ -6,7 +6,7 @@
   published by the Free Software Foundation; either version 2 of
   the License or (at your option) version 3 or any later version
   accepted by the membership of KDE e.V. (or its successor appro-
-  ved by the membership of KDE e.V.), which shall act as a proxy 
+  ved by the membership of KDE e.V.), which shall act as a proxy
   defined in Section 14 of version 3 of the license.
 
   This program is distributed in the hope that it will be useful,
@@ -23,12 +23,15 @@
 #define SKIN_H
 
 
+#include <QObject>
 #include <QPixmap>
 #include <QString>
 
 
-class Skin
+class Skin : public QObject
 {
+    Q_OBJECT
+
     public:
         explicit Skin();
         ~Skin();
@@ -67,6 +70,8 @@
         const QPixmap& tabBarSelectedLeftCornerImage() { return \
                m_tabBarSelectedLeftCornerImage; }
         const QPixmap& tabBarSelectedRightCornerImage() { return \
m_tabBarSelectedRightCornerImage; }  
+        const QPixmap tabBarPreventClosingImage();
+
         const QPixmap& tabBarBackgroundImage() { return m_tabBarBackgroundImage; }
         const QPixmap& tabBarLeftCornerImage() { return m_tabBarLeftCornerImage; }
         const QPixmap& tabBarRightCornerImage() { return m_tabBarRightCornerImage; }
@@ -78,6 +83,14 @@
         const QString tabBarCloseTabButtonStyleSheet() { return \
m_tabBarCloseTabButtonStyleSheet; }  
 
+    signals:
+        void iconChanged();
+
+
+    private slots:
+        void systemIconsChanged(int group);
+
+
     private:
         const QString buttonStyleSheet(const QString& up, const QString& over, const \
QString& down);  
@@ -112,13 +125,15 @@
         QPixmap m_tabBarSelectedLeftCornerImage;
         QPixmap m_tabBarSelectedRightCornerImage;
 
+        QPixmap m_tabBarPreventClosingImage;
+
         QPixmap m_tabBarBackgroundImage;
         QPixmap m_tabBarLeftCornerImage;
         QPixmap m_tabBarRightCornerImage;
 
         QPoint m_tabBarNewTabButtonPosition;
         QString m_tabBarNewTabButtonStyleSheet;
-        
+
         QPoint m_tabBarCloseTabButtonPosition;
         QString m_tabBarCloseTabButtonStyleSheet;
 };
--- trunk/extragear/utils/yakuake/app/tabbar.cpp #1067825:1067826
@@ -58,7 +58,9 @@
     m_dropIndicator = 0;
 
     m_mainWindow = mainWindow;
+
     m_skin = mainWindow->skin();
+    connect(m_skin, SIGNAL(iconChanged()), this, SLOT(repaint()));
 
     m_tabContextMenu = new KMenu(this);
     connect(m_tabContextMenu, SIGNAL(hovered(QAction*)), this, \
SLOT(contextMenuActionHovered(QAction*))); @@ -361,6 +363,22 @@
     QFontMetrics fontMetrics(font);
     textWidth = fontMetrics.width(title) + 10;
 
+    // Draw the Prevent Closing image in the tab button.
+    if (m_mainWindow->sessionStack()->isSessionClosable(sessionId) == false)
+    {
+        QPixmap preventClosingImage = \
m_skin->tabBarPreventClosingImage().scaled(height() - 4, height() - 4, +            \
Qt::KeepAspectRatio, Qt::SmoothTransformation); +
+        if (selected)
+            painter.drawTiledPixmap(x, y, preventClosingImage.width(), height(), \
m_skin->tabBarSelectedBackgroundImage()); +        else
+            painter.drawTiledPixmap(x, y, preventClosingImage.width(), height(), \
m_skin->tabBarUnselectedBackgroundImage()); +
+        painter.drawPixmap(x + 1, (height() / 2) - (preventClosingImage.height() / \
2), preventClosingImage); +
+        x += preventClosingImage.width();
+    }
+
     if (selected)
         painter.drawTiledPixmap(x, y, textWidth, height(), \
m_skin->tabBarSelectedBackgroundImage());  else
--- trunk/extragear/utils/yakuake/skins/default/CMakeLists.txt #1067825:1067826
@@ -19,6 +19,7 @@
     tabs/selected_right.png
     tabs/separator.png
     tabs/unselected_back.png
+    tabs/lock.png
     DESTINATION ${DATA_INSTALL_DIR}/yakuake/skins/default/tabs)
 
 install(FILES
--- trunk/extragear/utils/yakuake/skins/default/tabs.skin #1067825:1067826
@@ -15,6 +15,7 @@
 selected_left_corner=/tabs/selected_left.png
 selected_right_corner=/tabs/selected_right.png
 unselected_background=/tabs/unselected_back.png
+prevent_closing_image=/tabs/lock.png
 
 [Background]
 back_image=/tabs/back_image.png
@@ -33,4 +34,4 @@
 y=2
 up_image=/tabs/minus_up.png
 over_image=/tabs/minus_over.png
-down_image=/tabs/minus_down.png
+down_image=/tabs/minus_down.png
\ No newline at end of file
** trunk/extragear/utils/yakuake/skins/default/tabs/lock.png #property svn:mime-type
   + application/octet-stream
--- trunk/extragear/utils/yakuake/skins/plastik_dark/CMakeLists.txt #1067825:1067826
@@ -19,6 +19,7 @@
     tabs/selected_right.png
     tabs/separator.png
     tabs/unselected_back.png
+    tabs/lock.png
     DESTINATION ${DATA_INSTALL_DIR}/yakuake/skins/plastik_dark/tabs)
 
 install(FILES
--- trunk/extragear/utils/yakuake/skins/plastik_dark/tabs.skin #1067825:1067826
@@ -15,6 +15,7 @@
 selected_left_corner=/tabs/selected_left.png
 selected_right_corner=/tabs/selected_right.png
 unselected_background=/tabs/unselected_back.png
+prevent_closing_image=/tabs/lock.png
 
 [Background]
 back_image=/tabs/back_image.png
@@ -33,4 +34,4 @@
 y=0
 up_image=/tabs/minus_up.png
 over_image=/tabs/minus_over.png
-down_image=/tabs/minus_down.png
+down_image=/tabs/minus_down.png
\ No newline at end of file
** trunk/extragear/utils/yakuake/skins/plastik_dark/tabs/lock.png #property \
svn:mime-type  + application/octet-stream
--- trunk/extragear/utils/yakuake/skins/plastik_light/CMakeLists.txt #1067825:1067826
@@ -19,6 +19,7 @@
     tabs/selected_right.png
     tabs/separator.png
     tabs/unselected_back.png
+    tabs/lock.png
     DESTINATION ${DATA_INSTALL_DIR}/yakuake/skins/plastik_light/tabs)
 
 install(FILES
--- trunk/extragear/utils/yakuake/skins/plastik_light/tabs.skin #1067825:1067826
@@ -15,6 +15,7 @@
 selected_left_corner=/tabs/selected_left.png
 selected_right_corner=/tabs/selected_right.png
 unselected_background=/tabs/unselected_back.png
+prevent_closing_image=/tabs/lock.png
 
 [Background]
 back_image=/tabs/back_image.png
@@ -33,4 +34,4 @@
 y=0
 up_image=/tabs/minus_up.png
 over_image=/tabs/minus_over.png
-down_image=/tabs/minus_down.png
+down_image=/tabs/minus_down.png
\ No newline at end of file
** trunk/extragear/utils/yakuake/skins/plastik_light/tabs/lock.png #property \
svn:mime-type  + application/octet-stream


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

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