OSDN Git Service

Change font color & highlight colors to be QToolButton instead of QPushButton.
authorRandy Baumgarte <randy@fbn.cx>
Wed, 8 Sep 2010 18:12:22 +0000 (14:12 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Tue, 14 Sep 2010 10:24:51 +0000 (06:24 -0400)
src/cx/fbn/nevernote/gui/BrowserWindow.java
src/cx/fbn/nevernote/gui/ColorMenu.java

index e64c2c1..a1e4c43 100644 (file)
@@ -76,6 +76,8 @@ import com.trolltech.qt.gui.QMessageBox;
 import com.trolltech.qt.gui.QPushButton;\r
 import com.trolltech.qt.gui.QShortcut;\r
 import com.trolltech.qt.gui.QTimeEdit;\r
+import com.trolltech.qt.gui.QToolButton;\r
+import com.trolltech.qt.gui.QToolButton.ToolButtonPopupMode;\r
 import com.trolltech.qt.gui.QVBoxLayout;\r
 import com.trolltech.qt.gui.QWidget;\r
 import com.trolltech.qt.network.QNetworkRequest;\r
@@ -187,12 +189,11 @@ public class BrowserWindow extends QWidget {
        public EditorButtonBar buttonLayout;\r
        public final QComboBox fontList;\r
        public final QAction    fontListAction;\r
-       public final QPushButton fontColor;\r
+       public final QToolButton fontColor;\r
        public final QAction    fontColorAction;\r
        private final ColorMenu fontColorMenu;\r
-       public final QPushButton fontHilight;\r
+       public final QToolButton fontHilight;\r
        public final QAction    fontHilightAction;\r
-//     public final ColorComboBox fontHilight;\r
        private final ColorMenu fontHilightColorMenu;\r
        public final QFileSystemWatcher fileWatcher;\r
        public int cursorPosition;\r
@@ -434,17 +435,23 @@ public class BrowserWindow extends QWidget {
                }\r
 \r
 //             buttonLayout.addWidget(newSeparator(), 0);\r
-               fontColor = newEditorButton("fontColor", tr("Font Color"));\r
+               fontColor = newToolButton("fontColor", tr("Font Color"));\r
                fontColorMenu = new ColorMenu(this);\r
                fontColor.setMenu(fontColorMenu.getMenu());\r
+               fontColor.setPopupMode(ToolButtonPopupMode.MenuButtonPopup);\r
+               fontColor.setAutoRaise(false);\r
                fontColorMenu.getMenu().triggered.connect(this, "fontColorClicked()");\r
                fontColorAction = buttonLayout.addWidget(fontColor);\r
                buttonLayout.toggleFontColorVisible.triggered.connect(this, "toggleFontColorVisible(Boolean)");\r
-               fontHilight = newEditorButton("fontHilight", tr("Font Hilight Color"));\r
+               fontHilight = newToolButton("fontHilight", tr("Font Hilight Color"));\r
+               fontHilight.setPopupMode(ToolButtonPopupMode.MenuButtonPopup);\r
+               fontHilight.setAutoRaise(false);\r
                fontHilightColorMenu = new ColorMenu(this);\r
+               fontHilightColorMenu.setDefault(QColor.yellow);\r
                fontHilight.setMenu(fontHilightColorMenu.getMenu());\r
                fontHilightColorMenu.getMenu().triggered.connect(this, "fontHilightClicked()");\r
                fontHilightAction = buttonLayout.addWidget(fontHilight);\r
+               fontHilightColorMenu.setDefault(QColor.yellow);\r
                buttonLayout.toggleFontHilight.triggered.connect(this, "toggleFontHilightVisible(Boolean)");\r
 \r
 //             buttonLayout.addWidget(new QLabel(), 1);\r
@@ -484,6 +491,7 @@ public class BrowserWindow extends QWidget {
        }\r
 \r
        \r
+       \r
        private void setupShortcut(QShortcut action, String text) {\r
                if (!Global.shortcutKeys.containsAction(text))\r
                        return;\r
@@ -583,6 +591,15 @@ public class BrowserWindow extends QWidget {
                button.clicked.connect(this, name + "Clicked()");\r
                return button;\r
        }\r
+       // New Editor Button\r
+       private QToolButton newToolButton(String name, String toolTip) {\r
+               QToolButton button = new QToolButton();\r
+               QIcon icon = new QIcon(iconPath + name + ".gif");\r
+               button.setIcon(icon);\r
+               button.setToolTip(toolTip);\r
+               button.clicked.connect(this, name + "Clicked()");\r
+               return button;\r
+       }\r
 \r
        // New Separator\r
        private QLabel newSeparator() {\r
index 91ed0a0..7144b85 100644 (file)
@@ -42,6 +42,9 @@ public class ColorMenu extends Object {
                currentColor = new QColor("black");\r
        }\r
        \r
+       public void setDefault(QColor color) {\r
+               currentColor = color;\r
+       }\r
                \r
        private void populateList() {\r
                List<String> colorNames = QColor.colorNames();\r