Skip to content

Commit

Permalink
Ported to Qt5 and fixed all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
paulolieuthier committed Jun 14, 2015
1 parent 5a974e7 commit fd7837f
Show file tree
Hide file tree
Showing 62 changed files with 175 additions and 225 deletions.
120 changes: 45 additions & 75 deletions CMakeLists.txt
@@ -1,75 +1,45 @@
project(qps)

cmake_minimum_required(VERSION 2.6.1 FATAL_ERROR)

find_package(Qt4 REQUIRED)
#add_subdirectory(src)

#set(QTERM_BINDIR "${CMAKE_INSTALL_PREFIX}gbin")
#set(QTERM_DATADIR "${CMAKE_INSTALL_PREFIX}gshareqterm")
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}gconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}config.h)


set(SOURCES
proc.cpp
qps.cpp screenshot.cpp
pstable.cpp
uidstr.cpp
ttystr.cpp
dialogs.cpp
infobar.cpp
fieldsel.cpp
wchan.cpp
prefs.cpp
lookup.cpp
details.cpp
command.cpp
misc.cpp
trayicon.cpp
htable.cpp
# htable2.cpp
# pstable2.cpp
qttableview.cpp
)
SET(HEADERS
qps.h
screenshot.h
pstable.h
dialogs.h
fieldsel.h
prefs.h
infobar.h
lookup.h
details.h
command.h
misc.h
trayicon.h
htable.h
# htable2.h
# pstable2.h
qttableview.h
)


# the next line sets up include and link directories and defines some variables that we will use.
# you can modify the behavior by setting some variables, e.g.
# set(QT_USE_OPENGL TRUE) # -> this will cause cmake to include and link against the OpenGL module
include(${QT_USE_FILE})

INCLUDE_DIRECTORIES(
# ${QT_INCLUDES}
# ${PYTHON_INCLUDE_PATH}
)
#link_directories (${xmlrpc_BINARY_DIR}gsrc)

# the variable vterm_SRC that require such a file. note: this assumes that you use
# <<#include "header.moc">> in your files
#qt4_automoc(${VTERM_SRC})

QT4_WRAP_CPP(MOC ${HEADERS})
QT4_WRAP_UI(UI watchdog.ui message.ui )

# create an executable file named "qtproject" from srcs
add_executable(qps ${SOURCES} ${MOC})
target_link_libraries(qps ${QT_LIBRARIES} )

cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR)
set(PROJECT qps)
project(${PROJECT})

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(MAJOR_VERSION 1)
set(MINOR_VERSION 10)
set(PATCH_VERSION 16)
set(QPS_VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
add_definitions(-DQPS_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")

# C++11 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(FATAL "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. C++11 support is required")
endif()

find_package(Qt5 REQUIRED COMPONENTS Widgets X11Extras DBus)

include(GNUInstallDirs)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_AUTOMOC ON)

add_subdirectory(src)

# building tarball with CPack
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION})
set(CPACK_GENERATOR TBZ2)
set(CPACK_SOURCE_GENERATOR TBZ2)
set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
include(CPack)
87 changes: 0 additions & 87 deletions qps.pro

This file was deleted.

60 changes: 60 additions & 0 deletions src/CMakeLists.txt
@@ -0,0 +1,60 @@

set(SOURCES
proc.cpp
qps.cpp
screenshot.cpp
pstable.cpp
uidstr.cpp
ttystr.cpp
dialogs.cpp
infobar.cpp
fieldsel.cpp
wchan.cpp
prefs.cpp
lookup.cpp
details.cpp
command.cpp
misc.cpp
trayicon.cpp
htable.cpp
# htable2.cpp
# pstable2.cpp
qttableview.cpp
)

SET(HEADERS
qps.h
screenshot.h
pstable.h
dialogs.h
fieldsel.h
prefs.h
infobar.h
lookup.h
details.h
command.h
misc.h
trayicon.h
htable.h
# htable2.h
# pstable2.h
qttableview.h
)

qt5_wrap_ui(UIS
watchdog.ui
message.ui
)

add_executable(${PROJECT}
${SOURCES}
${HEADERS}
${UIS}
)

target_link_libraries(${PROJECT}
Qt5::Widgets
Qt5::X11Extras
Qt5::DBus
)

4 changes: 2 additions & 2 deletions command.cpp → src/command.cpp
Expand Up @@ -109,7 +109,7 @@ Command::Command(QString n, QString cmd,bool flag)

}

QString watchCond::getVal(QString &str, char *key)
QString watchCond::getVal(QString &str, const char *key)
{
int n;//key.length();
int idx=str.indexOf(key);
Expand Down Expand Up @@ -489,7 +489,7 @@ void CommandDialog::set_select(const QModelIndex &index)
{
Command *c= static_cast<Command*>(index.internalPointer()); // never Null ?
/*
if (item==NULL) return; //*** important
if (item==NULL) return; // important
Command *c = commands[find_command(item->text())];
*/
name->setText(c->name);
Expand Down
2 changes: 1 addition & 1 deletion command.h → src/command.h
Expand Up @@ -191,7 +191,7 @@ class watchCond
}
// key [txt] [a]
//QString getVal(QString &str, QString &key)
QString getVal(QString &str, char *key);
QString getVal(QString &str, const char *key);
QString getstring();
void putstring(QString str);
};
Expand Down
2 changes: 1 addition & 1 deletion config.h → src/config.h
Expand Up @@ -6,7 +6,7 @@
#ifndef CONFIG_H
#define CONFIG_H

#if defined(linux)
#if defined(__linux__)
#define LINUX

#elif defined(sun) && defined(__SVR4)
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions details.cpp → src/details.cpp
Expand Up @@ -541,6 +541,7 @@ void Files::refresh()

bool Files::refresh_fds()
{
return false;
}

void Files::refresh_window()
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions dialogs.cpp → src/dialogs.cpp
Expand Up @@ -114,7 +114,7 @@ void IntervalDialog::event_label_changed()
return;
}

while(s[i] >= '0' && s[i] <= '9' || s[i] == '.') i++;
while((s[i] >= '0' && s[i] <= '9') || s[i] == '.') i++;

float period = (i > 0) ? s.left(i).toFloat() : -1;

Expand Down Expand Up @@ -144,7 +144,7 @@ void IntervalDialog::done_dialog()

//if(toggle->isChecked())
QString s = ed_result;
while(s[i] >= '0' && s[i] <= '9' || s[i] == '.') i++;
while((s[i] >= '0' && s[i] <= '9') || s[i] == '.') i++;

float period = (i > 0) ? s.left(i).toFloat() : -1;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions infobar.cpp → src/infobar.cpp
Expand Up @@ -64,6 +64,7 @@ bool Infobar::swaplim_exceeded()
} else {
return procview->swap_free < Qps::swaplimit;
} */
return false;
}

char rotate_str[]="|/-\\|/-\\";
Expand Down Expand Up @@ -146,7 +147,7 @@ QColor part2_color;
QColor part3_color;
// DRAFT CODE : DRAFT CODE !!
// return width
int drawSPECTRUM(QPainter *p,int x,int y,char *name,
int drawSPECTRUM(QPainter *p,int x,int y,const char *name,
int total, int part1,int part2=0,int part3=0,int h=0)
{
int total_width;
Expand Down Expand Up @@ -558,7 +559,7 @@ class w_utime: public gwidget
x=x_swap->xpluswidth()+10;
width=drawUTIME(p,x,2,procview->boot_time);
}
virtual char *info()
virtual const char *info()
{
return "passed time after system booting";
};
Expand Down Expand Up @@ -593,7 +594,7 @@ class w_load_avg : public gwidget
pf_write(p,x,y,str);

}
virtual char *info()
virtual const char *info()
{
return "Average CPU%% each 1, 5 ,15 minutes";
};
Expand Down
2 changes: 1 addition & 1 deletion infobar.h → src/infobar.h
Expand Up @@ -43,7 +43,7 @@ class gwidget {
gwidget(QWidget *p){parent=p;};
virtual void draw(QPainter *p){printf("gwidget\n");};
virtual void setPosition(int parent_width,int parent_height){};
virtual char *info(){ return NULL; };
virtual const char *info(){ return NULL; };
void setParent(QWidget *p,Procview *procv){parent=p; procview=procv;};
void resize(int x_,int y_,int w,int h)
{ x=x_;y=y_;width=w;height=h;};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit fd7837f

Please sign in to comment.