summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Mi <codeminister@publicstatic.de>2014-01-22 00:49:24 (GMT)
committerGregor Mi <codeminister@publicstatic.de>2014-01-22 00:49:24 (GMT)
commit92933bebb13bd513ed19bdda269956322bc849b5 (patch)
treea1749fff58284488869fc9f569e274b8c4469c00
parent64e10b78dbe2d7796fea02cbcbd6bccd6e443017 (diff)
Fix skanlite version. Fix AboutData handling. Use QCommandLineParser. Fix main dialog crash after exit.
-rw-r--r--CMakeLists.txt12
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/TODO6
-rw-r--r--src/main.cpp41
-rw-r--r--src/skanlite.cpp4
5 files changed, 34 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d0fa90..c36b35f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,6 +29,7 @@ set(KF5_VERSION "5.0.0")
find_package(KF5 ${KF5_VERSION} REQUIRED
COMPONENTS # alias to find_package(KFGuiAddons ${KF5_VERSION} REQUIRED)
+ CoreAddons
GuiAddons
I18n
Wallet # FIXME KF5 why is this needed?
@@ -52,6 +53,8 @@ set(REQUIRED_QT_VERSION "5.2.0")
find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core)
find_package(PNG REQUIRED)
+set(SKANLITE_VERSION_STRING "1.1.0")
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/version.h)
# TODO: Add all required find_package() calls here
@@ -61,12 +64,3 @@ add_subdirectory(src)
add_subdirectory(doc)
add_subdirectory(autotests)
add_subdirectory(tests)
-
-# FIXME KF5 review the stuff below later
-
-message(STATUS "KSANE_FOUND=${KSANE_FOUND}, KSANE_INCLUDE_DIR=${KSANE_INCLUDE_DIR}")
-
-set(SKANLITE_VERSION_MAJOR "1")
-set(SKANLITE_VERSION_MINOR "1")
-set(SKANLITE_VERSION_STRING "${SKANLITE_VERSION_MAJOR}.${SKANLITE_VERSION_MINOR}")
-
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 22c3f94..b6066b6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,7 +10,7 @@ target_link_libraries(skanlite
PUBLIC
Qt5::Core
PRIVATE
- # KF5::CoreAddons
+ KF5::CoreAddons
# Other private libs
KF5::Sane
KF5::I18n
diff --git a/src/TODO b/src/TODO
index 8d37f36..1caa1a7 100644
--- a/src/TODO
+++ b/src/TODO
@@ -2,7 +2,11 @@
=================================
Major issues
------------
-* Main dialog: press Close closes skanlite but it also crashes
+* Scan button: crash after scan
+
+Questions
+---------
+* Difference between "skanlite -d test" and one of the SANE test scanners test:0 or test:1
Minor issues
------------
diff --git a/src/main.cpp b/src/main.cpp
index 672fc6d..3ac20f2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,25 +20,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* ============================================================ */
+
+#include <QCommandLineParser>
+#include <QCommandLineOption>
+
#include <kapplication.h>
#include <kcmdlineargs.h>
-#include <kaboutdata.h>
+#include <KAboutData>
#include <kglobal.h>
#include "skanlite.h"
#include "version.h"
int main(int argc, char *argv[])
-{
+{
QApplication app(argc, argv);
- // about data
- KAboutData aboutData("Skanlite", // appname
+ KAboutData aboutData("Skanlite", // componentName, k4: appName
"skanlite", // catalogName
- i18n("Skanlite"), // rogramName
+ i18n("Skanlite"), // displayName, k4: programName
skanlite_version, // version
- i18n("This is a scanning application for KDE based on libksane."), // shortDescription
+ i18n("Scanning application for KDE based on libksane."), // shortDescription
KAboutData::License_GPL, // licenseType
+ QString(), // othe Text
i18n("(C) 2008-2014 Kåre Särs") // copyrightStatement
);
@@ -65,18 +69,21 @@ int main(int argc, char *argv[])
i18n("Help with translations"));
aboutData.setProgramIconName("scanner");
+
+ QCoreApplication::setApplicationVersion(aboutData.version());
+ QCommandLineParser parser;
+ aboutData.setupCommandLine(&parser);
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption deviceOption(QStringList() << "d" << "device", i18n("Sane scanner device name. Use 'test' for test device."), i18n("device"));
+ parser.addOption(deviceOption);
+ parser.process(app); // the --author and --license is shown anyway but they work only with the following line
+ aboutData.processCommandLine(&parser);
+
+ QString deviceName = parser.value(deviceOption);
+ qDebug() << QString("deviceOption value=%1").arg(deviceName);
- // FIXME KF5 is the command line parsing still working? (ported KCmdLineOptions to QCommandLineParser)
- //KCmdLineArgs::init(argc, argv, &aboutData);
- //KCmdLineOptions options;
- //options.add("d <device>", ki18n("Sane scanner device name."));
- //KCmdLineArgs::addCmdLineOptions(options);
- //KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- //QString device = args->getOption("d");
- QString device; // FIXME KF5
-
-
- Skanlite skanliteDialog(device, 0);
+ Skanlite skanliteDialog(deviceName, 0);
skanliteDialog.setAboutData(&aboutData);
skanliteDialog.show();
diff --git a/src/skanlite.cpp b/src/skanlite.cpp
index f290e74..6b37bc0 100644
--- a/src/skanlite.cpp
+++ b/src/skanlite.cpp
@@ -56,9 +56,7 @@
Skanlite::Skanlite(const QString& device, QWidget* parent)
: QDialog(parent)
, m_aboutData(nullptr)
-{
- setAttribute(Qt::WA_DeleteOnClose);
-
+{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QDialogButtonBox* dlgButtonBoxBottom = new QDialogButtonBox(this);