OSDN Git Service

45a3f20e6da6c6b1d9e41d81c951f714217cd3e5
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / SharedNotebookSyncError.java
1 /*
2  * This file is part of NixNote 
3  * Copyright 2009 Randy Baumgarte
4  * 
5  * This file may be licensed under the terms of of the
6  * GNU General Public License Version 2 (the ``GPL'').
7  *
8  * Software distributed under the License is distributed
9  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
10  * express or implied. See the GPL for the specific language
11  * governing rights and limitations.
12  *
13  * You should have received a copy of the GPL along with this
14  * program. If not, go to http://www.gnu.org/licenses/gpl.html
15  * or write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18 */
19
20 package cx.fbn.nevernote.dialog;
21
22 //**********************************************
23 //**********************************************
24 //* Create or edit a tag
25 //**********************************************
26 //**********************************************
27
28 import com.trolltech.qt.gui.QDialog;
29 import com.trolltech.qt.gui.QGridLayout;
30 import com.trolltech.qt.gui.QGroupBox;
31 import com.trolltech.qt.gui.QIcon;
32 import com.trolltech.qt.gui.QPushButton;
33 import com.trolltech.qt.gui.QRadioButton;
34 import com.trolltech.qt.gui.QTextBrowser;
35 import com.trolltech.qt.gui.QVBoxLayout;
36
37 public class SharedNotebookSyncError extends QDialog {
38         private boolean         okPressed;
39         QPushButton ok;
40         public final QRadioButton doNothing;
41         public final QRadioButton deleteNotebook;
42         public final QRadioButton convertToLocal;
43         public final QRadioButton convertToShared;
44         private final QGroupBox choiceGroup;
45         private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
46         
47         // Constructor
48         public SharedNotebookSyncError(String notebook) {
49                 okPressed = false;
50                 setWindowTitle(tr("Shared Notebook Synchronization Error"));
51                 QGridLayout grid = new QGridLayout();
52                 setWindowIcon(new QIcon(iconPath+"synchronize.png"));
53                 QVBoxLayout vLayout = new QVBoxLayout();
54                 setLayout(vLayout);
55
56                 QTextBrowser msg1 = new QTextBrowser();
57                 msg1.setText(tr("There was an error with notebook ") +notebook 
58                                 +tr("\nThe most probable reason is that the owner of the notebook has revoked your authority to view it.\n\n")
59                                 +tr("Below are the choices available to resolve this issue."));
60                 vLayout.addWidget(msg1);
61                 
62                 choiceGroup = new QGroupBox(this);
63                 doNothing = new QRadioButton(this);
64                 doNothing.setChecked(true);
65                 doNothing.setText(tr("Do nothing and ask me later."));
66                 deleteNotebook = new QRadioButton(this);
67                 deleteNotebook.setText(tr("Permanently delete this notebook & all notes"));
68                 convertToLocal = new QRadioButton(this);
69                 convertToLocal.setText(tr("Convert this notebook to a local notebook and keep all notes"));
70                 convertToShared = new QRadioButton(this);
71                 convertToShared.setText(tr("Convert this notebook to a shared notebook and keep all notes"));
72                 
73                 QVBoxLayout optionLayout = new QVBoxLayout();
74                 optionLayout.addWidget(doNothing);
75                 optionLayout.addWidget(deleteNotebook);
76 //              optionLayout.addWidget(convertToLocal);
77 //              optionLayout.addWidget(convertToShared);
78                 choiceGroup.setLayout(optionLayout);
79                 vLayout.addWidget(choiceGroup);
80                 
81                 QGridLayout buttonGrid = new QGridLayout();
82                 ok = new QPushButton(tr("OK"));
83                 ok.clicked.connect(this, "okButtonPressed()");
84                 QPushButton cancel = new QPushButton(tr("Cancel"));
85                 cancel.clicked.connect(this, "cancelButtonPressed()");
86                 buttonGrid.addWidget(ok, 3, 1);
87                 buttonGrid.addWidget(cancel, 3,2);
88                 grid.addLayout(buttonGrid,3,1);
89                 vLayout.addLayout(grid);
90         }
91         
92         // The OK button was pressed
93         @SuppressWarnings("unused")
94         private void okButtonPressed() {
95                 okPressed = true;
96                 close();
97         }
98         
99         // The CANCEL button was pressed
100         @SuppressWarnings("unused")
101         private void cancelButtonPressed() {
102                 okPressed = false;
103                 close();
104         }
105         
106         // Check if the OK button was pressed
107         public boolean okPressed() {
108                 return okPressed;
109         }
110         
111         // Set the window title
112         public void setTitle(String s) {
113                 setWindowTitle(s);
114         }
115 }