summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/client.pro4
-rw-r--r--client/macrowindow.cc35
-rw-r--r--client/messagebox.cc153
-rw-r--r--client/messagebox.h50
-rw-r--r--client/pracro_dk.ts105
-rw-r--r--client/widgets/metawidget.cc6
-rw-r--r--client/widgets/multilist.cc17
7 files changed, 342 insertions, 28 deletions
diff --git a/client/client.pro b/client/client.pro
index 6df6c3f..1faa111 100644
--- a/client/client.pro
+++ b/client/client.pro
@@ -29,6 +29,7 @@ HEADERS += \
macrowindow.h \
mainwindow.h \
macrodrawer.h \
+ messagebox.h \
netcom.h \
resumewidget.h \
widgetbuilder.h \
@@ -61,6 +62,7 @@ SOURCES += \
macrowindow.cc \
mainwindow.cc \
macrodrawer.cc \
+ messagebox.cc \
netcom.cc \
resumewidget.cc \
widgetbuilder.cc \
@@ -83,3 +85,5 @@ SOURCES += \
widgets/window.cc \
widgets/altcombobox.cc \
widgets/metawidget.cc
+
+TRANSLATIONS=pracro_dk.ts \ No newline at end of file
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index 6beba85..80649a7 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -27,12 +27,13 @@
#include "macrowindow.h"
#include <QVBoxLayout>
-#include <QMessageBox>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNode>
#include <QByteArray>
+#include "messagebox.h"
+
#include "widgets/widget.h"
#include "widgets/window.h"
#include "widgetbuilder.h"
@@ -168,19 +169,19 @@ void MacroWindow::commit()
if(doCommit()) {
// close();
} else {
- QMessageBox::critical(NULL, "Fejl",
- "Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n"
- , QMessageBox::Ok);
+ MessageBox::critical(NULL, "Fejl",
+ "Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n",
+ MessageBox::Ok);
}
}
void MacroWindow::reset()
{
/*
- QMessageBox::warning(NULL, tr("Reset"),
+ MessageBox::warning(NULL, tr("Reset"),
tr("Du har valgt at nulstille de indtastede data.\n"
"Er du sikker?"),
- QMessageBox::Yes | QMessageBox::Cancel);
+ MessageBox::Yes | MessageBox::Cancel);
printf("MacroWindow -> resetting...\n");
*/
QVector< Widget* >::iterator i = widgets.begin();
@@ -225,9 +226,9 @@ void MacroWindow::cont(QString name)
// new_macro("example", macro);
// close();
} else {
- QMessageBox::critical(NULL, "Fejl",
+ MessageBox::critical(NULL, "Fejl",
"Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n",
- QMessageBox::Ok);
+ MessageBox::Ok);
}
printf("%s : MacroWindow -> continuing...\n", macro.toStdString().c_str());
}
@@ -252,9 +253,9 @@ void MacroWindow::cont_nocommit(QString name)
// new_macro("example", macro);
// close();
} else {
- QMessageBox::critical(NULL, "Fejl",
+ MessageBox::critical(NULL, "Fejl",
"Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n",
- QMessageBox::Ok);
+ MessageBox::Ok);
}
printf("%s : MacroWindow -> continuing...\n", macro.toStdString().c_str());
}
@@ -351,23 +352,23 @@ void MacroWindow::collapseWrapper()
if(isCollapsed()) return;
if(waschanged) {
- switch(QMessageBox::warning(NULL,
+ switch(MessageBox::warning(NULL,
"Gem ændringerne i makroen?",
"Du har valgt at lukke makroen " + macrotitle + ".\n"
"Ønsker du at gemme inden du lukker?",
- QMessageBox::Save | QMessageBox::Close | QMessageBox::Cancel)) {
- case QMessageBox::Save:
+ MessageBox::Save | MessageBox::Close | MessageBox::Cancel)) {
+ case MessageBox::Save:
if(doCommit()) setCollapsed(true);
- else QMessageBox::critical(NULL,
+ else MessageBox::critical(NULL,
"Fejl",
"Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n",
- QMessageBox::Ok);
+ MessageBox::Ok);
break;
- case QMessageBox::Close:
+ case MessageBox::Close:
collapse();
break;
- case QMessageBox::Cancel:
+ case MessageBox::Cancel:
default:
// emit expanding(); // signal the other to close again (if any)
break;
diff --git a/client/messagebox.cc b/client/messagebox.cc
new file mode 100644
index 0000000..902d2fd
--- /dev/null
+++ b/client/messagebox.cc
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * messagebox.cc
+ *
+ * Wed Mar 18 13:33:05 CET 2009
+ * Copyright 2009 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "messagebox.h"
+
+#include <QDialogButtonBox>
+#include <QPushButton>
+/*
+ QString p = tr("KEY", "default vaerdi");
+ printf("\n\n\n#######################\n%s\n\n\n", p.toStdString().c_str());
+*/
+
+static MessageBox::StandardButton showNewMessageBox(QWidget *parent,
+ MessageBox::Icon icon,
+ const QString& title, const QString& text,
+ MessageBox::StandardButtons buttons,
+ MessageBox::StandardButton defaultButton)
+{
+ QMessageBox msgBox(icon, title, text, MessageBox::NoButton, parent);
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&msgBox);
+ Q_ASSERT(buttonBox != 0);
+
+ uint mask = MessageBox::FirstButton;
+ while(mask <= MessageBox::LastButton) {
+ uint sb = buttons & mask;
+ mask <<= 1;
+
+ if(!sb) continue;
+
+ QPushButton *button = msgBox.addButton((MessageBox::StandardButton)sb);
+
+ switch(sb) {
+ case MessageBox::Ok: // An "OK" button defined with the AcceptRole.
+ button->setText(QObject::tr("Ok"));
+ break;
+ case MessageBox::Open: // A "Open" button defined with the AcceptRole.
+ button->setText(QObject::tr("Open"));
+ break;
+ case MessageBox::Save: // A "Save" button defined with the AcceptRole.
+ button->setText(QObject::tr("Save"));
+ break;
+ case MessageBox::Cancel: // A "Cancel" button defined with the RejectRole.
+ button->setText(QObject::tr("Cancel"));
+ break;
+ case MessageBox::Close: // A "Close" button defined with the RejectRole.
+ button->setText(QObject::tr("Close"));
+ break;
+ case MessageBox::Discard: // A "Discard" or "Don't Save" button, depending on the platform, defined with the DestructiveRole.
+ button->setText(QObject::tr("Discard"));
+ break;
+ case MessageBox::Apply: // An "Apply" button defined with the ApplyRole.
+ button->setText(QObject::tr("Apply"));
+ break;
+ case MessageBox::Reset: // A "Reset" button defined with the ResetRole.
+ button->setText(QObject::tr("Reset"));
+ break;
+ case MessageBox::RestoreDefaults: // A "Restore Defaults" button defined with the ResetRole.
+ button->setText(QObject::tr("Restore Defaults"));
+ break;
+ case MessageBox::Help: // A "Help" button defined with the HelpRole.
+ button->setText(QObject::tr("Help"));
+ break;
+ case MessageBox::SaveAll: // A "Save All" button defined with the AcceptRole.
+ button->setText(QObject::tr("Save All"));
+ break;
+ case MessageBox::Yes: // A "Yes" button defined with the YesRole.
+ button->setText(QObject::tr("Yes"));
+ break;
+ case MessageBox::YesToAll: // A "Yes to All" button defined with the YesRole.
+ button->setText(QObject::tr("Yes To All"));
+ break;
+ case MessageBox::No: // A "No" button defined with the NoRole.
+ button->setText(QObject::tr("No"));
+ break;
+ case MessageBox::NoToAll: // A "No to All" button defined with the NoRole.
+ button->setText(QObject::tr("No To All"));
+ break;
+ case MessageBox::Abort: // An "Abort" button defined with the RejectRole.
+ button->setText(QObject::tr("Abort"));
+ break;
+ case MessageBox::Retry: // A "Retry" button defined with the AcceptRole.
+ button->setText(QObject::tr("Retry"));
+ break;
+ case MessageBox::Ignore: // An "Ignore" button defined with the AcceptRole.
+ button->setText(QObject::tr("Ignore"));
+ break;
+ case MessageBox::NoButton: // An invalid button.
+ break;
+ }
+
+ // Choose the first accept role as the default
+ if(msgBox.defaultButton()) continue;
+ if((defaultButton == MessageBox::NoButton
+ && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
+ || (defaultButton != MessageBox::NoButton && sb == uint(defaultButton)))
+ msgBox.setDefaultButton(button);
+ }
+
+ if (msgBox.exec() == -1) return MessageBox::Cancel;
+
+ return msgBox.standardButton(msgBox.clickedButton());
+}
+
+MessageBox::StandardButton MessageBox::information(QWidget *parent, const QString &title,
+ const QString& text, StandardButtons buttons,
+ StandardButton defaultButton)
+{
+ return showNewMessageBox(parent, Information, title, text, buttons, defaultButton);
+}
+
+MessageBox::StandardButton MessageBox::question(QWidget *parent, const QString &title,
+ const QString& text, StandardButtons buttons,
+ StandardButton defaultButton)
+{
+ return showNewMessageBox(parent, Question, title, text, buttons, defaultButton);
+}
+MessageBox::StandardButton MessageBox::warning(QWidget *parent, const QString &title,
+ const QString& text, StandardButtons buttons,
+ StandardButton defaultButton)
+{
+ return showNewMessageBox(parent, Warning, title, text, buttons, defaultButton);
+}
+
+MessageBox::StandardButton MessageBox::critical(QWidget *parent, const QString &title,
+ const QString& text, StandardButtons buttons,
+ StandardButton defaultButton)
+{
+ return showNewMessageBox(parent, Critical, title, text, buttons, defaultButton);
+}
diff --git a/client/messagebox.h b/client/messagebox.h
new file mode 100644
index 0000000..2987c65
--- /dev/null
+++ b/client/messagebox.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * messagebox.h
+ *
+ * Wed Mar 18 13:33:05 CET 2009
+ * Copyright 2009 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_MESSAGEBOX_H__
+#define __PRACRO_MESSAGEBOX_H__
+
+#include <QMessageBox>
+
+class MessageBox : public QMessageBox
+{
+public:
+ static StandardButton information(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static StandardButton question(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static StandardButton warning(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static StandardButton critical(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+};
+
+#endif/*__PRACRO_MESSAGEBOX_H__*/
diff --git a/client/pracro_dk.ts b/client/pracro_dk.ts
new file mode 100644
index 0000000..d2d5698
--- /dev/null
+++ b/client/pracro_dk.ts
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1">
+<defaultcodec></defaultcodec>
+<context>
+ <name>ComboBox</name>
+ <message>
+ <location filename="widgets/combobox.cc" line="82"/>
+ <source>goddaws do</source>
+ <translation type="obsolete">weeee</translation>
+ </message>
+</context>
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="messagebox.cc" line="57"/>
+ <source>Ok</source>
+ <translation type="unfinished">Ok</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="60"/>
+ <source>Open</source>
+ <translation type="unfinished">Ã…bn</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="63"/>
+ <source>Save</source>
+ <translation type="unfinished">Gem</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="66"/>
+ <source>Cancel</source>
+ <translation type="unfinished">Annullér</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="69"/>
+ <source>Close</source>
+ <translation type="unfinished">Luk</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="72"/>
+ <source>Discard</source>
+ <translation type="unfinished">Kassér</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="75"/>
+ <source>Apply</source>
+ <translation type="unfinished">Tag i brug</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="78"/>
+ <source>Reset</source>
+ <translation type="unfinished">Nulstil</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="81"/>
+ <source>Restore Defaults</source>
+ <translation type="unfinished">Genopret default</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="84"/>
+ <source>Help</source>
+ <translation type="unfinished">Hjælp</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="87"/>
+ <source>Save All</source>
+ <translation type="unfinished">Gem alle</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="90"/>
+ <source>Yes</source>
+ <translation type="unfinished">Ja</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="93"/>
+ <source>Yes To All</source>
+ <translation type="unfinished">Ja til alle</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="96"/>
+ <source>No</source>
+ <translation type="unfinished">Nej</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="99"/>
+ <source>No To All</source>
+ <translation type="unfinished">Nej til alle</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="102"/>
+ <source>Abort</source>
+ <translation type="unfinished">Afbryd</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="105"/>
+ <source>Retry</source>
+ <translation type="unfinished">Prøv igen</translation>
+ </message>
+ <message>
+ <location filename="messagebox.cc" line="108"/>
+ <source>Ignore</source>
+ <translation type="unfinished">Ignorér</translation>
+ </message>
+</context>
+</TS>
diff --git a/client/widgets/metawidget.cc b/client/widgets/metawidget.cc
index c085f10..5491790 100644
--- a/client/widgets/metawidget.cc
+++ b/client/widgets/metawidget.cc
@@ -29,7 +29,7 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
-#include <QMessageBox>
+#include "messagebox.h"
#include "widgetbuilder.h"
#include "formatparser.h"
@@ -120,10 +120,10 @@ bool MetaWidget::isValid()
while (i != widgets.end()) {
Widget* w = *i;
if(w->isValid() == false) {
- QMessageBox::critical(NULL, "Fejl",
+ MessageBox::critical(NULL, "Fejl",
"Et af inputfelterne (" + w->getName()
+ ") er ikke udfyldt korrekt, prøv igen.\n"
- , QMessageBox::Ok);
+ , MessageBox::Ok);
return false;
}
i++;
diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc
index 4d34691..87f4975 100644
--- a/client/widgets/multilist.cc
+++ b/client/widgets/multilist.cc
@@ -26,12 +26,13 @@
*/
#include "multilist.h"
-#include <QMessageBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QPushButton>
+#include "messagebox.h"
+
#include "widgetbuilder.h"
#include "common.h"
@@ -127,25 +128,25 @@ void MultiList::changed()
bool MultiList::isValid()
{
if(innerwidget_has_changes) {
- switch(QMessageBox::warning(NULL,
+ switch(MessageBox::warning(NULL,
"Gem ændringerne i listen?",
"Der er lavet en ændring som ikke er tilføjet til listen.\n"
"Ønsker du at tilføje ændringen til listen inden du gemmer makroen?",
- QMessageBox::Save | QMessageBox::Close | QMessageBox::Cancel)) {
- case QMessageBox::Save:
+ MessageBox::Save | MessageBox::Close | MessageBox::Cancel)) {
+ case MessageBox::Save:
if(innerwidget && innerwidget->isValid()) {
add();
} else {
- QMessageBox::critical(NULL,
+ MessageBox::critical(NULL,
"Fejl",
"Der er fejl i ændringen, og den kan ikke tilføjes til listen.\n",
- QMessageBox::Ok);
+ MessageBox::Ok);
return false;
}
break;
- case QMessageBox::Close:
+ case MessageBox::Close:
break;
- case QMessageBox::Cancel:
+ case MessageBox::Cancel:
default:
// FIXME: How to we actually block the commit and return to the editor?
return false;