-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved app functionality to separate class
- Loading branch information
1 parent
e5a682f
commit e06bef4
Showing
6 changed files
with
147 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ package/*.tar.* | |
*~ | ||
*.bak | ||
*.auto | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* File name: YQPkgApplication.h | ||
* Summary: Application class for yqpkg | ||
* License: GPL V2 - See file LICENSE for details. | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* Author: Stefan Hundhammer <[email protected]> | ||
*/ | ||
|
||
|
||
#include <QApplication> | ||
|
||
#include "YQPackageSelector.h" | ||
#include "YQPkgApplication.h" | ||
#include "Logger.h" | ||
#include "Exception.h" | ||
|
||
|
||
YQPkgApplication * YQPkgApplication::_instance = 0; | ||
|
||
|
||
YQPkgApplication::YQPkgApplication() | ||
: QObject() | ||
, _pkgSel(0) | ||
{ | ||
_instance = this; | ||
logDebug() << "Creating YQPkgApplication" << endl; | ||
} | ||
|
||
|
||
YQPkgApplication::~YQPkgApplication() | ||
{ | ||
logDebug() << "Destroying YQPkgApplication..." << endl; | ||
|
||
if ( _pkgSel ) | ||
{ | ||
delete _pkgSel; | ||
_pkgSel = 0; | ||
} | ||
|
||
logDebug() << "Destroying YQPkgApplication done" << endl; | ||
_instance = 0; | ||
} | ||
|
||
|
||
void YQPkgApplication::run() | ||
{ | ||
createPkgSel(); | ||
qApp->exec(); | ||
} | ||
|
||
|
||
void YQPkgApplication::createPkgSel() | ||
{ | ||
if ( _pkgSel ) | ||
return; | ||
|
||
_pkgSel = new YQPackageSelector( 0, 0 ); | ||
CHECK_PTR( _pkgSel ); | ||
|
||
QObject::connect( _pkgSel, SIGNAL( commit() ), | ||
qApp, SLOT ( quit() ) ); | ||
|
||
_pkgSel->show(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* File name: YQPkgApplication.h | ||
* Summary: Application class for yqpkg | ||
* License: GPL V2 - See file LICENSE for details. | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* Author: Stefan Hundhammer <[email protected]> | ||
*/ | ||
|
||
|
||
#ifndef YQPkgApplication_h | ||
#define YQPkgApplication_h | ||
|
||
#include <QObject> | ||
|
||
|
||
class YQPackageSelector; | ||
|
||
/** | ||
* Application class for yqpkg. | ||
**/ | ||
class YQPkgApplication: public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
/** | ||
* Constructor | ||
**/ | ||
YQPkgApplication(); | ||
|
||
/** | ||
* Destructor | ||
**/ | ||
virtual ~YQPkgApplication(); | ||
|
||
/** | ||
* Return the instance of this class or 0 if there is none. | ||
* | ||
* This is not a real singleton, but for the life time of this application | ||
* this instance will remain alive, i.e. for most other classes related to | ||
* this. | ||
**/ | ||
static YQPkgApplication * instance() { return _instance; } | ||
|
||
/** | ||
* Run the application. This also handles the Qt event loop. | ||
**/ | ||
void run(); | ||
|
||
protected: | ||
|
||
/** | ||
* Create (and show) the YQPackageSelector if it doesn't already exist. | ||
**/ | ||
void createPkgSel(); | ||
|
||
|
||
// | ||
// Data members | ||
// | ||
|
||
YQPackageSelector * _pkgSel; | ||
|
||
static YQPkgApplication * _instance; | ||
}; | ||
|
||
#endif // YQPkgApplication_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters