Commit 939029c9 authored by Jonathan Marten's avatar Jonathan Marten
Browse files

Tidy up application sources in 'apps'

Rename files to reflect class name
Eliminate dependencies of 'gui' and 'core' on 'apps' include files
Remove unused variables, functions and includes
parent a970df6c
......@@ -280,8 +280,8 @@ target_link_libraries(kmixgui
set(kmix_SRCS
apps/main.cpp
apps/kmix.cpp
apps/KMixApp.cpp
apps/kmixwindow.cpp
apps/kmixapp.cpp
${kmix_debug_SRCS}
)
......
......@@ -19,17 +19,20 @@
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "KMixApp.h"
#include "kmixapp.h"
#include <qapplication.h>
#include <qcommandlineparser.h>
#include "apps/kmix.h"
#include "kmix_debug.h"
#include "core/ControlManager.h"
#include "core/GlobalConfig.h"
#include "apps/kmixwindow.h"
static bool firstCaller = true;
// Originally this class was a subclass of KUniqueApplication.
// Since, now that a unique application is enforced earlier by KDBusService,
// the only purpose of this class is to receive the activateRequested()
......@@ -37,7 +40,7 @@ static bool firstCaller = true;
KMixApp::KMixApp()
: QObject(),
m_kmix(0),
m_kmix(nullptr),
creationLock(QMutex::Recursive)
{
GlobalConfig::init();
......@@ -56,14 +59,14 @@ KMixApp::~KMixApp()
qCDebug(KMIX_LOG) << "Deleting KMixApp";
ControlManager::instance().shutdownNow();
delete m_kmix;
m_kmix = 0;
m_kmix = nullptr;
GlobalConfig::shutdown();
}
void KMixApp::createWindowOnce(bool hasArgKeepvisibility, bool reset)
{
// Create window, if it was not yet created (e.g. via autostart or manually)
if (m_kmix == 0)
if (m_kmix==nullptr)
{
qCDebug(KMIX_LOG) << "Creating new KMix window";
m_kmix = new KMixWindow(hasArgKeepvisibility, reset);
......
......@@ -27,6 +27,7 @@
class QCommandLineParser;
class KMixWindow;
class KMixApp : public QObject
{
Q_OBJECT
......
......@@ -18,7 +18,7 @@
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "apps/kmix.h"
#include "kmixwindow.h"
// include files for Qt
#include <QApplication>
......@@ -29,29 +29,31 @@
#include <QPushButton>
#include <qradiobutton.h>
#include <QCursor>
#include <QString>
#include <QTabWidget>
#include <QPointer>
#include <QHash>
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <QKeySequence>
// include files for KDE
#include <KGlobalAccel>
#include <kglobalaccel.h>
#include <kmessagebox.h>
#include <klocalizedstring.h>
#include <kconfig.h>
#include <kstandardaction.h>
#include <kxmlguifactory.h>
#include <kactioncollection.h>
#include <KProcess>
// KMix
#include "gui/guiprofile.h"
#include "kmix_debug.h"
#include "core/ControlManager.h"
#include "core/GlobalConfig.h"
#include "core/MasterControl.h"
#include "core/MediaController.h"
#include "core/mixertoolbox.h"
#include "core/kmixdevicemanager.h"
#include "gui/guiprofile.h"
#include "gui/kmixerwidget.h"
#include "gui/kmixprefdlg.h"
#include "gui/kmixdockwidget.h"
......@@ -60,18 +62,14 @@
#include "gui/dialogaddview.h"
#include "gui/dialogselectmaster.h"
#include "dbus/dbusmixsetwrapper.h"
#include "kmix_debug.h"
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <QKeySequence>
/* KMixWindow
* Constructs a mixer window (KMix main window)
*/
KMixWindow::KMixWindow(bool invisible, bool reset) :
KXmlGuiWindow(0, Qt::WindowFlags(
KDE_DEFAULT_WINDOWFLAGS | Qt::WindowContextHelpButtonHint)), m_multiDriverMode(false), // -<- I never-ever want the multi-drivermode to be activated by accident
KXmlGuiWindow(nullptr, Qt::WindowFlags(KDE_DEFAULT_WINDOWFLAGS|Qt::WindowContextHelpButtonHint)),
m_multiDriverMode(false), // -<- I never-ever want the multi-drivermode to be activated by accident
m_autouseMultimediaKeys(true),
m_dockWidget(), m_dsm(0), m_dontSetDefaultCardOnStart(false)
{
......@@ -173,7 +171,6 @@ void KMixWindow::initActions()
// settings menu
_actionShowMenubar = KStandardAction::showMenubar(this, SLOT(toggleMenuBar()), actionCollection());
//actionCollection()->addAction(QStringLiteral( a->objectName()), a );
KStandardAction::preferences(this, SLOT(showSettings()), actionCollection());
KStandardAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), actionCollection());
QAction* action = actionCollection()->addAction(QStringLiteral("hide_kmixwindow"));
......@@ -1198,17 +1195,6 @@ void KMixWindow::toggleMenuBar()
menuBar()->setVisible(_actionShowMenubar->isChecked());
}
void KMixWindow::forkExec(const QStringList& args)
{
int pid = KProcess::startDetached(args);
if (pid == 0)
{
KMessageBox::error(this, i18n("The helper application is either not installed or not working.\n\n%1",
args.join(QLatin1String(" "))));
}
}
void KMixWindow::slotConfigureCurrentView()
{
KMixerWidget *mw = qobject_cast<KMixerWidget *>(m_wsMixers->currentWidget());
......
......@@ -18,49 +18,44 @@
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KMIX_H
#define KMIX_H
#ifndef KMIXWINDOW_H
#define KMIXWINDOW_H
#include <config.h>
// Qt
#include <QString>
class QLabel;
#include <qlist.h>
#include <QVBoxLayout>
class QPushButton;
#include <QTimer>
class QTabWidget;
#include <qboxlayout.h>
#include <qtimer.h>
// KDE
class KAccel;
class KToggleAction;
// class KAccel;
#include <kxmlguiwindow.h>
// KMix
#include "core/GlobalConfig.h"
#include "core/ControlManager.h"
#include "core/mixer.h"
class QTabWidget;
class KToggleAction;
class KMixDockWidget;
class KMixerWidget;
class KMixWindow;
class Mixer;
#include "core/mixer.h"
class DialogSelectMaster;
class
KMixWindow : public KXmlGuiWindow
class KMixWindow : public KXmlGuiWindow
{
Q_OBJECT
public:
public:
KMixWindow(bool invisible, bool reset);
~KMixWindow();
virtual ~KMixWindow();
private:
private:
void saveBaseConfig();
void saveViewConfig();
void loadAndInitConfig(bool reset);
......@@ -74,9 +69,10 @@ KMixWindow : public KXmlGuiWindow
void fixConfigAfterRead();
protected:
bool queryClose() override;
public slots:
public slots:
void controlsChange(ControlManager::ChangeType changeType);
void quit();
void showSettings();
......@@ -95,15 +91,10 @@ KMixWindow : public KXmlGuiWindow
void newMixerShown(int tabIndex);
void slotSelectMaster();
private:
KMixerWidget* findKMWforTab( const QString& tabId );
void forkExec(const QStringList& args);
KAccel *m_keyAccel;
KToggleAction* _actionShowMenubar;
private:
KMixerWidget* findKMWforTab( const QString& tabId );
KToggleAction* _actionShowMenubar;
/**
* configSnapshot is used to hold the original state before modifications in the preferences dialog
*/
......@@ -121,23 +112,25 @@ private:
QString m_defaultCardOnStart;
bool m_dontSetDefaultCardOnStart;
QLabel *m_errorLabel;
QList<QString> m_backendFilter;
QStringList m_backendFilter;
unsigned int m_configVersion;
void showVolumeDisplay();
void increaseOrDecreaseVolume(bool increase);
bool addMixerWidget(const QString& mixer_ID, QString guiprofId, int insertPosition);
void setInitialSize();
private:
private:
void showVolumeDisplay();
void increaseOrDecreaseVolume(bool increase);
bool addMixerWidget(const QString& mixer_ID, QString guiprofId, int insertPosition);
void setInitialSize();
bool profileExists(QString guiProfileId);
bool updateDocking();
void removeDock();
void updateTabsClosable();
private:
static QString getKmixctrlRcFilename(const QString &postfix);
bool profileExists(QString guiProfileId);
bool updateDocking();
void removeDock();
void updateTabsClosable();
private slots:
private slots:
void slotConfigureCurrentView();
void plugged(const char *driverName, const QString &udi, int dev);
......@@ -163,4 +156,4 @@ private:
void saveVolumes4() { saveVolumes(QString("4")); }
};
#endif // KMIX_H
#endif // KMIXWINDOW_H
......@@ -26,7 +26,7 @@
#include <klocalizedstring.h>
#include <kdbusservice.h>
#include "KMixApp.h"
#include "kmixapp.h"
#include "kmix_debug.h"
static const char description[] =
......
......@@ -21,18 +21,13 @@
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "gui/kmixdockwidget.h"
#include "kmixdockwidget.h"
// Define this if KStatusNotifierItem::setOverlayIconByName() works.
// As of March 2020 it appears to be not working, the base icon is
// shown but with no overlay.
//#define CAN_USE_ICON_OVERLAY 1
#include <klocalizedstring.h>
#include <kwindowsystem.h>
#include <kactioncollection.h>
#include <ktoggleaction.h>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDesktopWidget>
......@@ -44,12 +39,18 @@
#include <QPainter>
#endif // CAN_USE_ICON_OVERLAY
#include "apps/kmix.h"
#include <klocalizedstring.h>
#include <kwindowsystem.h>
#include <kactioncollection.h>
#include <ktoggleaction.h>
#include <kxmlguiwindow.h>
#include "core/ControlManager.h"
#include "core/mixer.h"
#include "gui/viewdockareapopup.h"
KMixDockWidget::KMixDockWidget(KMixWindow* parent)
KMixDockWidget::KMixDockWidget(KXmlGuiWindow *parent)
: KStatusNotifierItem(parent)
, _oldToolTipValue(-1)
, _oldPixmapType('-')
......
......@@ -31,8 +31,8 @@ class QMenu;
class QWidgetAction;
class KToggleAction;
class KXmlGuiWindow;
class KMixWindow;
class ViewDockAreaPopup;
......@@ -40,11 +40,11 @@ class KMixDockWidget : public KStatusNotifierItem
{
Q_OBJECT
public:
explicit KMixDockWidget(KMixWindow *parent);
public:
explicit KMixDockWidget(KXmlGuiWindow *parent);
virtual ~KMixDockWidget();
public slots:
public slots:
void activate(const QPoint &pos) override;
void controlsChange(ControlManager::ChangeType changeType);
......@@ -58,20 +58,23 @@ private:
QWidgetAction *_dockWidgetAction;
int _oldToolTipValue;
char _oldPixmapType;
KMixWindow* _kmixMainWindow;
KXmlGuiWindow *_kmixMainWindow;
int _delta;
KToggleAction *_dockMuteAction;
private:
bool onlyHaveOneMouseButtonAction() const;
void refreshVolumeLevels();
void createWidgets();
void setVolumeTip();
void updatePixmap();
private slots:
protected slots:
void contextMenuAboutToShow();
private slots:
void dockMute();
void trayWheelEvent(int delta, Qt::Orientation wheelOrientation);
void contextMenuAboutToShow();
};
#endif
......@@ -21,12 +21,9 @@
#include "gui/kmixerwidget.h"
// Qt
#include <QIcon>
#include <QLabel>
#include <qpixmap.h>
#include <QString>
#include <qtoolbutton.h>
#include <QVBoxLayout>
#include <qboxlayout.h>
#include <qtabwidget.h>
// KDE
......@@ -34,14 +31,13 @@
#include <kconfiggroup.h>
// KMix
#include "apps/kmix.h"
#include "core/GlobalConfig.h"
#include "core/mixer.h"
#include "core/mixertoolbox.h"
#include "gui/guiprofile.h"
#include "gui/kmixtoolbox.h"
#include "gui/mixdevicewidget.h"
#include "gui/viewsliders.h"
#include "core/GlobalConfig.h"
#include "core/mixer.h"
#include "core/mixertoolbox.h"
/**
......
......@@ -34,9 +34,9 @@
#include <klocalizedstring.h>
#include <kwindowsystem.h>
#include <kglobalaccel.h>
#include <kxmlguiwindow.h>
// KMix
#include "apps/kmix.h"
#include "core/mixer.h"
#include "core/ControlManager.h"
#include "gui/dialogchoosebackends.h"
......@@ -50,7 +50,7 @@
ViewDockAreaPopup::ViewDockAreaPopup(QWidget* parent, const QString &id, ViewBase::ViewFlags vflags,
const QString &guiProfileId, KMixWindow *dockW)
const QString &guiProfileId, KXmlGuiWindow *dockW)
: ViewBase(parent, id, {}, vflags, guiProfileId),
_kmixMainWindow(dockW)
{
......
......@@ -36,13 +36,15 @@ class QWidget;
class Mixer;
class MixDevice;
class KMixWindow;
class KXmlGuiWindow;
class ViewDockAreaPopup : public ViewBase
{
Q_OBJECT
public:
ViewDockAreaPopup(QWidget* parent, const QString &id, ViewBase::ViewFlags vflags, const QString &guiProfileId, KMixWindow *dockW);
ViewDockAreaPopup(QWidget* parent, const QString &id, ViewBase::ViewFlags vflags, const QString &guiProfileId, KXmlGuiWindow *dockW);
virtual ~ViewDockAreaPopup();
QWidget* add(shared_ptr<MixDevice> md) override;
......@@ -58,7 +60,7 @@ protected:
void keyPressEvent(QKeyEvent *ev) override;
private:
KMixWindow *_kmixMainWindow;
KXmlGuiWindow *_kmixMainWindow;
QGridLayout *_layoutMDW;
QPushButton* createRestoreVolumeButton (int storageSlot);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment