From c20c5207c851e0e54f10cd3ec7074b7c44a1c851 Mon Sep 17 00:00:00 2001 From: Umcaruje Date: Fri, 29 Jul 2016 00:39:10 +0200 Subject: [PATCH] Fix dialog button mismatch (#2908) * Fix dialog button mismatch * Change order in menu * Make buttons the same role, so we have custom ordering * Hide the exit button, add a close button to the dialog, change ordering * Make the exit button not visible --- data/themes/default/discard.png | Bin 0 -> 217 bytes data/themes/default/ignore.png | Bin 0 -> 506 bytes data/themes/default/recover.png | Bin 0 -> 303 bytes src/core/main.cpp | 60 +++++++++++++++++++------------- 4 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 data/themes/default/discard.png create mode 100644 data/themes/default/ignore.png create mode 100755 data/themes/default/recover.png diff --git a/data/themes/default/discard.png b/data/themes/default/discard.png new file mode 100644 index 0000000000000000000000000000000000000000..6dec18588c0595f7df19a9b8063bb9ba315f06da GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fEX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR49o!0(WC^WyShghbM(|yb0%C}v}4{nyzopr E0P9LcU;qFB literal 0 HcmV?d00001 diff --git a/data/themes/default/ignore.png b/data/themes/default/ignore.png new file mode 100644 index 0000000000000000000000000000000000000000..9e0e3f876b1b8a764d3449851f6a698ca963a521 GIT binary patch literal 506 zcmV0znXlf6z`7Ldhj2NNcMFu`<{aYF>e7proNC z*zyE6)M#U4p@o6o3OY&?3yaTUXXA42?HLS{Y%ZDE{dQ({X08J05K=t|Rnl>Zy)CID z=}OY2>0TwhNP3j?TzC?Qtr{?+TxPcS7b6C}2G(})0~iB6AOp^TJ}?Egwr6c;lHghZ zeF9nq5eYa4mI1t$0?z_yH39YO6j%jmiGtff_$g2Qx&RiroVUF_EVqt*?@~ literal 0 HcmV?d00001 diff --git a/data/themes/default/recover.png b/data/themes/default/recover.png new file mode 100755 index 0000000000000000000000000000000000000000..42d8be333af5cf67dcfe0686757d098c645f820e GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fEX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4+C`{moi-_Nc$5wn@34Rkkyr>mdKI;Vst08NQ>3jhEB literal 0 HcmV?d00001 diff --git a/src/core/main.cpp b/src/core/main.cpp index 8b4f7b888..b04d19f51 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -718,10 +718,6 @@ int main( int argc, char * * argv ) " %6" " %7" " " - " " - " %8" - " %9" - " " "" "" ).arg( MainWindow::tr( "There is a recovery file present. " @@ -738,35 +734,49 @@ int main( int argc, char * * argv ) "present recover file from being overwritten." ), MainWindow::tr( "Discard" ), MainWindow::tr( "Launch a default session and delete " - "the restored files. This is not reversible." ), - MainWindow::tr( "Quit" ), - MainWindow::tr( "Shut down LMMS with no further action." ) + "the restored files. This is not reversible." ) ) ); mb.setIcon( QMessageBox::Warning ); mb.setWindowIcon( embed::getIconPixmap( "icon" ) ); + mb.setWindowFlags( Qt::WindowCloseButtonHint ); - mb.setStandardButtons( QMessageBox::Ok | - QMessageBox::Discard ); - - mb.setButtonText( QMessageBox::Ok, - MainWindow::tr( "Recover" ) ); - - QAbstractButton * recover; - QAbstractButton * discard; + QPushButton * recover; + QPushButton * discard; QPushButton * ignore; QPushButton * exit; + + #if QT_VERSION >= 0x050000 + // setting all buttons to the same roles allows us + // to have a custom layout + discard = mb.addButton( MainWindow::tr( "Discard" ), + QMessageBox::AcceptRole ); + ignore = mb.addButton( MainWindow::tr( "Ignore" ), + QMessageBox::AcceptRole ); + recover = mb.addButton( MainWindow::tr( "Recover" ), + QMessageBox::AcceptRole ); - recover = mb.QMessageBox::button( QMessageBox::Ok ); - discard = mb.QMessageBox::button( QMessageBox::Discard ); - ignore = mb.addButton( MainWindow::tr( "Ignore" ), - QMessageBox::NoRole ); - ignore->setIcon( embed::getIconPixmap( "no_entry" ) ); - exit = mb.addButton( MainWindow::tr( "Exit" ), - QMessageBox::RejectRole ); - exit->setIcon( embed::getIconPixmap( "exit" ) ); + # else + // in qt4 the button order is reversed + recover = mb.addButton( MainWindow::tr( "Recover" ), + QMessageBox::AcceptRole ); + ignore = mb.addButton( MainWindow::tr( "Ignore" ), + QMessageBox::AcceptRole ); + discard = mb.addButton( MainWindow::tr( "Discard" ), + QMessageBox::AcceptRole ); - mb.setDefaultButton( QMessageBox::Ok ); + #endif + + // have a hidden exit button + exit = mb.addButton( "", QMessageBox::RejectRole); + exit->setVisible(false); + + // set icons + recover->setIcon( embed::getIconPixmap( "recover" ) ); + discard->setIcon( embed::getIconPixmap( "discard" ) ); + ignore->setIcon( embed::getIconPixmap( "ignore" ) ); + + mb.setDefaultButton( recover ); mb.setEscapeButton( exit ); mb.exec(); @@ -774,7 +784,7 @@ int main( int argc, char * * argv ) { gui->mainWindow()->sessionCleanup(); } - else if( mb.clickedButton() == recover ) // ::Recover + else if( mb.clickedButton() == recover ) // Recover { fileToLoad = recoveryFile; gui->mainWindow()->setSession( MainWindow::SessionState::Recover );