new TabWidget - contains "info" icon/button to show "AboutApplication" dialog
authorpavelpa <pavelpa@localhost>
Tue, 26 Jan 2010 07:29:07 +0000 (07:29 +0000)
committerpavelpa <pavelpa@localhost>
Tue, 26 Jan 2010 07:29:07 +0000 (07:29 +0000)
src/gui/mainwindow.ui
src/gui/tabwidget.cpp [new file with mode: 0644]
src/gui/tabwidget.h [new file with mode: 0644]

index a01b8ef..021d64e 100644 (file)
@@ -21,7 +21,7 @@
   <widget class="QWidget" name="centralwidget" >
    <layout class="QGridLayout" name="gridLayout" >
     <item row="0" column="0" >
-     <widget class="QTabWidget" name="tabWidget" >
+     <widget class="TabWidget" name="tabWidget" >
       <property name="currentIndex" >
        <number>0</number>
       </property>
         </item>
        </layout>
       </widget>
-      <widget class="QWidget" name="searchTab">
-       <attribute name="title">
+      <widget class="QWidget" name="searchTab" >
+       <attribute name="title" >
         <string>Search</string>
        </attribute>
-       <layout class="QHBoxLayout" name="horizontalLayout_1">
+       <layout class="QHBoxLayout" name="horizontalLayout_1" >
         <item>
-         <widget class="QWidget" name="searchVerticalWidget" native="true">
-          <property name="enabled">
+         <widget class="QWidget" native="1" name="searchVerticalWidget" >
+          <property name="enabled" >
            <bool>true</bool>
           </property>
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
-          <layout class="QVBoxLayout" name="searchDayNavigatorVerticalLayout">
+          <layout class="QVBoxLayout" name="searchDayNavigatorVerticalLayout" >
            <item>
-            <widget class="QToolButton" name="searchAgainButton">
-             <property name="toolTip">
+            <widget class="QToolButton" name="searchAgainButton" >
+             <property name="toolTip" >
               <string>Search again</string>
              </property>
-             <property name="text">
+             <property name="text" >
               <string>S</string>
              </property>
-             <property name="toolButtonStyle">
+             <property name="toolButtonStyle" >
               <enum>Qt::ToolButtonTextOnly</enum>
              </property>
             </widget>
            </item>
            <item>
-            <widget class="DayNavigatorWidget" name="searchDayNavigator" native="true">
-             <property name="maximumSize">
+            <widget class="DayNavigatorWidget" native="1" name="searchDayNavigator" >
+             <property name="maximumSize" >
               <size>
                <width>16777215</width>
                <height>16777215</height>
          </widget>
         </item>
         <item>
-         <layout class="QVBoxLayout" name="verticalLayout_3">
+         <layout class="QVBoxLayout" name="verticalLayout_3" >
           <item>
-           <widget class="QWidget" name="searchHead" native="true">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+           <widget class="QWidget" native="1" name="searchHead" >
+            <property name="sizePolicy" >
+             <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="maximumSize">
+            <property name="maximumSize" >
              <size>
               <width>16777215</width>
               <height>16777215</height>
              </size>
             </property>
-            <layout class="QGridLayout" name="searchHeadLayout">
-             <property name="sizeConstraint">
+            <layout class="QGridLayout" name="searchHeadLayout" >
+             <property name="sizeConstraint" >
               <enum>QLayout::SetDefaultConstraint</enum>
              </property>
-             <item row="2" column="0">
-              <layout class="QHBoxLayout" name="horizontalLayout">
+             <item row="2" column="0" >
+              <layout class="QHBoxLayout" name="horizontalLayout" >
                <item>
-                <widget class="QLineEdit" name="searchEdit">
-                 <property name="enabled">
+                <widget class="QLineEdit" name="searchEdit" >
+                 <property name="enabled" >
                   <bool>true</bool>
                  </property>
-                 <property name="toolTip">
+                 <property name="toolTip" >
                   <string>type a keyword to search</string>
                  </property>
                 </widget>
                </item>
                <item>
-                <widget class="QPushButton" name="searchButton">
-                 <property name="text">
+                <widget class="QPushButton" name="searchButton" >
+                 <property name="text" >
                   <string>Search</string>
                  </property>
-                 <property name="checkable">
+                 <property name="checkable" >
                   <bool>false</bool>
                  </property>
-                 <property name="autoDefault">
+                 <property name="autoDefault" >
                   <bool>true</bool>
                  </property>
-                 <property name="default">
+                 <property name="default" >
                   <bool>true</bool>
                  </property>
-                 <property name="flat">
+                 <property name="flat" >
                   <bool>false</bool>
                  </property>
                 </widget>
                </item>
               </layout>
              </item>
-             <item row="0" column="0">
-              <layout class="QHBoxLayout" name="horizontalLayout_6">
+             <item row="0" column="0" >
+              <layout class="QHBoxLayout" name="horizontalLayout_6" >
                <item>
-                <widget class="QCheckBox" name="searchTitle">
-                 <property name="text">
+                <widget class="QCheckBox" name="searchTitle" >
+                 <property name="text" >
                   <string>Title</string>
                  </property>
-                 <property name="checked">
+                 <property name="checked" >
                   <bool>true</bool>
                  </property>
                 </widget>
                </item>
                <item>
-                <widget class="QCheckBox" name="searchAbstract">
-                 <property name="text">
+                <widget class="QCheckBox" name="searchAbstract" >
+                 <property name="text" >
                   <string>Abstract</string>
                  </property>
                 </widget>
                </item>
                <item>
-                <widget class="QCheckBox" name="searchSpeaker">
-                 <property name="text">
+                <widget class="QCheckBox" name="searchSpeaker" >
+                 <property name="text" >
                   <string>Speaker</string>
                  </property>
                 </widget>
                </item>
                <item>
-                <widget class="QCheckBox" name="searchTag">
-                 <property name="text">
+                <widget class="QCheckBox" name="searchTag" >
+                 <property name="text" >
                   <string>Tag</string>
                  </property>
                 </widget>
                </item>
                <item>
-                <widget class="QCheckBox" name="searchRoom">
-                 <property name="text">
+                <widget class="QCheckBox" name="searchRoom" >
+                 <property name="text" >
                   <string>Room</string>
                  </property>
                 </widget>
                </item>
                <item>
-                <spacer name="horizontalSpacer">
-                 <property name="orientation">
+                <spacer name="horizontalSpacer" >
+                 <property name="orientation" >
                   <enum>Qt::Horizontal</enum>
                  </property>
-                 <property name="sizeHint" stdset="0">
+                 <property name="sizeHint" stdset="0" >
                   <size>
                    <width>40</width>
                    <height>20</height>
            </widget>
           </item>
           <item>
-           <widget class="TreeView" name="searchTreeView">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+           <widget class="TreeView" name="searchTreeView" >
+            <property name="sizePolicy" >
+             <sizepolicy vsizetype="MinimumExpanding" hsizetype="Expanding" >
               <horstretch>0</horstretch>
               <verstretch>1</verstretch>
              </sizepolicy>
             </property>
-            <property name="minimumSize">
+            <property name="minimumSize" >
              <size>
               <width>0</width>
               <height>0</height>
              </size>
             </property>
-            <property name="maximumSize">
+            <property name="maximumSize" >
              <size>
               <width>16777215</width>
               <height>16777215</height>
              </size>
             </property>
-            <attribute name="headerDefaultSectionSize">
-             <number>100</number>
-            </attribute>
            </widget>
           </item>
           <item>
-           <spacer name="verticalSpacer_2">
-            <property name="orientation">
+           <spacer name="verticalSpacer_2" >
+            <property name="orientation" >
              <enum>Qt::Vertical</enum>
             </property>
-            <property name="sizeType">
+            <property name="sizeType" >
              <enum>QSizePolicy::Expanding</enum>
             </property>
-            <property name="sizeHint" stdset="0">
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>20</width>
               <height>1</height>
    <extends>QTreeView</extends>
    <header>../mvc/treeview.h</header>
   </customwidget>
+  <customwidget>
+   <class>TabWidget</class>
+   <extends>QTabWidget</extends>
+   <header>tabwidget.h</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections>
diff --git a/src/gui/tabwidget.cpp b/src/gui/tabwidget.cpp
new file mode 100644 (file)
index 0000000..8fdfb72
--- /dev/null
@@ -0,0 +1,37 @@
+#include "tabwidget.h"
+
+#include <QMouseEvent>
+#include <QPainter>
+
+#include <QDebug>
+
+const int SPACER = 5;
+
+TabWidget::TabWidget(QWidget *aParent)
+    : QTabWidget(aParent)
+    , mPressPoint(0,0)
+{
+    mInfoImage = QImage(":/icons/info.png");
+}
+
+void TabWidget::paintEvent(QPaintEvent *event)
+{
+    QPainter painter(this);
+    painter.drawImage(rect().topRight()-QPoint(mInfoImage.width()+SPACER,-SPACER),mInfoImage);
+}
+
+void TabWidget::mousePressEvent(QMouseEvent *event)
+{
+    mPressPoint = event->pos();
+}
+
+void TabWidget::mouseReleaseEvent(QMouseEvent *event)
+{
+    QPoint topLeft = rect().topRight()-QPoint(mInfoImage.width()+SPACER,-SPACER);
+    QRect infoRect = QRect(topLeft, topLeft+QPoint(mInfoImage.width(),mInfoImage.height()));
+    if( (infoRect.contains(event->pos())) && (infoRect.contains(mPressPoint)) )
+    {
+        emit(infoIconClicked());
+    }
+}
+
diff --git a/src/gui/tabwidget.h b/src/gui/tabwidget.h
new file mode 100644 (file)
index 0000000..6d73408
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef TABWIDGET_H
+#define TABWIDGET_H
+
+#include <QTabWidget>
+
+class TabWidget : public QTabWidget
+{
+    Q_OBJECT
+public:
+    TabWidget(QWidget *aParent = NULL);
+    ~TabWidget() {}
+protected:
+    void paintEvent(QPaintEvent *event);
+    void mousePressEvent(QMouseEvent *event);
+    void mouseReleaseEvent(QMouseEvent *event);
+signals:
+    void infoIconClicked();
+private:
+    QPoint mPressPoint;
+    QImage mInfoImage;
+};
+
+#endif /* TABWIDGET_H */
+