From a658ef3369935fbeca86eb390fadff2069fc122b Mon Sep 17 00:00:00 2001 From: in3otd Date: Mon, 13 Jul 2015 22:42:54 +0200 Subject: [PATCH] Use QucsSettings, correct windows titles Implement QSettings read/write on startup/exit, as for the other tools. Set main window title and icon as in the other tools. Correct Help window title. --- qucs-activefilter/bitmaps/big.qucs.xpm | 225 +++++++++++++++++++++++++ qucs-activefilter/helpdialog.cpp | 2 +- qucs-activefilter/main.cpp | 60 ++++++- qucs-activefilter/qucsactivefilter.cpp | 4 + qucs-activefilter/qucsactivefilter.h | 9 + qucs-activefilter/qucsactivefilter.qrc | 1 + 6 files changed, 292 insertions(+), 9 deletions(-) create mode 100644 qucs-activefilter/bitmaps/big.qucs.xpm diff --git a/qucs-activefilter/bitmaps/big.qucs.xpm b/qucs-activefilter/bitmaps/big.qucs.xpm new file mode 100644 index 00000000..b69901cf --- /dev/null +++ b/qucs-activefilter/bitmaps/big.qucs.xpm @@ -0,0 +1,225 @@ +/* XPM */ +static char *big_qucs_xpm[] = { +"32 32 190 2", +" c None", +". c #BCA2BC", +"+ c #B4B2D4", +"@ c #BC96BC", +"# c #7C6E9C", +"$ c #ACB2CC", +"% c #9C869C", +"& c #BCA2CC", +"* c #CCC6E4", +"= c #140A1C", +"- c #140A14", +"; c #0C0A14", +"> c #5C5A64", +", c #ACB6C4", +"' c #CCC6D4", +") c #0C0614", +"! c #0C0A1C", +"~ c #1C121C", +"{ c #1C1224", +"] c #0C060C", +"^ c #1C0A1C", +"/ c #2C2234", +"( c #0C0A24", +"_ c #140A24", +": c #1C0E2C", +"< c #240E24", +"[ c #3C323C", +"} c #B49EC4", +"| c #AC9ECC", +"1 c #CCCEE4", +"2 c #84768C", +"3 c #140E24", +"4 c #241634", +"5 c #4C324C", +"6 c #341A3C", +"7 c #645E7C", +"8 c #8472AC", +"9 c #9486BC", +"0 c #D4D6EC", +"a c #4C4664", +"b c #443A64", +"c c #DCEAF4", +"d c #CCBADC", +"e c #1C1634", +"f c #342644", +"g c #7C628C", +"h c #6C567C", +"i c #4C3654", +"j c #2C1634", +"k c #1C0E24", +"l c #645A7C", +"m c #8C7AB4", +"n c #9C92C4", +"o c #D4DEF4", +"p c #ACAECC", +"q c #544A6C", +"r c #A4A2C4", +"s c #E4EEF4", +"t c #CCCAE4", +"u c #DCD2E4", +"v c #540E1C", +"w c #840E14", +"x c #440E1C", +"y c #24264C", +"z c #44365C", +"A c #ACAAC4", +"B c #C4C6DC", +"C c #8C7AAC", +"D c #5C426C", +"E c #3C2A44", +"F c #2C162C", +"G c #A49EB4", +"H c #9492AC", +"I c #8C82A4", +"J c #340E1C", +"K c #7C0E14", +"L c #14122C", +"M c #3C3A64", +"N c #3C3E74", +"O c #ACA6CC", +"P c #D4DEEC", +"Q c #BCB2DC", +"R c #846694", +"S c #5C3E64", +"T c #2C1E3C", +"U c #341E34", +"V c #C4C2CC", +"W c #ECEAEC", +"X c #2C2A4C", +"Y c #242254", +"Z c #1C1A4C", +"` c #7466A4", +" . c #BCBADC", +".. c #CCDEEC", +"+. c #745A84", +"@. c #24162C", +"#. c #3C2A3C", +"$. c #241E2C", +"%. c #1C1E4C", +"&. c #242654", +"*. c #142E64", +"=. c #1C326C", +"-. c #1C265C", +";. c #34366C", +">. c #8476AC", +",. c #CCD2EC", +"'. c #C4CAE4", +"). c #4C4254", +"!. c #44325C", +"~. c #4C2E54", +"{. c #141234", +"]. c #142654", +"^. c #144274", +"/. c #1C3E74", +"(. c #1C2254", +"_. c #1C1E54", +":. c #4C4A7C", +"<. c #A492C4", +"[. c #6C6A7C", +"}. c #64628C", +"|. c #847A8C", +"1. c #644A74", +"2. c #14224C", +"3. c #1C3674", +"4. c #14427C", +"5. c #143E7C", +"6. c #1C3A7C", +"7. c #2C2644", +"8. c #D4E2F4", +"9. c #B4AACC", +"0. c #8C7AA4", +"a. c #140E2C", +"b. c #141634", +"c. c #14366C", +"d. c #1C427C", +"e. c #1C3E7C", +"f. c #141E44", +"g. c #C4CEEC", +"h. c #DCE6EC", +"i. c #C4C6C4", +"j. c #6C5E74", +"k. c #445274", +"l. c #A4B6DC", +"m. c #2C528C", +"n. c #6472AC", +"o. c #14163C", +"p. c #4C4684", +"q. c #BCB6DC", +"r. c #D4CEDC", +"s. c #9C9EA4", +"t. c #B4C2DC", +"u. c #2C365C", +"v. c #5C6A94", +"w. c #8CA2CC", +"x. c #BCBEE4", +"y. c #8C86AC", +"z. c #1C2A64", +"A. c #74769C", +"B. c #CCCADC", +"C. c #C4CEE4", +"D. c #A49EBC", +"E. c #1C162C", +"F. c #8C8AB4", +"G. c #445A8C", +"H. c #A49EC4", +"I. c #B4BAD4", +"J. c #B4B2DC", +"K. c #CCCEEC", +"L. c #CCDAF4", +"M. c #BCC6E4", +"N. c #746A8C", +"O. c #949AB4", +"P. c #9C8EB4", +"Q. c #544E74", +"R. c #342E4C", +"S. c #242A54", +"T. c #6C7AA4", +"U. c #4C5E94", +"V. c #7486B4", +"W. c #9CAAD4", +"X. c #C4D2EC", +"Y. c #D4E2EC", +"Z. c #DCEEF4", +"`. c #D4DAEC", +" + c #C4C6E4", +".+ c #B4AED4", +"++ c #7C7AA4", +"@+ c #9496B4", +"#+ c #9492B4", +"$+ c #8C92AC", +" ", +" ", +" . + ", +" @ # $ ", +" % & * $ ", +" = - ; = = - > , ' ", +" = ; ; = ) = ! ) = ! ", +" ~ ; ) ) ; = ! = ! = { ", +" = ; ] ) ; ) ) = ! = = ^ / ", +" = ; ) ! ) = ! ( ! ! _ : < _ [ } | 1 2 ", +" 3 = ) ! ) ( ( ( ( _ 3 4 5 6 { = 7 8 9 0 a b 0 c d ", +" = ( = = ( = ! _ ! e f g h i j k l m n o p q r s t u ", +" 3 _ v w x ) _ ( _ y z A B C D E j F n r C G H I ", +" _ J w K < _ _ L M b N O P Q R S T E U V V W ", +" _ _ x ^ _ 3 X M Y Z X ` ...| +.@.T #. ", +" $.= _ _ L %.&.*.=.-.Z ;.>.,.'.).!.~. ", +" = ! = 3 {.].^././.*.(._.:.<.[.}.|.1. ", +" > = ! ( L 2.3.4.5.6.*._.Y 7.}.8.9. ", +" 0.@.M 3 = a.b.].c.d.e.3.f.a.&.8 g.h. ", +" i.j.k.l.b ; ( 3 f.*.4.m.n.o.Z %.p.q. ", +" r.s.t.l. = ! 3 u.v.w.x.y.*.z._.A. ", +" B.C.D.t. ! E.x.Q 9.+ F.6.G. ", +" H.I.I. ! J. .K...'. ", +"r.J.A L.M.D.N.O. ", +"P.9. Q.R.%.S.T. ", +" N U.V.W.X. ", +" M.X.Y.c c ", +" c Z.c `. + ", +" B .+n ++@+ ", +" #+$+p A ", +" ", +" "}; diff --git a/qucs-activefilter/helpdialog.cpp b/qucs-activefilter/helpdialog.cpp index a7805f72..c7d561f7 100644 --- a/qucs-activefilter/helpdialog.cpp +++ b/qucs-activefilter/helpdialog.cpp @@ -31,7 +31,7 @@ HelpDialog::HelpDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle("Qucs Filter Help"); + setWindowTitle("Qucs Active Filter Help"); // -------- set help text into dialog ------------ diff --git a/qucs-activefilter/main.cpp b/qucs-activefilter/main.cpp index e49c0910..7e159f50 100644 --- a/qucs-activefilter/main.cpp +++ b/qucs-activefilter/main.cpp @@ -22,16 +22,52 @@ #include #include #include + #include "qucsactivefilter.h" +struct tQucsSettings QucsSettings; + + +// ######################################################################### +// Loads the settings file and stores the settings. +bool loadSettings() +{ + QSettings settings("qucs","qucs"); + settings.beginGroup("QucsActiveFilter"); + if(settings.contains("x"))QucsSettings.x=settings.value("x").toInt(); + if(settings.contains("y"))QucsSettings.y=settings.value("y").toInt(); + settings.endGroup(); + + if(settings.contains("font"))QucsSettings.font.fromString(settings.value("font").toString()); + if(settings.contains("Language"))QucsSettings.Language=settings.value("Language").toString(); + + return true; +} + + +// ######################################################################### +// Saves the settings in the settings file. +bool saveApplSettings(QucsActiveFilter *qucs) +{ + QSettings settings ("qucs","qucs"); + settings.beginGroup("QucsActiveFilter"); + settings.setValue("x", qucs->x()); + settings.setValue("y", qucs->y()); + settings.endGroup(); + return true; + +} + + int main(int argc, char *argv[]) { - QString Lang,LangDir; - QSettings settings("qucs","qucs"); - if(settings.contains("Language")) { - Lang=settings.value("Language").toString(); - } + QString LangDir; + // apply default settings + QucsSettings.x = 200; + QucsSettings.y = 100; + QucsSettings.font = QFont("Helvetica", 12); + // is application relocated? char * var = getenv ("QUCSDIR"); if (var != NULL) { QDir QucsDir = QDir (var); @@ -42,16 +78,24 @@ int main(int argc, char *argv[]) LangDir = LANGUAGEDIR; } + loadSettings(); + QApplication a(argc, argv); + a.setFont(QucsSettings.font); QTranslator tor( 0 ); + QString Lang = QucsSettings.Language; if(Lang.isEmpty()) Lang = QString(QLocale::system().name()); tor.load( QString("qucs_") + Lang, LangDir); a.installTranslator( &tor ); - QucsActiveFilter w; - w.show(); + QucsActiveFilter *w = new QucsActiveFilter(); + w->raise(); + w->move(QucsSettings.x, QucsSettings.y); // position before "show" !!! + w->show(); - return a.exec(); + int result = a.exec(); + saveApplSettings(w); + return result; } diff --git a/qucs-activefilter/qucsactivefilter.cpp b/qucs-activefilter/qucsactivefilter.cpp index d74c8be9..ee4676e6 100644 --- a/qucs-activefilter/qucsactivefilter.cpp +++ b/qucs-activefilter/qucsactivefilter.cpp @@ -35,6 +35,10 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent) Fc = 1000; ftyp = Filter::NoFilter; + // set application icon + setWindowIcon(QPixmap(":/images/bitmaps/big.qucs.xpm")); + setWindowTitle("Qucs Active Filter " PACKAGE_VERSION); + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); // -------- create menubar ------------------- diff --git a/qucs-activefilter/qucsactivefilter.h b/qucs-activefilter/qucsactivefilter.h index ef7475d0..290067de 100644 --- a/qucs-activefilter/qucsactivefilter.h +++ b/qucs-activefilter/qucsactivefilter.h @@ -24,6 +24,15 @@ #include #include "filter.h" +struct tQucsSettings { + int x, y; // position of main window + QFont font; + QString LangDir; + QString Language; +}; + +extern struct tQucsSettings QucsSettings; + class QucsActiveFilter : public QMainWindow { Q_OBJECT diff --git a/qucs-activefilter/qucsactivefilter.qrc b/qucs-activefilter/qucsactivefilter.qrc index ab6db3de..9154471d 100644 --- a/qucs-activefilter/qucsactivefilter.qrc +++ b/qucs-activefilter/qucsactivefilter.qrc @@ -13,5 +13,6 @@ bitmaps/cauer-bandpass.svg bitmaps/mfb-bandpass.svg bitmaps/sk-bandpass.svg + bitmaps/big.qucs.xpm