From 78b56ec751d15a6db68fbc2ea5fdc9815d8a932c Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sat, 11 Jul 2026 09:04:04 +0200 Subject: [PATCH] Port qlscribe to Qt 6 --- .gitignore | 1 + CMakeLists.txt | 15 ++++++++----- NEWS | 6 ++++- src/CMakeLists.txt | 44 +++++-------------------------------- src/lightscribe.xml | 8 +++---- src/main.cpp | 2 +- src/mainwindow.cpp | 9 +++++--- src/mainwindow.h | 2 +- src/previewinjector.cpp | 3 +-- src/qcdscene.cpp | 12 ++++------ src/qcdview.cpp | 4 +++- src/qdialogcdproperties.h | 2 +- src/qdialogprint.h | 2 +- src/qdialogprogress.cpp | 3 ++- src/qdialogprogress.h | 6 ++--- src/qdialogsettings.h | 2 +- src/qlightroundtextitem.cpp | 11 +++++----- src/qlightscribe.cpp | 4 ++-- src/qlightscribe.h | 5 +++-- 19 files changed, 60 insertions(+), 81 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7352f80..d785baa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,9 +18,14 @@ # # $Id$ -PROJECT( qlscribe ) +CMAKE_MINIMUM_REQUIRED(VERSION 3.21) +PROJECT(qlscribe VERSION 0.17 LANGUAGES CXX) -CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) +SET(CMAKE_CXX_STANDARD 17) +SET(CMAKE_CXX_STANDARD_REQUIRED ON) +SET(CMAKE_AUTOMOC ON) +SET(CMAKE_AUTOUIC ON) +SET(CMAKE_AUTORCC ON) SET( FINAL_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Final install path") SET( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ) @@ -32,6 +37,6 @@ SET( QLSCRIBE_DBUS_PATH /org/lightscribe ) SET( QLSCRIBE_DBUS_MANAGER_PATH ${QLSCRIBE_DBUS_PATH}/printManager ) # path to manager SET( QLSCRIBE_DBUS_DRIVES_PATH ${QLSCRIBE_DBUS_PATH}/drives ) # base path under which drives located -SUBDIRS( src ) -SUBDIRS( resources ) -SUBDIRS( lscribed ) +ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(resources) +ADD_SUBDIRECTORY(lscribed) diff --git a/NEWS b/NEWS index 408976a..a888e12 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ NEWS - list of user-visible changes between releases of qlscribe +New in 0.17 +----------- +* Ported the application and build system from Qt 4 to Qt 6. +* Modernized the CMake build while retaining the required LightScribe daemon. + New in 0.16 Fixed build on 64 bit Ubuntu Saucy Fixed bug with alarm() not found @@ -86,4 +91,3 @@ New in 0.2: New in 0.1: Open/save as implemented. Text, round text and image items can be inserted and edited Print preview and print is working (no exclusive lock or tray lock on printing yet) - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c74bb9b..b216c22 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,8 +18,7 @@ # # $Id$ -FIND_PACKAGE( Qt4 REQUIRED ) -SET( QT_USE_QTDBUS 1 ) +FIND_PACKAGE(Qt6 6.5 REQUIRED COMPONENTS Core Gui Widgets DBus) SET( QLSCRIBE_SRCS main.cpp mainwindow.cpp qcdscene.cpp qcdview.cpp qdialogpixmap.cpp qdialogroundtext.cpp qdialogtext.cpp qlightroundtextitem.cpp @@ -30,50 +29,19 @@ SET( QLSCRIBE_SRCS main.cpp mainwindow.cpp qcdscene.cpp qcdview.cpp SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui qdialogprint.ui qdialogprogress.ui qdialogcdproperties.ui qdialogsettings.ui ) -SET( QLSCRIBE_MOC_HDRS mainwindow.h qcdscene.h qdialogpixmap.h qdialogroundtext.h - qdialogtext.h qlightscribe.h qdialogprint.h qdialogprogress.h - qdialogcdproperties.h qconsoleprintprogress.h qdialogsettings.h previewinjector.h ) - ADD_DEFINITIONS( -Wall ) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/qlscribe.h.in ${CMAKE_CURRENT_BINARY_DIR}/qlscribe.h @ONLY ) -INCLUDE( ${QT_USE_FILE} ) - -QT4_WRAP_UI( QLSCRIBE_UI_HDRS ${QLSCRIBE_UIS} ) - -QT4_WRAP_CPP( QLSCRIBE_MOC_SRCS ${QLSCRIBE_MOC_HDRS} ) - -QT4_ADD_RESOURCES( QLSCRIBE_RCC_SRCS ../resources/qlscribe.qrc ) - -MACRO(ADD_DBUS_INTERFACE _sources _interface _basename) - GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE) - SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h) - SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) - SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) - - ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} - COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -i qlightscribe.h -p ${_basename} ${_infile} - DEPENDS ${_infile}) - - SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE) - - QT4_GENERATE_MOC(${_header} ${_moc}) - - SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc}) - MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc}) -ENDMACRO(ADD_DBUS_INTERFACE) - -ADD_DBUS_INTERFACE( QLSCRIBE_DBUS_SRCS lightscribe.xml lightscribe_interface ) +SET_SOURCE_FILES_PROPERTIES(lightscribe.xml PROPERTIES INCLUDE qlightscribe.h) +QT6_ADD_DBUS_INTERFACE(QLSCRIBE_DBUS_SRCS lightscribe.xml lightscribe_interface) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ) -ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS} - ${QLSCRIBE_RCC_SRCS} ${QLSCRIBE_UI_HDRS} - ${QLSCRIBE_DBUS_SRCS} ) +ADD_EXECUTABLE(qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_UIS} + ${QLSCRIBE_DBUS_SRCS} ../resources/qlscribe.qrc) -TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} ) +TARGET_LINK_LIBRARIES(qlscribe PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::DBus) INSTALL( TARGETS qlscribe DESTINATION bin ) - diff --git a/src/lightscribe.xml b/src/lightscribe.xml index 8bef6ec..0b90a67 100644 --- a/src/lightscribe.xml +++ b/src/lightscribe.xml @@ -24,7 +24,7 @@ - + @@ -44,15 +44,15 @@ - - + + - + diff --git a/src/main.cpp b/src/main.cpp index 802f3eb..4ea5ef4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ std::ostream &operator<<( std::ostream &os, const QString &str ) { - return os << str.toAscii().data(); + return os << str.toUtf8().constData(); } void usage() diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2209853..54069e4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -75,7 +76,8 @@ MainWindow::MainWindow( bool enablePrint ) SLOT(map()) ); m_newLabelMapper->setMapping( action, modeTitle ); } - connect( m_newLabelMapper, SIGNAL(mapped(int)), this, SLOT(onMenuNewLabel(int)) ); + connect(m_newLabelMapper, &QSignalMapper::mappedInt, + this, &MainWindow::onMenuNewLabel); m_menuFile->addAction( tr( "Open...", "Menu item \"Open\"" ), this, @@ -169,7 +171,8 @@ MainWindow::MainWindow( bool enablePrint ) m_insertMapper->setMapping( action, i->first ); connect( action, SIGNAL(triggered()), m_insertMapper, SLOT(map()) ); } - connect( m_insertMapper, SIGNAL(mapped(int)), this, SLOT(onMenuInsert(int)) ); + connect(m_insertMapper, &QSignalMapper::mappedInt, + this, &MainWindow::onMenuInsert); connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)), this, SLOT(updateMenu()) ); @@ -545,7 +548,7 @@ void MainWindow::onMenuAbout() QMessageBox::about( this, tr( "About" ), tr( "

qlscribe - Qt lisghtScribe

" - "

release 0.16 $Revision$

" + "

release 0.17

" "

visit project at home page " "qlscribe.sourceforge.net

" ) ); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 72f8e83..09f8202 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -21,7 +21,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include +#include class QMdiArea; class QSignalMapper; diff --git a/src/previewinjector.cpp b/src/previewinjector.cpp index 5a35e4b..a43a1d6 100644 --- a/src/previewinjector.cpp +++ b/src/previewinjector.cpp @@ -12,7 +12,7 @@ PreviewInjector::PreviewInjector( QFileDialog * dl ) : if( !dl ) return; - QSplitter *sp = qFindChild( dl, "splitter" ); + QSplitter *sp = dl->findChild("splitter"); if( !sp ) return; @@ -58,4 +58,3 @@ void PreviewInjector::onSelectionChanged(QString file) } m_label->setPixmap( QPixmap::fromImage( img ) ); } - diff --git a/src/qcdscene.cpp b/src/qcdscene.cpp index 7fb9175..d99139a 100644 --- a/src/qcdscene.cpp +++ b/src/qcdscene.cpp @@ -31,11 +31,10 @@ #include #include #include -#include #include #include #include -#include +#include QCDScene::QCDScene( QObject * parent ) : QGraphicsScene( parent ), @@ -83,7 +82,7 @@ void QCDScene::start( LabelMode mode ) bool QCDScene::load( const QString &fileName, QString *errMessage ) { - if( QRegExp( ".*.\\.qlx$", Qt::CaseInsensitive ).exactMatch( fileName ) ) { + if (fileName.endsWith(".qlx", Qt::CaseInsensitive)) { QFile file( fileName ); if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { if( errMessage ) @@ -188,9 +187,7 @@ void QCDScene::setName() } m_name = "Unnamed_" + QString::number( m_index ); } else { - QRegExp rx( "(.*/)?(.*)\\.qlx" ); - rx.indexIn( m_fileName ); - m_name = rx.cap( 2 ); + m_name = QFileInfo(m_fileName).completeBaseName(); } updateTitles(); @@ -405,7 +402,7 @@ void QCDScene::getItemFromClipboard() void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent ) { - QGraphicsItem *item = itemAt( mouseEvent->scenePos() ); + QGraphicsItem *item = itemAt(mouseEvent->scenePos(), QTransform()); if( !item ) return; item->setSelected( true ); @@ -520,4 +517,3 @@ void QCDScene::unredo( bool undo ) } setChanged( false ); } - diff --git a/src/qcdview.cpp b/src/qcdview.cpp index 561c5a4..f2efb1b 100644 --- a/src/qcdview.cpp +++ b/src/qcdview.cpp @@ -160,7 +160,9 @@ void QCDView::drawForeground ( QPainter * painter, const QRectF & rect ) QPainter paint( &alpha ); paint.setWorldTransform( painter->transform() ); drawCD( &paint, rectf, true ); - m_mask->setAlphaChannel( alpha ); + QImage maskImage = m_mask->toImage().convertToFormat(QImage::Format_ARGB32); + maskImage.setAlphaChannel(alpha.toImage()); + *m_mask = QPixmap::fromImage(maskImage); } } diff --git a/src/qdialogcdproperties.h b/src/qdialogcdproperties.h index 1ee732b..8570a88 100644 --- a/src/qdialogcdproperties.h +++ b/src/qdialogcdproperties.h @@ -22,7 +22,7 @@ #ifndef QDIALOGCDPROPERTIES_H #define QDIALOGCDPROPERTIES_H -#include +#include namespace Ui { class QDialogCDProperties; diff --git a/src/qdialogprint.h b/src/qdialogprint.h index ce68a9a..08b5776 100644 --- a/src/qdialogprint.h +++ b/src/qdialogprint.h @@ -21,7 +21,7 @@ #ifndef QDIALOGPRINT_H #define QDIALOGPRINT_H -#include +#include #include "qlightscribe.h" diff --git a/src/qdialogprogress.cpp b/src/qdialogprogress.cpp index 8d72eb9..2257dd2 100644 --- a/src/qdialogprogress.cpp +++ b/src/qdialogprogress.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,7 @@ QDialogProgress::QDialogProgress( QWidget *parent, QLightDrive *drive ) : QDialog(parent), m_ui(new Ui::QDialogProgress), m_drive( drive ), - m_start( new QTime ), + m_start(new QElapsedTimer), m_timer( new QTimer( this ) ) { m_ui->setupUi(this); diff --git a/src/qdialogprogress.h b/src/qdialogprogress.h index ccf15c5..6648601 100644 --- a/src/qdialogprogress.h +++ b/src/qdialogprogress.h @@ -21,7 +21,7 @@ #ifndef QDIALOGPROGRESS_H #define QDIALOGPROGRESS_H -#include +#include namespace Ui { class QDialogProgress; @@ -29,7 +29,7 @@ namespace Ui { class QCDScene; class QAbstractButton; -class QTime; +class QElapsedTimer; class QTimer; class QLightDrive; @@ -56,7 +56,7 @@ private: Ui::QDialogProgress *m_ui; QLightDrive *m_drive; - QTime *m_start; + QElapsedTimer *m_start; QTimer *m_timer; }; diff --git a/src/qdialogsettings.h b/src/qdialogsettings.h index e545a25..990ecdf 100644 --- a/src/qdialogsettings.h +++ b/src/qdialogsettings.h @@ -21,7 +21,7 @@ #ifndef QDIALOGSETTINGS_H #define QDIALOGSETTINGS_H -#include +#include namespace Ui { class QDialogSettings; diff --git a/src/qlightroundtextitem.cpp b/src/qlightroundtextitem.cpp index e8c1ce9..23208a9 100644 --- a/src/qlightroundtextitem.cpp +++ b/src/qlightroundtextitem.cpp @@ -129,7 +129,7 @@ QPainterPath QLightRoundTextItem::shape() const const double pad = 1; for( int i = 0; i < m_text.size(); ++i ) - arcAngle += mcs.width( m_text[ i ] ); + arcAngle += mcs.horizontalAdvance(m_text[i]); double height = ( mcs.height() * 2 ) / 3; double in, out; @@ -192,10 +192,10 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt switch( m_alignment ) { case Qt::AlignCenter : case Qt::AlignHCenter : - angle += mcs.width( m_text ) / diam * ( m_outside ? -1 : 1 ); + angle += mcs.horizontalAdvance(m_text) / diam * ( m_outside ? -1 : 1 ); break; case Qt::AlignRight : - angle += mcs.width( m_text ) / radi * ( m_outside ? -1 : 1 ); + angle += mcs.horizontalAdvance(m_text) / radi * ( m_outside ? -1 : 1 ); break; } @@ -213,12 +213,12 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt for( int i = 0; i < m_text.size(); ++i ) { QChar ch = m_text[ i ]; - double d = ( prevWidth + mcs.width( ch ) ) / diam; + double d = (prevWidth + mcs.horizontalAdvance(ch)) / diam; trans.reset(); trans.rotateRadians( m_outside ? d : -d ); painter->setWorldTransform( trans, true ); - prevWidth = mcs.width( ch ); + prevWidth = mcs.horizontalAdvance(ch); painter->drawText( int( -prevWidth / 2.0 ), int( m_outside ? -m_radius : m_radius ), @@ -371,4 +371,3 @@ void QShapeControllerRoundText::readData( const QString &element, return; } } - diff --git a/src/qlightscribe.cpp b/src/qlightscribe.cpp index 8cce97b..215cd5e 100644 --- a/src/qlightscribe.cpp +++ b/src/qlightscribe.cpp @@ -127,7 +127,7 @@ void printScene( QCDScene *scene, QByteArray &array ) image.save( &buffer, "bmp", 100 ); } -QPixmap QLightDrive::preview( const PrintParameters ¶ms, QCDScene *scene, const QSize &size ) throw( QString ) +QPixmap QLightDrive::preview(const PrintParameters ¶ms, QCDScene *scene, const QSize &size) { qApp->setOverrideCursor( Qt::WaitCursor ); QByteArray array; @@ -150,7 +150,7 @@ QPixmap QLightDrive::preview( const PrintParameters ¶ms, QCDScene *scene, co return pixmap; } -void QLightDrive::print( const PrintParameters ¶ms, QCDScene *scene ) throw( QString ) +void QLightDrive::print(const PrintParameters ¶ms, QCDScene *scene) { qApp->setOverrideCursor( Qt::WaitCursor ); QByteArray array; diff --git a/src/qlightscribe.h b/src/qlightscribe.h index 3466e2d..3fb3e5f 100644 --- a/src/qlightscribe.h +++ b/src/qlightscribe.h @@ -24,6 +24,7 @@ #include "qlscribe.h" #include +#include #include #include @@ -86,8 +87,8 @@ public: double innerRadius() const { return m_innerRadius; } double outerRadius() const { return m_outerRadius; } - QPixmap preview( const PrintParameters ¶ms, QCDScene *scene, const QSize &size ) throw( QString ); - void print( const PrintParameters ¶ms, QCDScene *scene ) throw( QString ); + QPixmap preview(const PrintParameters ¶ms, QCDScene *scene, const QSize &size); + void print(const PrintParameters ¶ms, QCDScene *scene); friend class QLightScribe;