OSDN Git Service

検索ボックスをツールバー右側に移動&改良した
authoryuki <kimaira7@gmail.com>
Mon, 16 Dec 2013 06:36:07 +0000 (15:36 +0900)
committeryuki <kimaira7@gmail.com>
Mon, 16 Dec 2013 06:36:07 +0000 (15:36 +0900)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/gui/SearchClearButton.java [new file with mode: 0644]
src/cx/fbn/nevernote/gui/SearchEdit.java [new file with mode: 0644]
src/cx/fbn/nevernote/gui/ZoomPanel.java [moved from src/cx/fbn/nevernote/gui/SearchPanel.java with 73% similarity]
src/cx/fbn/nevernote/icons/clear.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/clearActive.png [new file with mode: 0644]
src/cx/fbn/nevernote/icons/clearPressed.png [new file with mode: 0644]

index 0a1a9a2..cec0514 100644 (file)
@@ -104,7 +104,6 @@ import com.trolltech.qt.gui.QApplication;
 import com.trolltech.qt.gui.QClipboard;
 import com.trolltech.qt.gui.QCloseEvent;
 import com.trolltech.qt.gui.QColor;
-import com.trolltech.qt.gui.QComboBox;
 import com.trolltech.qt.gui.QCursor;
 import com.trolltech.qt.gui.QDesktopServices;
 import com.trolltech.qt.gui.QDialog;
@@ -116,7 +115,6 @@ import com.trolltech.qt.gui.QHBoxLayout;
 import com.trolltech.qt.gui.QIcon;
 import com.trolltech.qt.gui.QImage;
 import com.trolltech.qt.gui.QKeySequence;
-import com.trolltech.qt.gui.QLabel;
 import com.trolltech.qt.gui.QListWidgetItem;
 import com.trolltech.qt.gui.QMainWindow;
 import com.trolltech.qt.gui.QMenu;
@@ -129,7 +127,6 @@ import com.trolltech.qt.gui.QPrintDialog;
 import com.trolltech.qt.gui.QPrinter;
 import com.trolltech.qt.gui.QShortcut;
 import com.trolltech.qt.gui.QSizePolicy;
-import com.trolltech.qt.gui.QSizePolicy.Policy;
 import com.trolltech.qt.gui.QSpinBox;
 import com.trolltech.qt.gui.QSplashScreen;
 import com.trolltech.qt.gui.QSplitter;
@@ -139,6 +136,7 @@ import com.trolltech.qt.gui.QTableWidgetItem;
 import com.trolltech.qt.gui.QTextEdit;
 import com.trolltech.qt.gui.QToolBar;
 import com.trolltech.qt.gui.QTreeWidgetItem;
+import com.trolltech.qt.gui.QWidget;
 import com.trolltech.qt.network.QNetworkAccessManager;
 import com.trolltech.qt.network.QNetworkProxy;
 import com.trolltech.qt.network.QNetworkProxy.ProxyType;
@@ -185,13 +183,14 @@ import cx.fbn.nevernote.gui.NotebookTreeWidget;
 import cx.fbn.nevernote.gui.RensoNoteList;
 import cx.fbn.nevernote.gui.RensoNoteListDock;
 import cx.fbn.nevernote.gui.SavedSearchTreeWidget;
-import cx.fbn.nevernote.gui.SearchPanel;
+import cx.fbn.nevernote.gui.SearchEdit;
 import cx.fbn.nevernote.gui.TabBrowse;
 import cx.fbn.nevernote.gui.TabBrowserWidget;
 import cx.fbn.nevernote.gui.TableView;
 import cx.fbn.nevernote.gui.TagTreeWidget;
 import cx.fbn.nevernote.gui.Thumbnailer;
 import cx.fbn.nevernote.gui.TrashTreeWidget;
+import cx.fbn.nevernote.gui.ZoomPanel;
 import cx.fbn.nevernote.gui.controls.QuotaProgressBar;
 import cx.fbn.nevernote.oauth.OAuthTokenizer;
 import cx.fbn.nevernote.oauth.OAuthWindow;
@@ -237,7 +236,7 @@ public class NeverNote extends QMainWindow{
 
     public BrowserWindow       browserWindow;                          // Window containing browser & labels
     public QToolBar            toolBar;                                        // The tool bar under the menu
-    QComboBox                          searchField;                            // search filter bar on the toolbar;
+    SearchEdit                         searchField;                            // search filter bar on the toolbar;
     QShortcut                          searchShortcut;                         // Shortcut to search bar
     boolean                                    searchPerformed = false;        // Search was done?
     QuotaProgressBar           quotaBar;                                       // The current quota usage
@@ -308,7 +307,7 @@ public class NeverNote extends QMainWindow{
     QSpinBox                   zoomSpinner;                            // Zoom zoom
     QAction                            searchClearButton;                      // Clear the search field
     
-    SearchPanel                        searchLayout;                           // Widget to hold search field, zoom, & quota
+    ZoomPanel                  zoomLayout;                                     // Widget to hold search field, zoom, & quota
     
     QSplitter                  mainLeftRightSplitter;          // main splitter for left/right side
     QSplitter                  leftSplitter1;                          // first left hand splitter
@@ -545,17 +544,6 @@ public class NeverNote extends QMainWindow{
         trashTree = new TrashTreeWidget();
                noteTableView = new TableView(logger, listManager, this);     
         
-        searchField = new QComboBox();
-        searchField.setObjectName("searchField");
-        //setStyleSheet("QComboBox#searchField { background-color: yellow }");
-        searchField.setEditable(true);
-       searchField.activatedIndex.connect(this, "searchFieldChanged()");
-       searchField.setDuplicatesEnabled(false);
-       searchField.editTextChanged.connect(this,"searchFieldTextChanged(String)");
-       searchShortcut = new QShortcut(this);
-       setupShortcut(searchShortcut, "Focus_Search");
-       searchShortcut.activated.connect(this, "focusSearch()");
-        
        quotaBar = new QuotaProgressBar();
        // Setup the zoom
        zoomSpinner = new QSpinBox();
@@ -566,13 +554,13 @@ public class NeverNote extends QMainWindow{
        zoomSpinner.setValue(100);
        zoomSpinner.valueChanged.connect(this, "zoomChanged()");
        
-       searchLayout = new SearchPanel(searchField, quotaBar, notebookTree, zoomSpinner);
+       zoomLayout = new ZoomPanel(quotaBar, notebookTree, zoomSpinner);
         
         
         QGridLayout leftGrid = new QGridLayout();
         leftSplitter1.setContentsMargins(5, 0, 0, 7);
         leftSplitter1.setLayout(leftGrid);
-       leftGrid.addWidget(searchLayout,1,1);
+       leftGrid.addWidget(zoomLayout,1,1);
         leftGrid.addWidget(tagTree,2,1);
         leftGrid.addWidget(attributeTree,3,1);
         leftGrid.addWidget(savedSearchTree,4,1);
@@ -664,7 +652,7 @@ public class NeverNote extends QMainWindow{
                listManager.tagSignal.listChanged.connect(this, "reloadTagTree()");
                
                if (!Global.isWindowVisible("zoom")) {
-                       searchLayout.hideZoom();
+                       zoomLayout.hideZoom();
                        menuBar.hideZoom.setChecked(false);
                } 
        
@@ -741,14 +729,8 @@ public class NeverNote extends QMainWindow{
                if (!Global.isWindowVisible("quota"))
                        menuBar.hideQuota.setChecked(false);
                
-               searchField.setVisible(Global.isWindowVisible("searchField"));
-               // IFIXED !searchField.isVisible() → !Global.isWindowVisible("searchField")
-               // なぜかsearchField.isVisible()が常にfalseを返すようなので修正
-               if (!Global.isWindowVisible("searchField"))
-                       menuBar.hideSearch.setChecked(false);
-               
-               if (searchField.isHidden() && quotaBar.isHidden() && zoomSpinner.isHidden() && notebookTree.isHidden())
-                       searchLayout.hide();
+               if (quotaBar.isHidden() && zoomSpinner.isHidden() && notebookTree.isHidden())
+                       zoomLayout.hide();
                
                setMenuBar(menuBar);
                setupToolBar();
@@ -1585,15 +1567,22 @@ public class NeverNote extends QMainWindow{
        @SuppressWarnings("unused")
        private void toggleSearchWindow() {
                logger.log(logger.HIGH, "Entering NeverNote.toggleSearchWindow");
-       searchLayout.toggleSearchField();
+               toggleSearchField();
        menuBar.hideSearch.setChecked(searchField.isVisible());
        Global.saveWindowVisible("searchField", searchField.isVisible());
        logger.log(logger.HIGH, "Leaving NeverNote.toggleSearchWindow");
-    }  
+    }
+       private void toggleSearchField() {
+               if (searchField.isVisible())
+                       searchField.hide();
+               else
+                       searchField.show();
+       }
+       
        @SuppressWarnings("unused")
        private void toggleQuotaWindow() {
                logger.log(logger.HIGH, "Entering NeverNote.toggleQuotaWindow");
-       searchLayout.toggleQuotaBar();
+       zoomLayout.toggleQuotaBar();
        menuBar.hideQuota.setChecked(quotaBar.isVisible());
        Global.saveWindowVisible("quota", quotaBar.isVisible());
        logger.log(logger.HIGH, "Leaving NeverNote.toggleQuotaWindow");
@@ -1601,7 +1590,7 @@ public class NeverNote extends QMainWindow{
        @SuppressWarnings("unused")
        private void toggleZoomWindow() {
                logger.log(logger.HIGH, "Entering NeverNote.toggleZoomWindow");
-       searchLayout.toggleZoom();
+       zoomLayout.toggleZoom();
        menuBar.hideZoom.setChecked(zoomSpinner.isVisible());
        Global.saveWindowVisible("zoom", zoomSpinner.isVisible());
        logger.log(logger.HIGH, "Leaving NeverNote.toggleZoomWindow");
@@ -1632,8 +1621,7 @@ public class NeverNote extends QMainWindow{
                clearSavedSearchFilter();
                if (Global.mimicEvernoteInterface) {
                        clearTagFilter();
-                       //searchField.clear();
-                       searchField.clearEditText();
+                       searchField.clear();
                }
                menuBar.noteRestoreAction.setVisible(false);            
        menuBar.notebookEditAction.setEnabled(true);
@@ -1750,7 +1738,7 @@ public class NeverNote extends QMainWindow{
        @SuppressWarnings("unused")
        private void toggleNotebookWindow() {
                logger.log(logger.HIGH, "Entering NeverNote.toggleNotebookWindow");
-               searchLayout.toggleNotebook();
+               zoomLayout.toggleNotebook();
        menuBar.hideNotebooks.setChecked(notebookTree.isVisible());
        Global.saveWindowVisible("notebookTree", notebookTree.isVisible());
        logger.log(logger.HIGH, "Leaving NeverNote.toggleNotebookWindow");
@@ -2816,7 +2804,7 @@ public class NeverNote extends QMainWindow{
        savedSearchTree.clearSelection();
        savedSearchTree.blockSignals(false);
        selectedSavedSearchGUID = "";
-       searchField.setEditText("");
+       searchField.setText("");
        searchPerformed = false;
        listManager.setSelectedSavedSearch(selectedSavedSearchGUID);
     }
@@ -2846,13 +2834,13 @@ public class NeverNote extends QMainWindow{
                menuBar.savedSearchIconAction.setEnabled(true);
                selectedSavedSearchGUID = selections.get(0).text(1);
                SavedSearch s = conn.getSavedSearchTable().getSavedSearch(selectedSavedSearchGUID);
-               searchField.setEditText(s.getQuery());
+               searchField.setText(s.getQuery());
        } else { 
                menuBar.savedSearchEditAction.setEnabled(false);
                menuBar.savedSearchDeleteAction.setEnabled(false);
                menuBar.savedSearchIconAction.setEnabled(false);
                selectedSavedSearchGUID = "";
-               searchField.setEditText("");
+               searchField.setText("");
        }
        searchFieldChanged();
        
@@ -3125,7 +3113,7 @@ public class NeverNote extends QMainWindow{
                QWebSettings.setMaximumPagesInCache(0);
                QWebSettings.setObjectCacheCapacities(0, 0, 0);
         
-               searchField.setEditText("");
+               searchField.setdefaultText();
                saveNoteColumnPositions();
                saveNoteIndexWidth();
                noteIndexUpdated(true);
@@ -3144,7 +3132,7 @@ public class NeverNote extends QMainWindow{
                QWebSettings.setMaximumPagesInCache(0);
                QWebSettings.setObjectCacheCapacities(0, 0, 0);
 
-               if (text.trim().equals("")) {
+               if (text.trim().equals("") && !searchField.hasFocus()) {
                        searchFieldCleared();
                        if (searchPerformed) {
 
@@ -3171,7 +3159,7 @@ public class NeverNote extends QMainWindow{
        inkNoteCache.clear();
        saveNoteColumnPositions();
        saveNoteIndexWidth();
-       String text = searchField.currentText();
+       String text = searchField.text();
        listManager.setEnSearch(text.trim());
        listManager.loadNotesIndex();
        noteIndexUpdated(false);
@@ -3291,13 +3279,35 @@ public class NeverNote extends QMainWindow{
        
        //toolBar.addWidget(new QLabel("                    "));
        //toolBar.addSeparator();
-       //toolBar.addWidget(new QLabel(tr("  Search:")));
-       //toolBar.addWidget(searchField);
-       QSizePolicy sizePolicy = new QSizePolicy();
-       sizePolicy.setHorizontalPolicy(Policy.MinimumExpanding);
-       QLabel spacer = new QLabel("");
-       spacer.setSizePolicy(sizePolicy);
-       toolBar.addWidget(spacer);
+       
+       // 検索ボックスを右寄せするためのスペーサ
+       QWidget spacerWidget = new QWidget();
+       spacerWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred);
+       toolBar.addWidget(spacerWidget);
+       spacerWidget.setVisible(true);
+       
+        searchField = new SearchEdit(iconPath);
+        searchField.setObjectName("searchField");
+       searchField.returnPressed.connect(this, "searchFieldChanged()");
+       searchField.textChanged.connect(this,"searchFieldTextChanged(String)");
+       searchField.setFixedWidth(300);
+       searchShortcut = new QShortcut(this);
+       setupShortcut(searchShortcut, "Focus_Search");
+       searchShortcut.activated.connect(this, "focusSearch()");
+       toolBar.addWidget(searchField);
+       
+               searchField.setVisible(Global.isWindowVisible("searchField"));
+               // IFIXED !searchField.isVisible() → !Global.isWindowVisible("searchField")
+               // なぜかsearchField.isVisible()が常にfalseを返すようなので修正
+               if (!Global.isWindowVisible("searchField"))
+                       menuBar.hideSearch.setChecked(false);
+               
+//     QSizePolicy sizePolicy = new QSizePolicy();
+//     sizePolicy.setHorizontalPolicy(Policy.MinimumExpanding);
+//     QLabel spacer = new QLabel("");
+//     spacer.setSizePolicy(sizePolicy);
+//     toolBar.addWidget(spacer);
+               
        //searchField.setInsertPolicy(InsertPolicy.InsertAtTop);
 
        //searchClearButton = toolBar.addAction("Search Clear");
diff --git a/src/cx/fbn/nevernote/gui/SearchClearButton.java b/src/cx/fbn/nevernote/gui/SearchClearButton.java
new file mode 100644 (file)
index 0000000..243a15e
--- /dev/null
@@ -0,0 +1,57 @@
+package cx.fbn.nevernote.gui;
+
+import com.trolltech.qt.core.QEvent;
+import com.trolltech.qt.core.QSize;
+import com.trolltech.qt.core.Qt;
+import com.trolltech.qt.gui.QCursor;
+import com.trolltech.qt.gui.QIcon;
+import com.trolltech.qt.gui.QMouseEvent;
+import com.trolltech.qt.gui.QPixmap;
+import com.trolltech.qt.gui.QToolButton;
+import com.trolltech.qt.gui.QWidget;
+
+public class SearchClearButton extends QToolButton {
+       private final QPixmap clearIcon;
+       private final QPixmap clearActiveIcon;
+       private final QPixmap clearPressedIcon;
+       private final String iconPath;
+       
+       public SearchClearButton(QWidget parent, String iconPath) {
+               super(parent);
+               this.iconPath = iconPath;
+               
+               clearIcon = new QPixmap(this.iconPath + "clear.png");
+               clearActiveIcon = new QPixmap(this.iconPath + "clearActive.png");
+               clearPressedIcon = new QPixmap(this.iconPath + "clearPressed.png");
+               
+               this.setIcon(new QIcon(clearIcon));
+               this.setIconSize(new QSize(16, 16));
+               this.setCursor(new QCursor(Qt.CursorShape.ArrowCursor));
+               this.setStyleSheet("QToolButton { border: none; padding: 0px; }");
+               this.hide();
+       }
+       
+       @Override
+       protected void enterEvent(QEvent e) {
+               super.enterEvent(e);
+               this.setIcon(new QIcon(clearActiveIcon));
+       }
+       
+       @Override
+       protected void leaveEvent(QEvent e) {
+               super.leaveEvent(e);
+               this.setIcon(new QIcon(clearIcon));
+       }
+       
+       @Override
+       protected void mousePressEvent(QMouseEvent e) {
+               super.mousePressEvent(e);
+               this.setIcon(new QIcon(clearPressedIcon));
+       }
+       
+       @Override
+       protected void mouseReleaseEvent(QMouseEvent e) {
+               super.mouseReleaseEvent(e);
+               this.setIcon(new QIcon(clearIcon));
+       }
+}
diff --git a/src/cx/fbn/nevernote/gui/SearchEdit.java b/src/cx/fbn/nevernote/gui/SearchEdit.java
new file mode 100644 (file)
index 0000000..081da74
--- /dev/null
@@ -0,0 +1,69 @@
+package cx.fbn.nevernote.gui;
+
+import com.trolltech.qt.core.QSize;
+import com.trolltech.qt.gui.QFocusEvent;
+import com.trolltech.qt.gui.QLineEdit;
+import com.trolltech.qt.gui.QResizeEvent;
+import com.trolltech.qt.gui.QStyle.PixelMetric;
+
+public class SearchEdit extends QLineEdit {
+       private final SearchClearButton clearButton;
+       private final String inactiveColor;
+       private final String activeColor;
+       private final String defaultText;
+
+       
+       public SearchEdit(String iconPath) {
+               inactiveColor = new String("QLineEdit {color: gray; font:italic;} ");
+               activeColor = new String("QLineEdit {color: black; font:normal;} ");
+               
+               this.clearButton = new SearchClearButton(this, iconPath);
+               this.clearButton.clicked.connect(this, "clear()");
+               
+               this.textChanged.connect(this, "updateClearButton(String)");
+               int frameWidth = this.style().pixelMetric(PixelMetric.PM_DefaultFrameWidth);
+               this.setStyleSheet("QLineEdit { padding-right: " + (clearButton.sizeHint().width() + frameWidth + 1) + "px; } ");
+               defaultText = new String(tr("Search"));
+               this.setText(defaultText);
+               this.setStyleSheet(inactiveColor);
+       }
+       
+       @Override
+       protected void resizeEvent(QResizeEvent event) {
+               QSize sz = clearButton.sizeHint();
+               int frameWidth = this.style().pixelMetric(PixelMetric.PM_DefaultFrameWidth);
+               clearButton.move(this.rect().right() - frameWidth - sz.width(), (this.rect().bottom() + 1 - sz.height()) / 2);
+       }
+       
+       @SuppressWarnings("unused")
+       private void updateClearButton(String text) {
+               clearButton.setVisible(!text.isEmpty());
+       }
+       
+       public void setdefaultText() {
+               this.setText(defaultText);
+               this.setStyleSheet(inactiveColor);
+       }
+       
+       @Override
+       protected void focusInEvent(QFocusEvent event) {
+               super.focusInEvent(event);
+               if (this.text().equals(defaultText)) {
+                       this.blockSignals(true);
+                       this.setText("");
+                       this.blockSignals(false);
+               }
+               this.setStyleSheet(activeColor);
+       }
+       
+       @Override
+       protected void focusOutEvent(QFocusEvent event) {
+               super.focusOutEvent(event);
+               if (this.text().trim().equals("")) {
+                       this.blockSignals(true);
+                       this.setText(defaultText);
+                       this.blockSignals(false);
+                       this.setStyleSheet(inactiveColor);
+               }
+       }
+}
similarity index 73%
rename from src/cx/fbn/nevernote/gui/SearchPanel.java
rename to src/cx/fbn/nevernote/gui/ZoomPanel.java
index c8553a6..4c6b564 100644 (file)
@@ -1,96 +1,83 @@
-package cx.fbn.nevernote.gui;\r
-\r
-import com.trolltech.qt.gui.QComboBox;\r
-import com.trolltech.qt.gui.QHBoxLayout;\r
-import com.trolltech.qt.gui.QLabel;\r
-import com.trolltech.qt.gui.QSpinBox;\r
-import com.trolltech.qt.gui.QVBoxLayout;\r
-import com.trolltech.qt.gui.QWidget;\r
-\r
-import cx.fbn.nevernote.gui.controls.QuotaProgressBar;\r
-\r
-public class SearchPanel extends QWidget {\r
-       private final QLabel zoomLabel;\r
-       private final QSpinBox zoomSpinner;\r
-       private final NotebookTreeWidget notebook;\r
-       private final QComboBox search;\r
-       private final QuotaProgressBar bar;\r
-       \r
-       public SearchPanel(QComboBox search, QuotaProgressBar bar, NotebookTreeWidget notebook, QSpinBox zoom) {\r
-               QVBoxLayout mainLayout = new QVBoxLayout();\r
-               QVBoxLayout subLayout = new QVBoxLayout();\r
-               zoomSpinner = zoom;\r
-               this.bar = bar;\r
-               this.search = search;\r
-               this.notebook = notebook;\r
-               \r
-               setLayout(mainLayout);\r
-               subLayout.addWidget(search);\r
-               subLayout.addWidget(bar);\r
-               QHBoxLayout zoomLayout = new QHBoxLayout();\r
-               zoomLabel = new QLabel(tr("Zoom:"));\r
-               zoomLayout.addWidget(zoomLabel);\r
-               zoomLayout.addWidget(zoom);\r
-               zoomLayout.setStretch(1, 100);\r
-               subLayout.addLayout(zoomLayout);\r
-               mainLayout.addLayout(subLayout);\r
-               mainLayout.addWidget(notebook);\r
-               //setStyleSheet("QTreeView {border: 0.0em;}");\r
-               mainLayout.setContentsMargins(0, 0, 0, 0);\r
-       }\r
-       \r
-       public void hideZoom() {\r
-               zoomLabel.hide();\r
-               zoomSpinner.hide();\r
-       }\r
-       public void showZoom() {\r
-               zoomLabel.show();\r
-               zoomSpinner.show();\r
-       }\r
-       \r
-       public void toggleNotebook() {\r
-               show();\r
-               if (notebook.isVisible())\r
-                       notebook.hide();\r
-               else\r
-                       notebook.show();\r
-               \r
-               checkVisibility();\r
-       }\r
-       \r
-       public void toggleSearchField() {\r
-               show();\r
-               if (search.isVisible())\r
-                       search.hide();\r
-               else\r
-                       search.show();\r
-               checkVisibility();\r
-       }\r
-       \r
-       private void checkVisibility() {\r
-               if (notebook.isHidden() && bar.isHidden() && search.isHidden() && zoomSpinner.isHidden()) {\r
-                       hide();\r
-               }\r
-       }\r
-       \r
-       public void toggleQuotaBar() {\r
-               show();\r
-               if (bar.isVisible())\r
-                       bar.hide();\r
-               else\r
-                       bar.show();\r
-               checkVisibility();\r
-       }\r
-       \r
-       public void toggleZoom() {\r
-               show();\r
-               if (zoomSpinner.isVisible()) {\r
-                       zoomSpinner.hide();\r
-                       zoomLabel.hide();\r
-               } else {\r
-                       zoomSpinner.show();\r
-                       zoomLabel.show();\r
-               }\r
-               checkVisibility();\r
-       }\r
-}\r
+package cx.fbn.nevernote.gui;
+
+import com.trolltech.qt.gui.QHBoxLayout;
+import com.trolltech.qt.gui.QLabel;
+import com.trolltech.qt.gui.QSpinBox;
+import com.trolltech.qt.gui.QVBoxLayout;
+import com.trolltech.qt.gui.QWidget;
+
+import cx.fbn.nevernote.gui.controls.QuotaProgressBar;
+
+public class ZoomPanel extends QWidget {
+       private final QLabel zoomLabel;
+       private final QSpinBox zoomSpinner;
+       private final NotebookTreeWidget notebook;
+       private final QuotaProgressBar bar;
+       
+       public ZoomPanel(QuotaProgressBar bar, NotebookTreeWidget notebook, QSpinBox zoom) {
+               QVBoxLayout mainLayout = new QVBoxLayout();
+               QVBoxLayout subLayout = new QVBoxLayout();
+               zoomSpinner = zoom;
+               this.bar = bar;
+               this.notebook = notebook;
+               
+               setLayout(mainLayout);
+               subLayout.addWidget(bar);
+               QHBoxLayout zoomLayout = new QHBoxLayout();
+               zoomLabel = new QLabel(tr("Zoom:"));
+               zoomLayout.addWidget(zoomLabel);
+               zoomLayout.addWidget(zoom);
+               zoomLayout.setStretch(1, 100);
+               subLayout.addLayout(zoomLayout);
+               mainLayout.addLayout(subLayout);
+               mainLayout.addWidget(notebook);
+               //setStyleSheet("QTreeView {border: 0.0em;}");
+               mainLayout.setContentsMargins(0, 0, 0, 0);
+       }
+       
+       public void hideZoom() {
+               zoomLabel.hide();
+               zoomSpinner.hide();
+       }
+       public void showZoom() {
+               zoomLabel.show();
+               zoomSpinner.show();
+       }
+       
+       public void toggleNotebook() {
+               show();
+               if (notebook.isVisible())
+                       notebook.hide();
+               else
+                       notebook.show();
+               
+               checkVisibility();
+       }
+       
+       private void checkVisibility() {
+               if (notebook.isHidden() && bar.isHidden() && zoomSpinner.isHidden()) {
+                       hide();
+               }
+       }
+       
+       public void toggleQuotaBar() {
+               show();
+               if (bar.isVisible())
+                       bar.hide();
+               else
+                       bar.show();
+               checkVisibility();
+       }
+       
+       public void toggleZoom() {
+               show();
+               if (zoomSpinner.isVisible()) {
+                       zoomSpinner.hide();
+                       zoomLabel.hide();
+               } else {
+                       zoomSpinner.show();
+                       zoomLabel.show();
+               }
+               checkVisibility();
+       }
+}
diff --git a/src/cx/fbn/nevernote/icons/clear.png b/src/cx/fbn/nevernote/icons/clear.png
new file mode 100644 (file)
index 0000000..e8850ef
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/clear.png differ
diff --git a/src/cx/fbn/nevernote/icons/clearActive.png b/src/cx/fbn/nevernote/icons/clearActive.png
new file mode 100644 (file)
index 0000000..5a0395e
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/clearActive.png differ
diff --git a/src/cx/fbn/nevernote/icons/clearPressed.png b/src/cx/fbn/nevernote/icons/clearPressed.png
new file mode 100644 (file)
index 0000000..d12bfdd
Binary files /dev/null and b/src/cx/fbn/nevernote/icons/clearPressed.png differ