OSDN Git Service

検索ボックスをツールバー右側に移動&改良した
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / gui / ZoomPanel.java
1 package cx.fbn.nevernote.gui;
2
3 import com.trolltech.qt.gui.QHBoxLayout;
4 import com.trolltech.qt.gui.QLabel;
5 import com.trolltech.qt.gui.QSpinBox;
6 import com.trolltech.qt.gui.QVBoxLayout;
7 import com.trolltech.qt.gui.QWidget;
8
9 import cx.fbn.nevernote.gui.controls.QuotaProgressBar;
10
11 public class ZoomPanel extends QWidget {
12         private final QLabel zoomLabel;
13         private final QSpinBox zoomSpinner;
14         private final NotebookTreeWidget notebook;
15         private final QuotaProgressBar bar;
16         
17         public ZoomPanel(QuotaProgressBar bar, NotebookTreeWidget notebook, QSpinBox zoom) {
18                 QVBoxLayout mainLayout = new QVBoxLayout();
19                 QVBoxLayout subLayout = new QVBoxLayout();
20                 zoomSpinner = zoom;
21                 this.bar = bar;
22                 this.notebook = notebook;
23                 
24                 setLayout(mainLayout);
25                 subLayout.addWidget(bar);
26                 QHBoxLayout zoomLayout = new QHBoxLayout();
27                 zoomLabel = new QLabel(tr("Zoom:"));
28                 zoomLayout.addWidget(zoomLabel);
29                 zoomLayout.addWidget(zoom);
30                 zoomLayout.setStretch(1, 100);
31                 subLayout.addLayout(zoomLayout);
32                 mainLayout.addLayout(subLayout);
33                 mainLayout.addWidget(notebook);
34                 //setStyleSheet("QTreeView {border: 0.0em;}");
35                 mainLayout.setContentsMargins(0, 0, 0, 0);
36         }
37         
38         public void hideZoom() {
39                 zoomLabel.hide();
40                 zoomSpinner.hide();
41         }
42         public void showZoom() {
43                 zoomLabel.show();
44                 zoomSpinner.show();
45         }
46         
47         public void toggleNotebook() {
48                 show();
49                 if (notebook.isVisible())
50                         notebook.hide();
51                 else
52                         notebook.show();
53                 
54                 checkVisibility();
55         }
56         
57         private void checkVisibility() {
58                 if (notebook.isHidden() && bar.isHidden() && zoomSpinner.isHidden()) {
59                         hide();
60                 }
61         }
62         
63         public void toggleQuotaBar() {
64                 show();
65                 if (bar.isVisible())
66                         bar.hide();
67                 else
68                         bar.show();
69                 checkVisibility();
70         }
71         
72         public void toggleZoom() {
73                 show();
74                 if (zoomSpinner.isVisible()) {
75                         zoomSpinner.hide();
76                         zoomLabel.hide();
77                 } else {
78                         zoomSpinner.show();
79                         zoomLabel.show();
80                 }
81                 checkVisibility();
82         }
83 }